Jump to content
  • Advertisement
Sign in to follow this  
davcaw

a little help

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

i am using OpenGL in an application i am making. I am using visual basic .net and am having a little bit of trouble becuase the NeHe tutorials are written in C++. The problem i am having is trying to load multiple textures. When i try and use a loop or somthing it overwrites the first texture and makes a blank second one. Here is the code i am using to load a single texture: Dim texture(50) as UInt32 Dim Image As Bitmap = New Bitmap("\myimage.bmp") Dim bitmapdata As System.Drawing.Imaging.BitmapData Dim rect As Rectangle = New Rectangle(0, 0, Image.Width, Image.Height) bitmapdata = Image.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadOnly, Drawing.Imaging.PixelFormat.Format24bppRgb) GL.glGenTextures(1, texture) GL.glBindTexture(Convert.ToUInt32(GLFlags.GL_TEXTURE_2D), texture(0)) GL.glTexImage2D(Convert.ToUInt32(GLFlags.GL_TEXTURE_2D), 0, Convert.ToInt32(GLFlags.GL_RGB8), _ Image.Width, Image.Height, 0, Convert.ToUInt32(32992), _ Convert.ToUInt32(GLFlags.GL_UNSIGNED_BYTE), bitmapdata.Scan0) GL.glTexParameteri(Convert.ToUInt32(GLFlags.GL_TEXTURE_2D), Convert.ToUInt32(GLFlags.GL_TEXTURE_MIN_FILTER), Convert.ToUInt32(9729)) GL.glTexParameteri(Convert.ToUInt32(GLFlags.GL_TEXTURE_2D), Convert.ToUInt32(GLFlags.GL_TEXTURE_MAG_FILTER), Convert.ToUInt32(9729)) Image.UnlockBits(bitmapdata) Image.Dispose()

Share this post


Link to post
Share on other sites
Advertisement
When you use glGenTextures you're constantly overwriting the first element of the Texture array. Replace it with
GL.glGenTextures(50, texture)
which will fill the array with texture id's that you can use.

You'll obviously have to bind to a different id when you load another texture, so

GL.glBindTexture(Convert.ToUInt32(GLFlags.GL_TEXTURE_2D), texture(1))

or something to load the second texture.

Share this post


Link to post
Share on other sites
thanks a lot, i have been looking for this in a lot of different vb forums, but most vb programmers use DirectX.

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!