Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Gandalf

OpenGL Creating a OpenGL texture from a resorce file

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

Wake up all GL Wizards! I still need help with creating a OpenGL texture from a bitmap loaded from resoure file.
                                            

void CreateResTextures()
{
    // bits needed to create a 256x256 24 bits bitmap

    const int iNrBits = 256*256*3;


    // Load bitmap from resource file

    HBITMAP bitmap = LoadBitmap(GetModuleHandle(NULL), 
        MAKEINTRESOURCE(IDB_BITMAP));


    // Allocate bitmap data

    unsigned char *data = new unsigned char[iNrBits];


    // Get bitmap data from handle

    GetBitmapBits(bitmap, iNrBits, data);


    // Create one texture

    glGenTextures(1, &m_texture[0]);


    // Bind name to texture

    glBindTexture(GL_TEXTURE_2D, m_texture[0]);

	
    // Generate the texture

    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 256, 256, 
		0, GL_RGB, GL_UNSIGNED_BYTE, data);


   delete data;
}

                        
The pixels in the image is not on correct positions. But I think that all the colors is correct. Only half texture shows up. Edited by - Gandalf on 6/20/00 7:05:28 AM Edited by - Gandalf on 6/20/00 7:06:28 AM Edited by - Gandalf on 6/20/00 7:06:54 AM

Share this post


Link to post
Share on other sites
Advertisement

  • 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!