Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Am i doing this right? (OpenGL 3.0+ context)


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
5 replies to this topic

#1 Vortez   Crossbones+   -  Reputation: 2704

Like
0Likes
Like

Posted 11 May 2013 - 04:36 PM

Hi, i've been trying to add some code to my engine to create an opengl 3.1 context, to keep up to date with current technology. However, it's dosen't seem to do anything different... I though depreciated features where phased out in 3.1, and that you absolutely needed shaders to render anything, but all my old code still work and i can even render stuff without shaders. Is there a way to be sure the context i am creating is what i am trying to do?

 

For example, i added this pieces of code in my engine initialization procedure:

 

    if(!SetupPixelFormatDescriptor(hDC)){
	PostQuitMessage(0);
	return false;
    }

    #ifndef COMPILE_FOR_OPENGL_3_1_
        hRC = wglCreateContext(hDC);
        wglMakeCurrent(hDC, hRC);
    #else
        GLenum err = glewInit();
        HGLRC tempContext = wglCreateContext(hDC);
        wglMakeCurrent(hDC, tempContext);

	int attribs[] =
	{
        WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
        WGL_CONTEXT_MINOR_VERSION_ARB, 1,
        WGL_CONTEXT_FLAGS_ARB, 0,
        0};

	PFNWGLCREATECONTEXTATTRIBSARBPROC CreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB");
	
        hRC = CreateContextAttribsARB(hDC, 0, attribs);
	wglMakeCurrent(NULL,NULL);
	wglDeleteContext(tempContext);
	wglMakeCurrent(hDC, hRC);
    #endif

 

But for the reasons listed above, it dosen't seem to do much... I followed the new red book instruction (OpenGL Programming guide 7th edition).

 

Am i doing this right?


Edited by Vortez, 11 May 2013 - 04:37 PM.


Sponsor:

#2 Brother Bob   Moderators   -  Reputation: 8630

Like
1Likes
Like

Posted 11 May 2013 - 05:18 PM

The WGL_CONTEXT_FLAG_ARG option needs the WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB flag to produce a forward-compatible rendering context. Without the flag, you get a backward compatible context with all the old functions as well as the new ones.



#3 Vortez   Crossbones+   -  Reputation: 2704

Like
0Likes
Like

Posted 11 May 2013 - 05:30 PM

So, i would have to do

 

WGL_CONTEXT_FLAG_ARG | WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB

 

?

 

What's the point of using WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB if all it does is remove depreciated stuff?

 

And how something can be "foward compatible"?!? I mean, backward compatible make sense, but foward compatible sound like

"this is compatible with things that don't exist yet"!

 

i know what they mean, but it's weird...


Edited by Vortez, 11 May 2013 - 05:36 PM.


#4 Brother Bob   Moderators   -  Reputation: 8630

Like
3Likes
Like

Posted 11 May 2013 - 05:38 PM

So, i would have do

 

WGL_CONTEXT_FLAG_ARG | WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB

 

?

The bit goes into the value, not the option.

WGL_CONTEXT_FLAG_ARG, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB

 

What's the point of using WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB if all it does is remove depreciated stuff?

You asked how to get rid of the deprecated stuff, and that bit gets rid of the deprecated stuff. So the point of it should be obvious to you :)



#5 Vortez   Crossbones+   -  Reputation: 2704

Like
0Likes
Like

Posted 11 May 2013 - 05:48 PM

Ahh, i think i just got how the attriblist array work... so, aren't i am missing a 0 at the end of my example above?

 

For example, this code terminate it with 2 zeros. I mean, mine too... but isin't the parameters working in pair? Mine have an uneven number of elements, does it matter?

 

I can't find any good documentation on this wglCreateContextAttribsARB function that explain the arguments properly.


Edited by Vortez, 11 May 2013 - 05:55 PM.


#6 Brother Bob   Moderators   -  Reputation: 8630

Like
0Likes
Like

Posted 11 May 2013 - 05:59 PM

No, the specification says that the list of option/value pairs are terminated by a zero value, so one zero is enough.

 

However, I do terminate it with a double zero myself simply because I look at it as a list of option/value pairs, and the single terminating zero is only half a option/value pair. It is unnecessary, but I feels better to end it with a whole option/value pair since that is my view of it.


Edited by Brother Bob, 11 May 2013 - 06:00 PM.





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