I was hoping for an answer like, “Oh ya, I had that problem once!, I forgot to do ya-d-da and then it worked.”
Following is fragments of the VB program that relate to the processing of the textures. The whole program, even though simple, is too big to post entirely.
Global TextureMaps() As Long
’
'lots of public declarations removed for clarity,
'------------------------------------------------------------------------------------------------------------
Public Sub Form_Load()
'initialize stuff
.
.stuff remove, hopefully for clarity
.
.
.
SetupPixelFormat Mainfm.hdc
hGLRC = wglCreateContext(Mainfm.hdc)
wglMakeCurrent Mainfm.hdc, hGLRC
glClearColor 0.6, 0.6, 0.6, 1#
glViewport 0, 0, Mainfm.ScaleWidth, Mainfm.ScaleHeight
glEnable GL_TEXTURE_2D
glEnable GL_DEPTH_TEST
glDepthFunc GL_LEQUAL
glShadeModel GL_SMOOTH 'or GL_FLAT
glCullFace GL_BACK
glEnable GL_CULL_FACE
glHint GL_PERSPECTIVE_CORRECTION_HINT, GL_FLAT
glMatrixMode GL_PROJECTION
gluPerspective FOV, AspectRatio, dNear, dFar
glMatrixMode GL_MODELVIEW
.
.
.
.
End Sub
'------------------------------------------------------------------------------------------------------------
Public Sub Form_Paint()
glClear GL_COLOR_BUFFER_BIT Or GL_DEPTH_BUFFER_BIT
glPushMatrix
glRotatef Elevation, 1, 0, 0
glRotatef Azimuth, 0, 1, 0
glTranslatef xPos, yPos, zPos
Call DrawWorld
glPopMatrix
SwapBuffers Mainfm.hdc
End Sub
'--------------------------------------------------------------------------------------------------------------
Sub DrawWorld()
Dim i,j as Integer
glEnable GL_TEXTURE_2D
Call glBegin(GL_TRIANGLES)
For j = 1 To nObj
glBindTexture GL_TEXTURE_2D, TextureMaps(j - 1) 'yes I know, I’m mixing zero base and one base
For i = 1 To nFaces(j)
Call glTexCoord2f(TVerts(j, TFaces(j, i, 1), 1), TVerts(j, TFaces(j, i, 1), 2))
Call glVertex3f(Verts(j, Faces(j, i, 1), 1), Verts(j, Faces(j, i, 1), 2), Verts(j, Faces(j, i, 1), 3)) 'vertex 1
Call glTexCoord2f(TVerts(j, TFaces(j, i, 2), 1), TVerts(j, TFaces(j, i, 2), 2))
Call glVertex3f(Verts(j, Faces(j, i, 2), 1), Verts(j, Faces(j, i, 2), 2), Verts(j, Faces(j, i, 2), 3)) 'vertex 2
Call glTexCoord2f(TVerts(j, TFaces(j, i, 3), 1), TVerts(j, TFaces(j, i, 3), 2))
Call glVertex3f(Verts(j, Faces(j, i, 3), 1), Verts(j, Faces(j, i, 3), 2), Verts(j, Faces(j, i, 3), 3)) 'vertex 3
Next i
Next j
Call glEnd
End Sub
'-------------------------------------------------------------------------------------------------------------
'call from menu seletion to open project
Sub OpenProject()
.
.Dim, file open and data read statements removed
.nTextures are counted as data is read
.TextureNames are checked for validity
.
'set up space for textures
ReDim TextureMaps(nTextures)
Call glGenTextures(nTextures, TextureMaps(0))
For i = 0 To nTextures - 1
ProcessTextures i, (App.Path & “” & Trim(TextureName(i + 1)))
Next i
End Sub
'-----------------------------------------------------------------------------------------------------------
Sub ProcessTextures(num, Filename)
.
.
. code to read bitmap texture images remove for clarity
.
.
Get 1, , FileInfo
Get 1, , ByteInfo
.
.
. more code to check for valid image removed for clarity
.
.
'Determine how big the image is
iPixelSize = ByteInfo.biBitCount / 8
lImageSize = ByteInfo.biWidth * ByteInfo.biHeight * iPixelSize
ReDim BitMapImage(0 To lImageSize) As Byte
'Read in the image data
Get #1, , BitMapImage
Close #1 'no longer need file data
glBindTexture GL_TEXTURE_2D, TextureMaps(num)
glTexParameteri GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR
glTexParameteri GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR
glTexImage2D GL_TEXTURE_2D, 0, GL_RGB, ByteInfo.biWidth , ByteInfo.biHeight , _
0, GL_RGB, GL_UNSIGNED_BYTE, BitMapImage(0)
Erase BitMapImage
End Sub