Archived

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

Problem with multiple glViewport calls

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

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 on other sites
Are you clearing the window between the viewports? glClear is not bounded by the viewport, but by the scissor box (glScissor).

Share on other sites
Ok, I moved the glClear function away from the Render() code to be before the block of code as above, and that solves the problem of the viewports not showing. But now, the last viewport keeps blinking. Anyway I can solve this?

I good you bid evening.

InitGames Software | InitGames Software forums

Share on other sites
Need more details on what you''re actually doing in your code. The code itself (relevant parts only if it''s large) would be nice.

Share on other sites
I''ll post my code when my home connection gets restored. Btw, just in case you need to know, I''m using the wxWindows API.

I good you bid evening.

InitGames Software | InitGames Software forums

Share on other sites
I always set the frustum after calling glViewPort.
I''m not sure if this is needed. You might give it a try if all else fails.

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 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 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 ^^

1. 1
2. 2
JoeJ
20
3. 3
4. 4
frob
12
5. 5

• 13
• 19
• 13
• 20
• 13
• Forum Statistics

• Total Topics
632194
• Total Posts
3004694

×