Jump to content
  • Advertisement
Sign in to follow this  
SteveDeFacto

glGenerateMipmap not working?

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

What I am doing is kinda complex. Basically I'm rendering to an off screen texture and I'm trying to render that texture to the screen. Now I've got that part working but I want to render this texture at a lower resolution to the screen. So I decided to generate and render the texture's mipmap but when I use tex2Dlod or tex2Dbias after calling glGenerateMipmap on the texture all I see is black on every leve except 0.

Here is the code I am using to generate the frame buffer and texture:



glGenFramebuffersEXT(1, &rendertarget->frameBuffer);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, rendertarget->frameBuffer);
glGenRenderbuffersEXT(1, &rendertarget->depthBuffer);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, rendertarget->depthBuffer);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, WindowRect.right - WindowRect.left, WindowRect.bottom - WindowRect.top);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, rendertarget->depthBuffer);
glGenTextures(1, &rendertarget->Texture);
glBindTexture(GL_TEXTURE_2D, rendertarget->Texture);
glTexParameteri( GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR );
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, WindowRect.right - WindowRect.left, WindowRect.bottom - WindowRect.top, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glGenerateMipmap(GL_TEXTURE_2D);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, rendertarget->Texture, 0);
GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
if(status != GL_FRAMEBUFFER_COMPLETE_EXT)
{
OutputDebugString( L"Unable to create frame buffer" );
}



Any idea what I'm doing wrong?

Share this post


Link to post
Share on other sites
Advertisement
The GL_GENERATE_MIPMAP parameter has been deprecated/removed; It might be causing a conflict. Do you get any glErrors after calling glTexparameter/glGenerateMipMap?

Share this post


Link to post
Share on other sites

The GL_GENERATE_MIPMAP parameter has been deprecated/removed; It might be causing a conflict. Do you get any glErrors after calling glTexparameter/glGenerateMipMap?


It is obvious he isn't using GL 3.X. Why do you people always talk about deprecation?
He is using the EXT version of FBO.

Also, this is invalid
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR );

Share this post


Link to post
Share on other sites

[quote name='johnchapman' timestamp='1312954650' post='4847046']
The GL_GENERATE_MIPMAP parameter has been deprecated/removed; It might be causing a conflict. Do you get any glErrors after calling glTexparameter/glGenerateMipMap?


It is obvious he isn't using GL 3.X. Why do you people always talk about deprecation?
He is using the EXT version of FBO.

Also, this is invalid
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR );

[/quote]

Okay okay :). BUT using implicit generation (GL_GENERATE_MIPMAP) and explicit generation (glGenerateMipmap()) is at best redundant.

But V-man is right; the problem is that you can't use mipmaps as texture mag filters :)

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!