Problem with multiple glViewport calls

Started by
8 comments, last by liquidAir 20 years, 4 months ago
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
Advertisement
Are you clearing the window between the viewports? glClear is not bounded by the viewport, but by the scissor box (glScissor).
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
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.
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
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.
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!).
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
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
*bump*

"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
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 ^^
That Was Teh Evil ^^

This topic is closed to new replies.

Advertisement