Jump to content
  • Advertisement
Sign in to follow this  

Help With classes.

This topic is 5081 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Alright, so i have a Renderer class.
class Renderer

	BOOL CreateGLWindow(char *, int, int, int, BOOL);
	GLvoid ReSizeGLScene(GLsizei, GLsizei);
	int InitGL(GLvoid);
	GLvoid KillGLWindow();

	HDC GetHDC() const { return hDC; }
	HGLRC GetHRC() const { return hRC; }
	HWND GetHWND() const { return hWnd; }
	HINSTANCE GetInst() const { return hInstance; }
	BOOL IsActive() const { return active; }
	BOOL IsFullscreen() const { return fullscreen; }

	char *title;
	char *GLname;

	HDC				hDC;
	HWND			hWnd;
	HINSTANCE		hInstance;

	BOOL active;
	BOOL fullscreen;

	GLuint PixelFormat;							//Holds the results after searching for a match
	WNDCLASS wc;								//Windows Class Structure

	DWORD dwExstyle;							//Exstyle
	DWORD dwstyle;								//style

	RECT WindowRect;							//Grabs Upper Left and Lower Right

In my CreateGLWindow() i have:
hInstance = GetModuleHandle(NULL);			//Get an instance for our window.
	wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;		//Redraw on move, and own DC
	wc.lpfnWndProc = (WNDPROC) RenderProc;				//Set window procedure
	wc.cbClsExtra = 0;							//No extra window data
	wc.cbWndExtra = 0;							//No extra window data
	wc.hInstance = hInstance;					//Set instance of window
	wc.hIcon = LoadIcon(NULL, IDI_WINLOGO);		//LoadDefault logo
	wc.hCursor = LoadCursor(NULL, IDC_ARROW);	//Load arrow pointer
	wc.hbrBackground = NULL;					//Don't need a background for GL
	wc.lpszMenuName = NULL;						//We don't want a menu
	wc.lpszClassName = GLname;					//Set class name

My problem is in setting the window procedure. It says it can't convert from 'over-loaded function' to WNDPROC. I was wondering what I can do to keep it in the class, or if I probably shouldn't. The idea is that each object created will have it's own render procedure. Thanks.

Share this post

Link to post
Share on other sites
RenderProc must be made static in order to keep it within the class. When called, it must be able to dermine which window the message was fired from.

Share this post

Link to post
Share on other sites
Yes, make it static. When it is static it has no implicit this pointer added by the compiler, so signatures should match.

class Renderer

RenderProc must then determine an instance of type Renderer to call functions upon it.

You can do this by having a singleton or a global object of type Renderer or by ...

There are many ways ;-)

Share this post

Link to post
Share on other sites
You can probably use the lParam to contain the pointer to an instance:

LRESULT Renderer::RenderProc(HWND hwnd, UINT uint, WPARAM wParam, LPARAM lParam)
Renderer* self = (Renderer*)lParam;

Just make sure that your callback function is called with a pointer to an instance of type Renderer.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!