GRY-Online.pl --> Archiwum Forum

Problem z OpenGL na pelnym ekranie :(

05.08.2003
15:25
smile
[1]

masterofpain [ Centurion ]

Problem z OpenGL na pelnym ekranie :(

Mam problem z OpenGl'em na pelnym ekranie... robie programik i gdy uruchamiam go w oknie to wszystko jest ok ale gdy probuje 2 razy uruchomic go na pelnym ekranie to komp mi sie wiesza ma ktos pomysl co z tym zrobic???
Ponizej kod:

#define WIN32_LEAN_AND_MEAN

#include <windows.h>
#include<gl.h>
#include<glu.h>
#include<glaux.h>

float angle=0.0f;
HDC g_HDC;
bool fullScreen = TRUE;


void SetupPixelFormat(HDC hDC)

int nPixelFormat;

static 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,0,
16,
0,
0,
PFD_MAIN_PLANE,
0,
0,0,0›;

nPixelFormat = ChoosePixelFormat(hDC, &pfd);

SetPixelFormat(hDC, nPixelFormat, &pfd);




LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)

static HGLRC hRC;
static HDC hDC;
int width, height;

switch(message)

case WM_CREATE:

hDC=GetDC(hwnd);
SetupPixelFormat(hDC);
g_HDC = 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_CHAR:

switch (toupper(wParam))

case VK_ESCAPE:

// wstawia komunikat WM_QUIT do kolejki
PostQuitMessage(0);
return 0;



case WM_SIZE:
height = HIWORD(lParam);
width = LOWORD(lParam);

if (height==0)

height=1;


glViewport(0,0, width, height);
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, message, wParam, lParam));


int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)

WNDCLASSEX windowClass;
HWND hwnd;
MSG msg;
bool done;
DWORD dwExStyle;
DWORD dwStyle;

int bits= 32;
int height = 768;
int width = 1024;

windowClass.cbSize = sizeof(WNDCLASSEX);
windowClass.style = CS_HREDRAW | CS_VREDRAW;
windowClass.lpfnWndProc = WndProc;
windowClass.cbClsExtra = 0;
windowClass.cbWndExtra = 0;
windowClass.hInstance = hInstance;
windowClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
windowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
windowClass.hbrBackground = NULL;
windowClass.lpszMenuName = NULL;
windowClass.lpszClassName = "MojaKlasa";
windowClass.hIconSm = LoadIcon(NULL, IDI_WINLOGO);


if(!RegisterClassEx(&windowClass))

MessageBox(NULL, TEXT ("DUPA!!!"), NULL,MB_ICONERROR);
return 0 ;


DEVMODE devModeScreen;
memset(&devModeScreen,0,sizeof(devModeScreen));
devModeScreen.dmSize = sizeof(devModeScreen);
devModeScreen.dmPelsWidth = width;
devModeScreen.dmPelsHeight = height;
devModeScreen.dmBitsPerPel = bits;
devModeScreen.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;

if(ChangeDisplaySettings(&devModeScreen, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)

fullScreen = false;


if(fullScreen)

dwExStyle = WS_EX_APPWINDOW;
dwStyle = WS_POPUP;
ShowCursor(FALSE);

else

dwExStyle = NULL;
dwStyle = WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_SYSMENU | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;


RECT windowRect;
windowRect.top =(long)0;
windowRect.left = (long)0;
windowRect.bottom = (long)height;
windowRect.right = (long)width;

AdjustWindowRectEx(&windowRect, dwStyle, FALSE, dwExStyle);


hwnd = CreateWindowEx(NULL,
"MojaKlasa",
"Aplikacaj OPENGL",
dwStyle /*| WS_CLIPCHILDREN | WS_CLIPSIBLINGS*/,
0, 0,
windowRect.right - windowRect.left,
windowRect.bottom - windowRect.top,
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 + 50.1f;
if (angle>=360.0f)
angle=0.0f;
glTranslatef(0.0f,0.0f,-5.0f);
glRotatef(angle,angle,0.0f,1.0f);
glLineWidth(5.0);
glColor3f(1.0f,0.0f,0.0f);
glBegin(GL_LINES);
glVertex3f(0.0,0.0,0.0);
glVertex3f(1.0f,0.0f,0.0f);
// glVertex3f(1.0f,1.0f,0.0f);
glEnd();

SwapBuffers(g_HDC);


TranslateMessage(&msg);
DispatchMessage(&msg);


return msg.wParam;

05.08.2003
19:07
smile
[2]

masterofpain [ Centurion ]

Nikt nie wie co z tym zrobic :( ???

© 2000-2024 GRY-OnLine S.A.