PDA

View Full Version : window resize, z buffer, viewport



borodadada
03-19-2015, 05:28 AM
Hello, i create window on winapi


CreateWindowEx(0, class_name, "test", WS_CHILD | WS_VISIBLE, 0, 0, x, y, main_window, NULL, (HINSTANCE)hInstance, NULL);

Settings


PIXELFORMATDESCRIPTOR pfd =
{
sizeof(PIXELFORMATDESCRIPTOR),
1,
PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, //Flags
PFD_TYPE_RGBA, //The kind of framebuffer. RGBA or palette.
32, //Colordepth of the framebuffer.
0, 0, 0, 0, 0, 0,
0,
0,
0,
0, 0, 0, 0,
16, //Number of bits for the depthbuffer
8, //Number of bits for the stencilbuffer
0, //Number of Aux buffers in the framebuffer.
PFD_MAIN_PLANE,
0,
0, 0, 0
};


Init opengl


glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);


draw quads on z buffer


glColor3f(1,0,0);
glBegin(GL_QUADS);
glVertex3d( -1,0, -0.8 );
glVertex3d( -1,1, -0.8 );
glVertex3d( 0,1, -0.8 );
glVertex3d( 0,0, -0.8 );
glEnd();

glColor3f(0,1,0);
glBegin(GL_QUADS);
glVertex3d( 0,0, -0.9 );
glVertex3d( 0,1, -0.9 );
glVertex3d( 1,1, -0.9 );
glVertex3d( 1,0, -0.9 );
glEnd();

glColor3f(0,0,1);
glBegin(GL_QUADS);
glVertex3d( 0-0.5,0, -0.7 );
glVertex3d( 0-0.5,1, -0.7 );
glVertex3d( 1-0.5,1, -0.7 );
glVertex3d( 1-0.5,0, -0.7 );
glEnd();



1 quad hidden per 2 quad

Resize


MoveWindow(child_window, 0, 0, x, y, FALSE);
glViewport(0, 0, x, y);


If i use This resize i have problem
Original
1669
Problem
1670

If i use resize


glViewport(0, 0, x, y);
MoveWindow(child_window, 0, 0, x, y, FALSE);


This problem out, but resize very slow, no cool and not properly.
If I do not use Z buffer, and use resize 1 method, all work!