Sign in to follow this  
SteveDeFacto

glGenerateMipmap not working?

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:


[code]
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" );
}[/code]


Any idea what I'm doing wrong?

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?

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?
[/quote]

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='V-man' timestamp='1312967754' post='4847087']
[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?
[/quote]

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) [i]and [/i]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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this