Can i change the order of these OpenGL / Win32 calls?

Posted by Adam Naylor on Game Development See other posts from Game Development or by Adam Naylor
Published on 2011-02-25T09:53:30Z Indexed on 2011/02/25 15:33 UTC
Read the original article Hit count: 250

Filed under:
|

I've been adapting the NeHe ogl/win32 code to be more object orientated and I don't like the way some of the calls are structured.

The example has the following pseudo structure:

Register window class
Change display settings with a DEVMODE
Adjust window rect
Create window
Get DC
Find closest matching pixel format
Set the pixel format to closest match
Create rendering context
Make that context current
Show the window
Set it to foreground
Set it to having focus
Resize the GL scene
Init GL

The points in bold are what I want to move into a rendering class (the rest are what I see being pure win32 calls) but I'm not sure if I can call them after the win32 calls.
Essentially what I'm aiming for is to encapsulate the Win32 calls into a Platform::Initiate() type method and the rest into a sort of Renderer::Initiate() method.

So my question essentially boils down to: "Would OpenGL allow these methods to be called in this order?"

Register window class
Adjust window rect
Create window
Get DC
Show the window
Set it to foreground
Set it to having focus

Change display settings with a DEVMODE
Find closest matching pixel format
Set the pixel format to closest match
Create rendering context
Make that context current
Resize the GL scene
Init GL

(obviously passing through the appropriate window handles and device contexts.)

Thanks in advance.

© Game Development or respective owner

Related posts about opengl

Related posts about Windows