Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 7 of 7

Thread: Using GL_GENERATE_MIPMAP_SGIS

  1. #1
    Intern Contributor
    Join Date
    Feb 2001
    Location
    Sydney, NSW, Australia
    Posts
    58

    Using GL_GENERATE_MIPMAP_SGIS

    I've attempted to use this however when I use it with glCopyTexImage2D I get no texture.

    That make sence as I've notice that glCopyTexImage2D gets no pointer to my data.

    How does this all work? Do I need to load the texture in first with glTexImage2D then call glCopyTexImage2D ?

    I've tried a few combinations but can't seem to work out how this is meant to be operated.

    Any clues?

    Chris

  2. #2

    Re: Using GL_GENERATE_MIPMAP_SGIS

    Im not sure about the correct way to do it, but when I used glCopyTexSubImage2D(), I had to do this:

    Initialization:
    glGenTextures()
    glBindTexture()
    glTexImage2D() with texture data all 0's, i.e. black.
    glTexParameteri() for whatever parameters you want, and set generate mipmaps to true

    Without the glTexImage2D, it didnt work.

  3. #3
    Advanced Member Frequent Contributor
    Join Date
    Oct 2000
    Location
    Belgium
    Posts
    857

    Re: Using GL_GENERATE_MIPMAP_SGIS

    The mipmaps should be regenerated every time you change the level 0 image -- regardless of how you modify it. Are you sure you enabled mipmap generation before calling glCopyTexImage2D()?

    -- Tom

  4. #4
    Junior Member Regular Contributor
    Join Date
    Oct 2001
    Location
    Holland
    Posts
    184

    Re: Using GL_GENERATE_MIPMAP_SGIS

    Originally posted by gimp:
    That make sence as I've notice that glCopyTexImage2D gets no pointer to my data.
    The framebuffer is the source for glCopyTexImage2D.
    To use a memory area as source, you have to use glTexImage2D.

    The ..SubImage commands only work to replace (a part of) the color information of an already created texture.

    Mipmaps should be generated when using GL_GENERATE_MIPMAP_SGIS whenever level zero of a texture is modified.

    Jean-Marc.

  5. #5
    Intern Contributor
    Join Date
    Feb 2001
    Location
    Sydney, NSW, Australia
    Posts
    58

    Re: Using GL_GENERATE_MIPMAP_SGIS

    This is my best attempt:

    Code :
    	unsigned int Index = 0;
    	glGenTextures(1, &Index);
    	glBindTexture(GL_TEXTURE_2D, Index);
     
    	if (m_HardwareGenerateMipmap == true)
    	{
    		glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
    		glTexImage2D(	GL_TEXTURE_2D, 
    						TEXTURE_LEVEL_0, 
    						GL_RGBA, 
    						a_Image.GetWidth(), 
    						a_Image.GetHeight(), 
    						NO_BORDER, 
    						GL_BGRA_EXT, 
    						GL_UNSIGNED_BYTE, 
    						a_Image.GetData());
     
    		glCopyTexImage2D(	GL_TEXTURE_2D,
    							TEXTURE_LEVEL_0,
    							GL_RGBA,
    							0,
    							0,
    							a_Image.GetWidth(), 
    							a_Image.GetHeight(), 
    							NO_BORDER);
    	}
    When this code is run glGetError() returns 0 but all my textured area are blank.

    However when I remove the glCopyTexImage2D code the textures are generated normally. However I suspect thats just because no mipmaps are being generated, not that I know how to check this either.

    This looks to be what you guys are suggesting, but it still doesn't work.

    I've followed up every link in google for 'GL_GENERATE_MIPMAP_SGIS' but haven't found any simple demo's\code that describe how this is meant to work...

    Many thanks,

    Chris

  6. #6
    Junior Member Regular Contributor
    Join Date
    Jan 2001
    Location
    Israel
    Posts
    159

    Re: Using GL_GENERATE_MIPMAP_SGIS

    Do you understand that glCopyTexImage2D take it's data fromt he frame buffer? if it's blank then the texture will be blank...

    What are you trying to do anyway? If you really try to copy your frame buffer into a texture, there is no sense in calling glTexImage2D with real data. Send it NULL instead.

  7. #7
    Senior Member OpenGL Pro
    Join Date
    Feb 2001
    Location
    Switzerland
    Posts
    1,840

    Re: Using GL_GENERATE_MIPMAP_SGIS

    if you use glCopyTexImage to create your texture, why creating it before with glTexImage as well? you just need ONE TIME A TexImage call per texture. ONE TIME. eighter glCopy or just gl. if you use gCopyTexImage, you need data in the screenbuffer (the one you defined to readout).
    http://davepermen.net - if i could stay true to my heart, i would feel totally free

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •