Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Compile Shaders/Load Extensions without setting up a window


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 ~0ul   Members   -  Reputation: 656

Like
0Likes
Like

Posted 17 September 2013 - 12:48 AM

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!



Sponsor:

#2 BitMaster   Crossbones+   -  Reputation: 4228

Like
1Likes
Like

Posted 17 September 2013 - 01:14 AM

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.

#3 ~0ul   Members   -  Reputation: 656

Like
0Likes
Like

Posted 17 September 2013 - 01:23 AM

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.



#4 3TATUK2   Members   -  Reputation: 730

Like
0Likes
Like

Posted 17 September 2013 - 07:49 AM

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, 17 September 2013 - 07:49 AM.


#5 radioteeth   Prime Members   -  Reputation: 1103

Like
0Likes
Like

Posted 17 September 2013 - 11:57 AM

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.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS