PDA

View Full Version : Cleanest way to start OpenGL 3.2 programming ?



somboon
01-26-2010, 08:01 PM
I currently use the latest version of GLEW to initialize OpenGL 3.2 functionality.
But since GLEW doesn't have any option to force CORE/FORWARD_COMPATIBILITY.
It really difficult to port my OpenGL 2.0 code and make sure that I didn't use any deprecated stuff.

Can some one suggest me on this ?

I also have another question.
Does Catalyst 9.12 support OpenGL 3.2 core profile ? , or it only support OpenGL 3.2 functionality in the form of extension only (not sure if I use correct term here)

My video card is ATI 4670 running on windows XP with catalyst 9.12

Ilian Dinev
01-26-2010, 08:20 PM
Maybe:
http://www.gamedev.net/community/forums/topic.asp?topic_id=557319
http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=266523&page=1

Or simply change glew's srccode to specify said context-options. Just specifying core/fwd profile will make GL return error on every deprecated functionality you try. (edit: actually by getting a 3.2 context and specifying no profile defaults to core-profile). The latest glew supports 3.2, to my knowledge

Alfonse Reinheart
01-26-2010, 08:59 PM
I currently use the latest version of GLEW to initialize OpenGL 3.2 functionality.

It has been a while since I used GLEW (pre-3.x), but I recall that you're expected to do your own context creation, right?

somboon
01-26-2010, 11:11 PM
Actually I manage to create a working GL3.2 context a few minute ago
(test with simple GLSL 1.5 shader).

for any one who want to try this after calling glewInit(); to initialize all the function(the latest version of GLEW already support all GL3.2 function).

call this code to create OpenGL 3.2 context



this->currentContext = wglGetCurrentContext();
this->currentDC = wglGetCurrentDC();

int attribs[] =
{
WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
WGL_CONTEXT_MINOR_VERSION_ARB, 2,
WGL_CONTEXT_FLAGS_ARB,WGL_CONTEXT_FORWARD_COMPATIB LE_BIT_ARB,
WGL_CONTEXT_PROFILE_MASK_ARB,WGL_CONTEXT_CORE_PROF ILE_BIT_ARB,
0
};

PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = NULL;
wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC) wglGetProcAddress("wglCreateContextAttribsARB");
HGLRC ogl3Context;
if(wglCreateContextAttribsARB != NULL)
{
MessageBox(NULL,"Found the goddamn function\n","noticed",MB_OK);
ogl3Context = wglCreateContextAttribsARB(this->currentDC,0, attribs);
}

wglMakeCurrent(NULL,NULL);
wglDeleteContext(this->currentContext);

this->currentContext = ogl3Context;

wglMakeCurrent(this->currentDC,this->currentContext);



currentContext and currentDC are declare as global/member to store current rendering context / HDC (I have to do this since I use GLFW)

The core profile work as expect , attemp to call deprecate function result in Invalid Operation error and GLSL compiler also refuse to compile GLSL 110/120 code.

The only thing still puzzle me is calling.

int major,minor;
glGetIntegerv(GL_MAJOR_VERSION, &major);
glGetIntegerv(GL_MINOR_VERSION, &minor);

return major = 3 , minor = 1 but the driver allow me to create GL3.2 context anyway.

May be this is a bug since Catalyst 9.12 suppose to be support GL3.2 ?