Jump to content
  • Advertisement
Sign in to follow this  
Jossos

glViewport Makes no sense

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

34yntrm.jpg

 

Ok So the two viewports refuse to go fullscreen, for reasons I cannot comprehend.

 

Code:

void GAME::DrawToFBO(bool half, float CameraOffset)
{
	// DRAW TO FBO
	glBindFramebuffer(GL_FRAMEBUFFER, FBO);	// Modify only 'FBO' screen
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glEnable(GL_DEPTH_TEST);

	m_pipeline.LoadIdentity();

	// Init View
	m_pipeline.MatrixMode(VIEW_MATRIX);

	if (half)
		m_pipeline.Perspective(fov, ((float)g_graphicsManager->GetWidth()) / (float)g_graphicsManager->GetHeight(), 0.01f, 1000.0f);
	else
		m_pipeline.Perspective(fov, (float)g_graphicsManager->GetWidth() / (float)g_graphicsManager->GetHeight(), 0.01f, 1000.0f);
	m_pipeline.RotateX(-m_camera->GetRotX());
	m_pipeline.RotateY(m_camera->GetRotY());
	m_pipeline.Translate(-m_camera->GetPos().x, -m_camera->GetPos().y, -m_camera->GetPos().z);
	

	// Right
	m_pipeline.PushMatrix();
	glLoadIdentity();
	glViewport(0, 0, g_graphicsManager->GetWidth() / 2, g_graphicsManager->GetHeight());
	
	m_pipeline.Translate(-CameraOffset, 0.0f, 0.0f);
	RenderModels();
	m_pipeline.PopMatrix();

	// Left
	m_pipeline.PushMatrix();
	glLoadIdentity();
	glViewport(g_graphicsManager->GetWidth() / 2, 0, g_graphicsManager->GetWidth() / 2, g_graphicsManager->GetHeight());
	
	m_pipeline.Translate(CameraOffset, 0.0f, 0.0f);
	RenderModels();
	m_pipeline.PopMatrix();
}

I'm not even sure how glViewport works, and google refuses to give anything useful. I thought specifying the pixels would work, but apparently not? And I've fiddled with the values for ages. It makes absolutely no sense. It seems calling glViewport twice seems to scale them both down for some reason.

 

Any help is appreciated.

 

 

 

By the way I'm trying to make a little thing for the oculus rift. If anyone has useful resources, feel free to share, although I'm obviously not that far just yet, until I can fix this stupidity.

 

Thanks!

Share this post


Link to post
Share on other sites
Advertisement

What's happening is you are setting your glViewport the 2nd time, rendering to an FBO, and then doing whatever with the FBO to actually get it to the screen while your glViewport is still the right half of the screen. So the FBO gets dumped to just that area.

 

EDIT: add another glViewport for the entire screen before you draw the stereo FBO to the screen.

Edited by radioteeth

Share this post


Link to post
Share on other sites

OPh dude thanks a bunch, you are a smart guy. I'm so dumb thatnks a tonne!

Edited by Jossos

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!