PDA

View Full Version : no gl constants visible in code::blocks



CarstenT
10-25-2013, 12:33 PM
Hi fellow-newbs
I've setup code::blocks and picked the opengl-project. It compiled and ran successfully at second attempt. Great!

The main.c does not use the code suggested in SuperBible_5. I managed to get

const char *verString = glGetString(GL_VERSION) ;
and
printf("verString: %s \n ", verString ) ;

working.
const char is a substitute for ubyte which the setup (MinGW, win7) did not recognize. But
GL_MAJOR_VERSION and GL_MINOR_VERSION is not recognized either.

As an aside: the version is 3.3 which I was going for.

int MajorVer, MinorVer;
glGetIntegerv(GL_MAJOR_VERSION, &MajorVer) ;
glGetIntegerv(GL_MINOR_VERSION, &MinorVer) ;

and the problem continues if I try (to ensure that I'll get the core-profile)

GLint attribs[] = {WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
WGL_CONTEXT_MINOR_VERSION_ARB, 3,
WGL_CONTEXT_POFILE_MASK_ARB, WGL_CONTEXT_CORE_POFILE_BIT_ARB,
WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_DEBUG_BIT,
0};
hRC = wglCreateContextAttribsARB(*hDC, 0, attribs);

First: Should I set wglCreateContextAttribsARB() atop my code as (a prototype) like:
void EnableOpenGL(HWND hwnd, HDC*, HGLRC*);

Second: Error-code from the compiler->
...
F:\Projekter\OpenGL_02\main.c|172|note: each undeclared identifier is reported only once for each function it appears in|
F:\Projekter\OpenGL_02\main.c|173|error: 'WGL_CONTEXT_MINOR_VERSION_ARB' undeclared (first use in this function)|
F:\Projekter\OpenGL_02\main.c|174|error: 'WGL_CONTEXT_POFILE_MASK_ARB' undeclared (first use in this function)|
F:\Projekter\OpenGL_02\main.c|174|error: 'WGL_CONTEXT_CORE_POFILE_BIT_ARB' undeclared (first use in this function)|
F:\Projekter\OpenGL_02\main.c|175|error: 'WGL_CONTEXT_FLAGS_ARB' undeclared (first use in this function)|
F:\Projekter\OpenGL_02\main.c|175|error: 'WGL_CONTEXT_DEBUG_BIT' undeclared (first use in this function)|
F:\Projekter\OpenGL_02\main.c|177|warning: implicit declaration of function 'wglCreateContextAttribsARB' [-Wimplicit-function-declaration]|
...

I would appreciate a comment

I added
#include <stdlib.h>
and it stopped whining about printf(). [or did something else do the trick?]

CarstenT
10-25-2013, 02:55 PM
ok,
I read further text where the code I use is following an initiation of Glew ... It makes sense why the constants and functions are missing then.

Cheers all