Jump to content

View more

Image of the Day

Boxes as reward for our ranking mode. ヾ(☆▽☆)
#indiedev #gamedev #gameart #screenshotsaturday https://t.co/ALF1InmM7K
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Fullscreen OpenGL

4: Adsense

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

#1 Drakon   Members   

120
Like
Likes
Like

Posted 18 October 2001 - 11:01 AM

I''ve been reading the OpenGL Game Programming book... But I can''t get fullscreen to work. It gives me these bugs: Compiling... OpenGLsrc.cpp E:\BeginOGLWork\OpenGLsrc.cpp(19) : error C2065: ''screenWidth'' : undeclared identifier E:\BeginOGLWork\OpenGLsrc.cpp(20) : error C2065: ''screenHeight'' : undeclared identifier E:\BeginOGLWork\OpenGLsrc.cpp(21) : error C2065: ''screenBpp'' : undeclared identifier E:\BeginOGLWork\OpenGLsrc.cpp(28) : error C2065: ''extendedWindowStyle'' : undeclared identifier E:\BeginOGLWork\OpenGLsrc.cpp(29) : error C2065: ''windowStyle'' : undeclared identifier E:\BeginOGLWork\OpenGLsrc.cpp(53) : error C2065: ''SetupPixelFormat'' : undeclared identifier E:\BeginOGLWork\OpenGLsrc.cpp(130) : warning C4551: function call missing argument list Error executing cl.exe. OpenGLsrc.obj - 6 error(s), 1 warning(s) Here is the code: NOTE: THE FULLSCREEN STUFF IS BETWEEN THE //''s. #include #include #include #include HDC g_hDC; float angle = 0.0f; bool fullScreen = TRUE; LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam){ static HGLRC hRC; static HDC hDC; int width; int height; // DEVMODE devModeScreen; memset(&devModeScreen, 0, sizeof(devModeScreen)); devModeScreen.dmSize = sizeof(devModeScreen); devModeScreen.dmPelsWidth = screenWidth; devModeScreen.dmPelsHeight = screenHeight; devModeScreen.dmBitsPerPel = screenBpp; devModeScreen.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL; if(ChangeDisplaySettings(&devModeScreen, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) fullScreen = false; if(fullScreen){ extendedWindowStyle = WS_EX_APPWINDOW; windowStyle = WS_POPUP; ShowCursor(FALSE); } else { extendedWindowStyle = NULL; windowStyle = WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_SYSMENU | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; RECT windowRect; windowRect.top = 0; windowRect.left = 0; windowRect.bottom = screenHeight; windowRect.right = screenWidth; AdjustWindowRectEx(&windowRect, windowStyle, FALSE, extendedWindowStyle); } // PAINTSTRUCT ps; switch(msg){ case WM_CREATE: hDC = GetDC(hwnd); g_hDC = hDC; SetupPixelFormat(hDC); hRC = wglCreateContext(hDC); wglMakeCurrent(hDC, hRC); return 0; break; case WM_CLOSE: wglMakeCurrent(hDC, NULL); wglDeleteContext(hRC); PostQuitMessage(0); return 0; break; case WM_SIZE: height = HIWORD(lparam); width = LOWORD(lparam); if(height==0){ height = 1; } glViewport(0,0,height,width); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,1.0f,1000.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); return 0; break; default: break; } return DefWindowProc(hwnd, msg, wparam, lparam); } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd){ WNDCLASSEX wc; HWND hwnd; bool done; MSG msg; wc.cbClsExtra = 0; wc.cbSize = sizeof(WNDCLASSEX); wc.cbWndExtra = 0; wc.hbrBackground = NULL; wc.hCursor = LoadCursor(NULL, IDC_CROSS); wc.hIcon = LoadIcon(NULL, NULL); wc.hIconSm = LoadIcon(NULL, NULL); wc.hInstance = hInstance; wc.lpfnWndProc = WndProc; wc.lpszClassName = "WCClass"; wc.lpszMenuName = NULL; wc.style = CS_HREDRAW | CS_VREDRAW; if(!RegisterClassEx(&wc)){ return 0; } hwnd = CreateWindowEx(NULL, "WCClass", "Beginning OpenGL review", WS_VISIBLE | WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_SYSMENU, 0, 0, 400, 400, NULL, NULL, hInstance, NULL); if (!hwnd) return 0; ShowWindow(hwnd, SW_SHOW); UpdateWindow(hwnd); done = false; while(!done){ PeekMessage(&msg, hwnd, NULL, NULL, PM_REMOVE); if(msg.message == WM_QUIT){ done = true; } else { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity; angle = angle + 0.1f; if(angle >= 1.0f) angle = 0.0f; glTranslatef(0.0f,0.0f,-5.0f); glRotatef(angle, 2.0f,2.0f,2.0f); glColor3f(0.0f,1.0f,1.0f); glBegin(GL_TRIANGLES); glVertex3f(0.0f,0.0f,0.0f); glVertex3f(2.0f,0.0f,0.0f); glVertex3f(2.0f,2.0f,0.0f); glEnd(); SwapBuffers(g_hDC); TranslateMessage(&msg); DispatchMessage(&msg); } } return msg.wParam; } It worked fine without the fullscreen code in. If anyone knows what is wrong, please reply

#2 Anonymous Poster_Anonymous Poster_*   Guests   

Likes

Posted 18 October 2001 - 11:09 AM

You never declared screenWidth. Use GetSystemMetrics() to get the screen width.

#3 Drakon   Members   

120
Like
Likes
Like

Posted 18 October 2001 - 11:21 AM

Uhh. What goes in the ()''s of GetSystemMetrics? And, where does it(the systemMetrics stuff) go?

#4 Spider_In_A_Web   Members   

122
Like
Likes
Like

Posted 18 October 2001 - 11:10 PM

the following two will give you screen height and width!!

place them just after the first // i guess!!

UINT windowStyle;
DWORD extendedWindowStyle;
int screenWidth = GetSystemMetrics(SM_CXSCREEN);
int screenHeight = GetSystemMetrics(SM_CYSCREEN);
int screenBpp = 16; //or any bits per pixel value you prefer

that will clear the first 5 errors, the problem is simply that you are not declaring your variables!!!

As for the last error, that involves looking properly and i dont have time, sorry!!






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.