i tried with
GLUT and GL_texture_rectangle but still the same problem
Code: Select all
EnableExplicit
;********************************************************************
;- OPENGL INCLUDES
;********************************************************************
IncludeFile "include/gl.pbi" ; GL constants up to OpenGL 1.1
IncludeFile "include/glext.pbi" ; GL constants up to OpenGL 4.1
IncludeFile "include/wglext.pbi" ; GL constants for Windows-only extensions
IncludeFile "include/glimp.pbi" ; GL imports
IncludeFile "include/glut.pbi" ; GLUT
;IncludeFile "include/glew.pbi" ; GLEW
Global Dim Texture.i(1)
Global TexureExt.i
Procedure LoadBitmapTexture(TextureNum.i, Filename.s, Filter.i)
Define.i img = LoadImage(0, Filename)
Define.BITMAP bmp
GetObject_(img,SizeOf(BITMAP),bmp)
; Debug "[ bmp ]"
; Debug "bmBits: " + Str( bmp\bmBits )
; Debug "bmBitsPixel: " + Str( bmp\bmBitsPixel )
; Debug "bmHeigh: " + Str( bmp\bmHeight )
; Debug "bmPlanes: " + Str( bmp\bmPlanes )
; Debug "bmType: " + Str( bmp\bmType )
; Debug "bmWidth: " + Str( bmp\bmWidth )
; Debug "bmWidthBytes: "+ Str( bmp\bmWidthBytes )
Debug "texture extension: " +Hex( TexureExt )
glBindTexture(TexureExt, TextureNum)
glTexParameteri(TexureExt, #GL_TEXTURE_WRAP_S, #GL_REPEAT)
glTexParameteri(TexureExt, #GL_TEXTURE_WRAP_T, #GL_REPEAT)
Select Filter
Case #GL_NEAREST
glTexParameteri(TexureExt, #GL_TEXTURE_MAG_FILTER, #GL_NEAREST)
glTexParameteri(TexureExt, #GL_TEXTURE_MIN_FILTER, #GL_NEAREST)
Debug "Mode: #GL_NEAREST"
Case #GL_LINEAR
glTexParameteri(TexureExt, #GL_TEXTURE_MAG_FILTER, #GL_LINEAR)
glTexParameteri(TexureExt, #GL_TEXTURE_MIN_FILTER, #GL_LINEAR)
Debug "Mode: #GL_LINEAR"
EndSelect
glTexImage2D(TexureExt, 0, 3, bmp\bmWidth, bmp\bmHeight, 0, #GL_BGR_EXT, #GL_UNSIGNED_BYTE, bmp\bmBits)
DeleteObject_(bmp)
FreeImage(0)
EndProcedure
Procedure Draw()
Static.f angler = 0.0
glClearScreen(1.0,0.66,0.0)
glBindTexture(TexureExt, 1)
glMatrixMode(#GL_MODELVIEW)
glLoadIdentity()
glPushMatrix()
glTranslatef(0.0,0.0,-10.0)
glRotatef(angler,1.0,1.0,1.0)
glutWireCube (1.0)
glPopMatrix()
glPushMatrix()
glTranslatef(-2.0,2.0,-10.0)
glRotatef(angler,1.0,1.0,1.0)
glutSolidCube(1.0)
glPopMatrix()
glPushMatrix()
glTranslatef(2.0,-2.0,-10.0)
glRotatef(angler,1.0,1.0,1.0)
glutSolidTeapot ( 1.0 )
glPopMatrix()
angler+0.01
glutSwapBuffers()
EndProcedure
Procedure Idle()
glutPostRedisplay()
EndProcedure
Procedure Resize(Width.i, Height.i)
glViewport(0, 0, Width, Height)
glMatrixMode(#GL_PROJECTION)
glLoadIdentity()
gluPerspective(45.0, Width/Height, 0.1, 100.0)
EndProcedure
Procedure Initialize()
Define.i argc = 0
Dim argv.s(0) : argv(0) = ""
glutInit(@argc, @argv())
glutInitWindowSize(800, 600);
glutInitWindowPosition(300, 300);
glutInitDisplayMode(#GLUT_RGB | #GLUT_DEPTH | #GLUT_DOUBLE)
glutCreateWindow("PureBasic GLUT")
;Debug glGetString(#GL_EXTENSIONS)
glEnable(#GL_DEPTH_TEST)
glMatrixMode(#GL_PROJECTION);
glLoadIdentity()
gluPerspective(45.0,800/600,0.1,100.0)
If( glutExtensionSupported("GL_ARB_texture_rectangle") )
TexureExt=#GL_TEXTURE_RECTANGLE
Else
TexureExt=#GL_TEXTURE_2D
EndIf
glEnable(TexureExt)
glGenTextures( 1, @texture() )
LoadBitmapTexture(texture(0), "res\NeHe.bmp", #GL_NEAREST)
glutDisplayFunc(@Draw())
glutReshapeFunc(@Resize())
glutIdleFunc(@Idle())
EndProcedure
Initialize()
glutMainLoop()
As you can see, when i initialize
glut i check if GL_ARB_texture_rectangle is supported
Code: Select all
If( glutExtensionSupported("GL_ARB_texture_rectangle") )
TexureExt=#GL_TEXTURE_RECTANGLE
Else
TexureExt=#GL_TEXTURE_2D
EndIf
glEnable(TexureExt)
with GL_TEXTURE_RECTANGLE
with GL_TEXTURE_2D
edit : nevermind, GL_TEXTURE_RECTANGLE is not more used because of the the extension ARB_texture_non_power_of_two