I receive this error during building in this function, is it normal?
void SetDCPixelFormat(HDC hDC)
{
PIXELFORMATDESCRIPTOR pfd;
int nPixelFormat;
pfd = { /ERROR IS HERE
sizeof(PIXELFORMATDESCRIPTOR),
1,
PFD_DRAW_TO_WINDOW |
PFD_SUPPORT_OPENGL |
PFD_DOUBLEBUFFER |
PFD_TYPE_RGBA,
32,
0, 0, 0, 0, 0, 0,
0, 0,
0, 0, 0, 0,
16,
0,
0,
0,
0,
0,0,0 };
nPixelFormat = ChoosePixelFormat(hDC, &pfd);
SetPixelFormat(hDC, nPixelFormat, &pfd);
}
error: expected primary-expression before '{' token
error: expected ';' before '{' token.
I think the code is ok, do you see any error??
The error is very likely in a header file included before that.
The initialization by { } can be done only when you declare your variable:
PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR),
1,
PFD_DRAW_TO_WINDOW |
PFD_SUPPORT_OPENGL |
PFD_DOUBLEBUFFER |
PFD_TYPE_RGBA,
32,
0, 0, 0, 0, 0, 0,
0, 0,
0, 0, 0, 0,
16,
0,
0,
0,
0,
0,0,0 };
God, thanks kkez, it solved the problem, I didn't know that.
Many thanks.
Errr, just another question...
I receive undefined references in the same code above regarding "SetPixelFormat" and "ChoosePixelFormat" calls.
I've added:
#include <windows.h>
#include <GL/gl.h>
#include <GL/glu.h>
and glu32 and opengl32 to the linker's options, do I need any lib more to get this working??. Am I missing something??
As you can see here (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/opengl/ntopnglr_3q5w.asp) and here (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/opengl/ntopnglr_2qb8.asp), you need to include windows.h and link to gdi32.lib (libgdi32.a).
Thanks, problem solved. I'm just too much used to MSVC ;)
Uh, i read too rapidly, you need to include wingdi.h :)