Sign in to follow this  
b1gjo3

DX10 Beginner Needs Help

Recommended Posts

is it a good idea as a beginner, to write a wrapper class for directx10. for instance.. use that class to instantiate direct3d devices, and have in it a pointer to a Render function that does all the drawing which can be user defined outside the class. ex. //dxwrap.h class DirectX10Wrapper { //all functions void (*pRender) (); //the pointer to the render function } //..dxwrap.h //testprog.cpp #include "dxwrap.h" //user defined render function void MyRenderFunc(); int APIENTRY _tWinMain(.....) { //have all necessary windowapi / message loop DirectX10Wrapper wrapper; wrapper.pRender = &MyRenderFunc; } //..testprog.cpp ------------------------------------------------- would something like this be a good idea? also can somebody tell me about SwapChain and why i need it for a directx10 application. thanks everyone and sorry if this post was confusing.

Share this post


Link to post
Share on other sites
Wrapper classes are only ever useful if they're doing at least one of three things:


  1. Turning a C-style (free function) API into an object-oriented one

  2. Hiding some details of the API to make it easier to use - e.g. wrapping the CreateDevice function that takes any resolution, in one that always creates it at 1024x768 resolution

  3. Adding functionality to the API, e.g. tracking when a renderstate has already been set so that it doesn't get set again



I would definitely not do what you're suggesting with a function pointer. Use inheritance and a virtual function; that's what they're there for - i.e. have a D3D10Application class, with a virtual Render() function, and then derive a MyD3D10Game class from D3D10Application that implements that function.

A swap chain is how a generalized form of double-buffering is implemented. The graphics device renders into one of the buffers in the chain, while a different buffer is displayed on screen. When the graphics device has finished rendering, the buffers are swapped, causing the image on screen to update instantaneously instead of the user seeing it get drawn part-by-part by the graphics device.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this