RTT with working on ATI but not nVidia (OpenGL)

Started by
1 comment, last by rocklobster 10 years, 7 months ago

Hey guys,

Since the start of my hobby project, I've been using one PC for development which is using an ATI card. I've just tried to run my project on my friends computer and my laptop (both have nVidia cards) and nothing renders, the screen is the same colour as the glClear(...) with nothing showing.

I did some debugging with glGetError and I'm not getting any errors showing up. I removed my render target and just rendered my scene to the default framebuffer and then things started drawing (minus the post-processing). So this leads me to believe my framebuffer object is not created correctly for nVidia cards?


bool Graphics::CreateRenderTarget( RenderTarget* target )
	{
		GLuint fbo;
		glGenFramebuffers(1, &fbo);
		glBindFramebuffer(GL_FRAMEBUFFER, fbo);
		target->SetFrameBufferId(fbo);

		for (uint32 i = 0; i < target->GetNumSources(); i++)
		{
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

			GLuint tex;
			glActiveTexture(GL_TEXTURE0 + i);
			glGenTextures(1, &tex);
			glBindTexture(GL_TEXTURE_2D, tex);
			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB32F, target->GetWidth(), target->GetHeight(), 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
			glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, tex, 0);
			target->SetSourceId(i, tex);
		}

		if (target->UseDepth())
		{
			GLuint depth;
			glGenRenderbuffers(1, &depth);
			glBindRenderbuffer(GL_RENDERBUFFER, depth);
			glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, target->GetWidth(), target->GetHeight());
			target->SetDepthBufferId(depth);
			glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depth);
		}

		glDrawBuffers(target->GetNumSources(), target->GetDrawBuffers());

		if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
		{
			return false;
		}
		return true;
	}

Anything obviously incorrect? I can post more info If needed.

Advertisement


glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

This should be done after the texture was created and bound.This is a texture state so it needs an active texture to be applied to. ;)

Bingo! Thanks mate.

This topic is closed to new replies.

Advertisement