• Advertisement
Sign in to follow this  

Compile Shaders/Load Extensions without setting up a window

This topic is 1586 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

I'm trying to write a simple windows app which goes a bunch of glsl shaders and compiles them. From searching online it seems this requires querying the glCreateShader etc extensions which require calling wglGetProcessAdress to get these extensions (I'm trying to target gl 3.3). I tried doing this but the call always fails (since I don't have a wglContext and further more a window setup).

 

Is there any way to get these extensions without creating a window ? I don't need to do any rendering at all (ever), just compile a bunch of shaders and check the output for errors.

 

From what I've found so far, I haven't seen a way of doing this without creating a window first ? is there any way to compile shaders offline or quick way to setup a dummy context without doing all the window setup ? Window setup seems a bit hacky just to require shader compilation.

 

Thanks!

Share this post


Link to post
Share on other sites
Advertisement
That is simply impossible. There could be a dozen different graphics cards plugged into a system, each with its own driver and each with its own individual return values for wglGetProcessAdress. Before you create the context there is no way for anyone to know which driver you want to talk to.

If you don't want to do any rendering you still need to create a window (you do not need to make it visible at any point though) and attach a context.

Share this post


Link to post
Share on other sites

Yeah, it makes sense to have a wglContext, I just don't see why it requires a window to be setup and was hoping there was a way to create a gl context without creating a window. Just like you can create a d3d11 device without creating a window and compile all your shaders using d3dcompile.

 

If I must create a dummy window, is it safe to delete the hWnd etc after getting the addresses for the extensions ? I know the context must stay alive but I'd like to clean up all the other window stuff if possible.

Share this post


Link to post
Share on other sites

I think SDL[2] might allow you to make a context without a window - not 100% sure, but the functions are separate so maybe

Edited by 3TATUK2

Share this post


Link to post
Share on other sites

In windows you do not need to create a window to get a device context (HDC). You can use anything, the desktop, a button, any type of windows GUI element (anything with its own HWND) can have GetDC(hwnd) called on it to retrieve a device context. Then you can use that to create a rendering context and use OpenGL calls.

 

From what I've gleaned from MSDN, this is due to Microsoft's choices in designing/implementing support for OpenGL, as the context functions aren't even a part of the OpenGL specification.

Share this post


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

  • Advertisement