Archived

This topic is now archived and is closed to further replies.

Problem with multiple glViewport calls

This topic is 5120 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

I''m having a problem with making multiple calls to glViewport. What I want to do is to divide the screen into 4 different views, and then render the scene differently in each view.\ My code is something like... // topleft // glViewport call // set projection matrix // render // bottomleft - same // bottomright - same The problem I''m having is that it first renders the topleft, covers it with black, then the bottomleft, which then gets covered after bottomright is rendered. Why is this so? And what can I do to solve this? I good you bid evening. InitGames Software | InitGames Software forums

Share this post


Link to post
Share on other sites
Wow, what are the odds - I am working with the exact same thing right now!

I believe you need to make a seperate wxGLContext for each render target - the 4 windows.

The wxGLCanvas isn''t a complete class (it doesn''t even do anything in OnSize!).

Share this post


Link to post
Share on other sites
Here''s the code

void COGLCanvas::OnPaint(wxPaintEvent &event)
{
wxPaintDC dc(this);

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

int w, h;
GetClientSize(&w, &h);

// bottom left

glViewport(0, 0, ((GLint)w)/2, ((GLint)h)/2);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0, ((GLfloat)w/(GLfloat)h)/2, 0.1, 2000.0);
Render();

// top left

glViewport(0, ((GLint)h)/2, (GLint)w/2, (GLint)h/2);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0, (GLfloat)w/(GLfloat)h/2, 0.1, 2000.0);
Render();
//SwapBuffers();


// bottom right

glViewport(0+((GLint)w)/2, 0, ((GLint)w)/2, ((GLint)h)/2);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0, (GLfloat)w/(GLfloat)h, 0.1, 2000.0);
Render();
}


"Never met an American that didn''t like guns."
"Santa Claus would pick up a gun to save his friend."

InitGames Software | InitGames Software forums

Share this post


Link to post
Share on other sites
Hmmn, The blinking could be because you might be swaping the buffers in the render functions as I don''t see you swaping in what you''ve posted...



That Was Teh Evil ^^

Share this post


Link to post
Share on other sites