Help!Multi-texturing in Lesson 10
Hi, can anyone tell me how to apply the multi-texturing in Lesson 10? For exmaple, different wall in different texture mapping that using VBopenGL.And my 3D world have 40 sector that constructed by triangle. What it mean by "bind the texture ID before renderer (i.e. us glBindTexture)"? .Here I provided neccessary coding for texture mapping in lesson 10. Hope anyone
can help me in showing coding.
Public Texture(3) As GLuint
Private Sub CreateTextureMapFromImage(pict As PictureBox, ByRef TextureImg() As GLbyte, ByRef Height As Long, ByRef Width As Long)
'' Create the array as needed for the image.
pict.ScaleMode = 3 '' Pixels
Height = pict.ScaleHeight
Width = pict.ScaleWidth
ReDim TextureImg(2, Height - 1, Width - 1)
Dim x As Long, y As Long
Dim c As Long
Dim yloc As Long
For x = 0 To Width - 1
For y = 0 To Height - 1
c = pict.Point(x, y) '' Returns in long format.
yloc = Height - y - 1
TextureImg(0, x, yloc) = c And 255
TextureImg(1, x, yloc) = (c And 65280) \ 256
TextureImg(2, x, yloc) = (c And 16711680) \ 65536
Next y
Next x
End Sub
______________________________________________
Private Function LoadGLTextures() As Boolean
'' Load Bitmaps And Convert To Textures
Dim Status As Boolean
Dim h As Long
Dim w As Long
Dim TextureImage() As GLbyte
Status = False '' Status Indicator
If LoadBMP("Data\Mud.BMP", TextureImage(), h, w) Then
Status = True '' Set The Status To TRUE
glGenTextures 3, Texture(0) '' Create The Textures
'' Create Nearest Filtered Texture
glBindTexture glTexture2D, Texture(0)
glTexParameteri glTexture2D, tpnTextureMagFilter, GL_NEAREST ''( NEW )
glTexParameteri glTexture2D, tpnTextureMinFilter, GL_NEAREST ''( NEW )
glTexImage2D glTexture2D, 0, 3, w, h, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage(0, 0, 0)
'' Create Linear Filtered Texture
glBindTexture glTexture2D, Texture(1)
glTexParameteri glTexture2D, tpnTextureMinFilter, GL_LINEAR '' Linear Filtering
glTexParameteri glTexture2D, tpnTextureMagFilter, GL_LINEAR '' Linear Filtering
glTexImage2D glTexture2D, 0, 3, w, h, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage(0, 0, 0)
'' Create MipMapped Texture
glBindTexture glTexture2D, Texture(2)
glTexParameteri glTexture2D, tpnTextureMagFilter, GL_LINEAR
glTexParameteri glTexture2D, tpnTextureMinFilter, GL_LINEAR_MIPMAP_NEAREST ''( NEW )
gluBuild2DMipmaps glTexture2D, 3, w, h, GL_RGB, GL_UNSIGNED_BYTE, VarPtr(TextureImage(0, 0, 0)) '' ( NEW )
End If
Erase TextureImage '' Free the texture image memory
LoadGLTextures = Status
End Function
cynique
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement