• Advertisement
Sign in to follow this  

Triangles not displayed correctly on fullscreen

This topic is 4683 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I use Visual C++ and OpenGL. I wrote a programm that draws triangles (with glBegin(GL_TRIANGLES) and glVertex3f(...)) on the screen. But for some reason this only works in windowed mode. When I toggle to fullscreen, the triangles appear as an ugly group of horizontal lines that flicker when you move the camera. Quads are displayed normally on fullscreen. Can anyone tell me what I'm doing wrong? Thank you for your help, Phex

Share this post


Link to post
Share on other sites
Advertisement
I think it's a problem with your z-buffer. Could you paste your pixelformatdescriptor and Projection setup? Don't forget to use the source-tags! [ (/)source ]

Share this post


Link to post
Share on other sites
Quote:
Original post by Pipo DeClown
I think it's a problem with your z-buffer. Could you paste your pixelformatdescriptor and Projection setup?

I am not totally sure if this is what you meant, but I hope so:

PIXELFORMATDESCRIPTOR pfd =
{
sizeof (PIXELFORMATDESCRIPTOR),
1,
PFD_DRAW_TO_WINDOW |
PFD_SUPPORT_OPENGL |
PFD_DOUBLEBUFFER,
PFD_TYPE_RGBA,
window->init.bitsPerPixel,
0, 0, 0, 0, 0, 0,
0,
0,
0,
0, 0, 0, 0,
16,
0,
0,
PFD_MAIN_PLANE,
0,
0, 0, 0
};


And

glViewport (0, 0, (GLsizei)(width), (GLsizei)(height));
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gluPerspective (45.0f, (GLfloat)(width)/(GLfloat)(height), 0.1f, 500.0f);


rgds,
Phex

Share this post


Link to post
Share on other sites
Quote:
Original post by nhatkthanh
Did you setup the DEVMODE when you switch to fullscreen?

Yes; or at least I hope I did it correctly. This is the relevant code:

BOOL ChangeScreenResolution (int width, int height, int bitsPerPixel)
{
DEVMODE dmScreenSettings;
ZeroMemory (&dmScreenSettings, sizeof (DEVMODE));
dmScreenSettings.dmSize = sizeof (DEVMODE);
dmScreenSettings.dmPelsWidth = width;
dmScreenSettings.dmPelsHeight = height;
dmScreenSettings.dmBitsPerPel = bitsPerPixel;
dmScreenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
if (ChangeDisplaySettings (&dmScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
return FALSE;
return TRUE;
}




Share this post


Link to post
Share on other sites
Is nobody able to help me? I would really appreciate a hint because I cant find any bug on my own...

Share this post


Link to post
Share on other sites
The Tutorial (34 in this case) works perfect (even when I insert my own drawing function).

Share this post


Link to post
Share on other sites
check for anything you are doing differently, especially anything involving z buffer precision like Pipo said, but also remembering that bad near/far values passed to gluPerspective could affect the z buffer.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement