RECT rect; // Holds Coordinates Of A Rectangle
GetClientRect(g_window->hWnd, &rect); // Get Window Dimensions
int window_width=rect.right-rect.left; // Calculate The Width (Right Side-Left Side)
int window_height=rect.bottom-rect.top; // Calculate The Height (Bottom-Top)
// Update Our Texture... This Is The Key To The Programs Speed... Much Faster Than Rebuilding The Texture Each Time
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, tex_data);
glClear (GL_COLOR_BUFFER_BIT); // Clear Screen
for (int loop=0; loop<4; loop++) // Loop To Draw Our 4 Views
{
glColor3ub(r[loop],g[loop],b[loop]); // Assign Color To Current View
if (loop==0)
{
// Set The Viewport To The Top Left. It Will Take Up Half The Screen Width And Height
glViewport (0, window_height/2, window_width/2, window_height/2);
glMatrixMode (GL_PROJECTION); // Select The Projection Matrix
glLoadIdentity (); // Reset The Projection Matrix
gluOrtho2D(0, window_width/2, window_height/2, 0);
}
if (loop==1)
{
// Set The Viewport To The Top Right. It Will Take Up Half The Screen Width And Height
glViewport (window_width/2, window_height/2, window_width/2, window_height/2);
glMatrixMode (GL_PROJECTION); // Select The Projection Matrix
glLoadIdentity (); // Reset The Projection Matrix
gluOrtho2D(0, window_width/2, window_height/2, 0);
}
if (loop==2)
{
// Set The Viewport To The Bottom Right. It Will Take Up Half The Screen Width And Height
glViewport (window_width/2, 0, window_width/2, window_height/2);
glMatrixMode (GL_PROJECTION); // Select The Projection Matrix
glLoadIdentity (); // Reset The Projection Matrix
gluOrtho2D(0, window_width/2, window_height/2, 0);
}
if (loop==3)
{
// Set The Viewport To The Bottom Left. It Will Take Up Half The Screen Width And Height
glViewport (0, 0, window_width/2, window_height/2);
glMatrixMode (GL_PROJECTION); // Select The Projection Matrix
glLoadIdentity (); // Reset The Projection Matrix
gluOrtho2D(0, window_width/2, window_height/2, 0);
}
glMatrixMode (GL_MODELVIEW); // Select The Modelview Matrix
glLoadIdentity (); // Reset The Modelview Matrix
glClear (GL_DEPTH_BUFFER_BIT); // Clear Depth Buffer
glBegin(GL_QUADS); // Begin Drawing A Single Quad
// We Fill The Entire 1/4 Section With A Single Textured Quad.
glTexCoord2f(1.0f, 0.0f); glVertex2i(window_width/2, 0 );
glTexCoord2f(0.0f, 0.0f); glVertex2i(0, 0 );
glTexCoord2f(0.0f, 1.0f); glVertex2i(0, window_height/2);
glTexCoord2f(1.0f, 1.0f); glVertex2i(window_width/2, window_height/2);
glEnd(); // Done Drawing The Textured Quad
}
viewports problem
trying to draw same thing to 4 viewports each with ortho proj. problem is only top left vp shows
gluOrtho2D(0, window_width/2, window_height/2, 0);
Are you sure the last two parameters are OK?
spec. says bottom,top
This may not be the issue but:
What do you copy with glTexSubImage2D? I think the viewport setting affects that too.
So you should post your whole renderer.
Are you sure the last two parameters are OK?
spec. says bottom,top
This may not be the issue but:
What do you copy with glTexSubImage2D? I think the viewport setting affects that too.
So you should post your whole renderer.
gluOrtho2D(0, window_width/2, window_height/2, 0);
Are you sure the last two parameters are OK?
//it shows ok in the top left, should show at top right as well then.
the glTexSubImage2D thing is tutorial leftover, rtt stuff I guess, haven't dealt with opengl that much
Are you sure the last two parameters are OK?
//it shows ok in the top left, should show at top right as well then.
the glTexSubImage2D thing is tutorial leftover, rtt stuff I guess, haven't dealt with opengl that much
Post your whole renderer.
We cannot guess, what's happening before glTexSubImage2D, because your code looks fine otherwise.
We cannot guess, what's happening before glTexSubImage2D, because your code looks fine otherwise.
It`s the nehe #42 tutorial, wasn`t able to find anything else on viewports on the net
Quote:
void Draw (void)
{
RECT rect;
GetClientRect(g_window->hWnd, &rect);
int window_width=rect.right-rect.left;
int window_height=rect.bottom-rect.top;
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, tex_data);
copying to texture means you have to copy something. That's it. You copy nothing nowhere, I don't know what are you expecting.
And as I told you, viewport setting affects copying to texture, so guess what's going to happen, if you set viewports only in the loop. Sorry, I'm not sure how it behaves, but it is sure, that things won't be as you want them to be.
And as I told you, viewport setting affects copying to texture, so guess what's going to happen, if you set viewports only in the loop. Sorry, I'm not sure how it behaves, but it is sure, that things won't be as you want them to be.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement