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 6 of 6

Thread: Can't get rid of gluBuild2DMipmaps (solved)

  1. #1
    Junior Member Newbie Mr.Byteside's Avatar
    Join Date
    Mar 2010
    Location
    NL
    Posts
    26

    Can't get rid of gluBuild2DMipmaps (solved)

    I'm using gluBuild2DMipmaps simply because glTexImage2D does not want to work. I tried everything. I followed this: http://www.opengl.org/wiki/Common_Mistakes

    I have 24bpp .bmp in my windows form and load them this way:
    Code :
    GLuint texture[3];												// Storage For 3 Textures
     
    void LoadGLTextures()											// Creates Textures From Bitmaps In The Resource File
    {
    	HBITMAP hBMP;												// Handle Of The Bitmap
    	BITMAP	BMP;												// Bitmap Structure
     
    	// The ID Of The 3 Bitmap Images We Want To Load From The Resource File
    	byte	Texture[]={	IDB_FONT_NORMAL_1, IDB_FONT_LARGE_1 };
     
    	glGenTextures(sizeof(Texture), &texture[0]);				// Generate 3 Textures (sizeof(Texture)=3 ID's)
    	for (int loop=0; loop<sizeof(Texture); loop++)				// Loop Through All The ID's (Bitmap Images)
    	{
    		hBMP=(HBITMAP)LoadImage(GetModuleHandle(NULL),MAKEINTRESOURCE(Texture[loop]), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION);
    		if (hBMP)												// Does The Bitmap Exist?
    		{														// If So...
    			GetObject(hBMP,sizeof(BMP), &amp;BMP);					// Get The Object
    																// hBMP: Handle To Graphics Object
    																// sizeof(BMP): Size Of Buffer For Object Information
    																// Buffer For Object Information
    			glPixelStorei(GL_UNPACK_ALIGNMENT,4);				// Pixel Storage Mode (Word Alignment / 4 Bytes)
    			glBindTexture(GL_TEXTURE_2D, texture[loop]);		// Bind Our Texture
    			glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); 
    			glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
    			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
     
    			// Generate Mipmapped Texture (3 Bytes, Width, Height And Data From The BMP)
    			gluBuild2DMipmaps(GL_TEXTURE_2D, 3, BMP.bmWidth, BMP.bmHeight, GL_BGR, GL_UNSIGNED_BYTE, BMP.bmBits);
    			//glTexImage2D(GL_TEXTURE_2D,0,3,BMP.bmWidth,BMP.bmHeight,0,GL_BGR,GL_UNSIGNED_SHORT,BMP.bmBits);
     
    			DeleteObject(hBMP);									// Delete The Bitmap Object
    		}
    	}
    }

    Help?

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    2,891

    Re: Can't get rid of gluBuild2DMipmaps

    Quote Originally Posted by Mr.Byteside
    I'm using gluBuild2DMipmaps simply because glTexImage2D does not want to work.
    Nowadays, I believe it is preferrable to use glGenerateMipmapEXT(GL_TEXTURE_2D) instead to tell the driver/GPU to build MIPmaps.

    However, let's see how you were trying to populate the MIP levels of the texture via glTexImage2D. Then you won't even need the MIPmap gen.

  3. #3
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,655

    Re: Can't get rid of gluBuild2DMipmaps

    What do you mean "with does not want to work" exactly ?
    Why do you want to do without gluBuild2DMipmaps, if you can not find a way to replace it ?
    Did you check that bmWidth and bmHeight are within allowed bounds for your hardware ?
    Do you check if your hardware accept NPOT textures ?

    Read again the documentation about gluBuild2DMipmaps, to be sure to re-implement everything needed :
    http://www.opengl.org/sdk/docs/man/x...d2DMipmaps.xml

  4. #4
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,655

    Re: Can't get rid of gluBuild2DMipmaps

    [quote=Dark Photon]
    Quote Originally Posted by Mr.Byteside
    However, let's see how you were trying to populate the MIP levels of the texture via glTexImage2D. Then you won't even need the MIPmap gen.
    He does not need mipmap gen, as GL_NEAREST is already used for minification filter.

  5. #5
    Junior Member Newbie Mr.Byteside's Avatar
    Join Date
    Mar 2010
    Location
    NL
    Posts
    26

    Re: Can't get rid of gluBuild2DMipmaps

    see below

  6. #6
    Junior Member Newbie Mr.Byteside's Avatar
    Join Date
    Mar 2010
    Location
    NL
    Posts
    26

    Re: Can't get rid of gluBuild2DMipmaps

    Edit, I found it myself. It was this:

    glTexImage2D(GL_TEXTURE_2D,0,3,BMP.bmWidth,BMP.bmH eight,0,GL_BGR,GL_UNSIGNED_SHORT,BMP.bmBits);

    To:

    glTexImage2D(GL_TEXTURE_2D,0,3,BMP.bmWidth,BMP.bmH eight,0,GL_BGR,GL_UNSIGNED_BYTE,BMP.bmBits);

    Sorry, for all the trouble.

Posting Permissions

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