Page 1 of 1

OpenGL & Textures

Posted: Tue Apr 20, 2010 1:00 pm
by Foz
This is a weird one :D

The textures just aren't loading. Everything *appears* to be working (no error reported, all the values are getting the correct values, etc). In fact, on my Netbook, which has an Intel chipset, it IS working as I expected it to. When I go to my NVidia machine, the textures just don't load and I get a white square, or on my works ATI machine... the square disappears.

Everything is reporting as just fine, but it just isn't. I've added in a "CreateImage" so you can see what the texture is that is being generated - just adjust the OUTPUT_TEXTURE_FILENAME$ to your requirements.

Just disable the GenerateTexture() and you will see the white square, enable it and... well, I don't know what is happening!

Help!

*** edit : I love Fred.

Code: Select all

#OUTPUT_TEXTURE_FILENAME$ = "output check.bmp"

Global WallTexture

;{--- OpenGL Setup
CompilerIf Subsystem("OpenGL")
CompilerElse
  MessageRequester("ERROR", "Set the subsystem To OpenGL")
  End
CompilerEndIf

; pb workaround fix
Import ""
  PB_Screen_Target
EndImport
#GL_TEXTURE_RECTANGLE_ARB        =  $84F5
;----------------------------
#GL_BLEND = $0BE2
#GL_COLOR_BUFFER_BIT = $00004000
#GL_DEPTH_BUFFER_BIT = $00000100
#GL_DEPTH_TEST = $0B71
#GL_LEQUAL = $0203
#GL_LINEAR = $2601
#GL_LINEAR_MIPMAP_NEAREST = $2701
#GL_LUMINANCE = $1909
#GL_MODELVIEW = $1700
#GL_MODULATE = $2100
#GL_NICEST = $1102
#GL_PERSPECTIVE_CORRECTION_HINT = $0C50
#GL_PROJECTION = $1701
#GL_QUADS = $0007
#GL_SMOOTH = $1D01
#GL_TEXTURE_2D = $0DE1
#GL_TEXTURE_ENV = $2300
#GL_TEXTURE_ENV_MODE = $2200
#GL_TEXTURE_MAG_FILTER = $2800
#GL_TEXTURE_MIN_FILTER = $2801
#GL_TEXTURE_WRAP_S = $2802
#GL_TEXTURE_WRAP_T = $2803
#GL_TRUE = 1
#GL_UNSIGNED_BYTE = $1401

#GL_SRC_ALPHA = $0302
#GL_ONE = 1
#GL_UNPACK_ALIGNMENT = $0CF5

CompilerIf #PB_Compiler_OS = #PB_OS_Linux
ImportC "/usr/lib/libX11.a"+Chr('"')+" -l"+Chr('"')+"GL"
CompilerElse
Import "Opengl32.lib"
CompilerEndIf
   glBegin(a.l)
   glBindTexture(a.l,b.l)
   glClear(a.l)
   glClearColor(a.f,b.f,c.f,d.f)
   glClearDepth(a.d)
   glDepthFunc(a.l)
   glDepthMask(a.c)
   glDisable(a.l)
   glEnable(a.l)
   glEnd()
   glGenTextures(a.l,b.l)
   glGetError()
   glHint(a.l,b.l)
   glLoadIdentity()
   glMatrixMode(a.l)
   glShadeModel(a.l)
   glTexCoord2f(a.f,b.f)
   glTexEnvf(a.l,b.l,c.f)
   glTexParameterf(a.l,b.l,c.f)
   glTranslatef(a.f,b.f,c.f)
   glVertex3f(a.f,b.f,c.f)
   glViewport(a.l,b.l,c.l,d.l)
   
     glBlendFunc(a.l,b.l) ; As "glBlendFunc@8"
   glPixelStorei(a.l,b.l) ; As "glPixelStorei@8"
 
EndImport

CompilerIf #PB_Compiler_OS = #PB_OS_Linux
ImportC "/usr/lib/libGLU.a"
CompilerElse
Import "Glu32.lib"
CompilerEndIf
   gluBuild2DMipmaps(a.l,b.l,c.l,d.l,e.l,f.l,g.l)
   gluErrorString(a.l)
   gluPerspective(a.d,b.d,c.d,d.d)
EndImport
;}

Procedure Noise(x, y)
  Static salt = 0
  salt = salt ! x & y
  ProcedureReturn salt
EndProcedure

Procedure.i GenerateTexture(pWidth.i, pHeight.i)
  Protected img = CreateImage(#PB_Any, pWidth, pHeight, 32)
  Protected *mem = AllocateMemory(pWidth * pHeight)
  If Not *mem : ProcedureReturn 0 : EndIf

  StartDrawing(ImageOutput(img))
  Protected *buffer.Ascii = *mem

  For y = 0 To pHeight-1
    For x = 0 To pWidth-1
      n = Noise(x, y) * 4
      If n < 0   : n = 0   : EndIf
      If n > 255 : n = 255 : EndIf
      Plot(x, y, RGBA(n, n, n, 255))
      *buffer\a = n
      *buffer + 1
    Next
  Next

  StopDrawing()
  SaveImage(img, #OUTPUT_TEXTURE_FILENAME$)

  Protected TexID = 0
  glGenTextures(1, @TexID)
  glBindTexture(#GL_TEXTURE_2D, TexID)

  glTexEnvf(#GL_TEXTURE_ENV, #GL_TEXTURE_ENV_MODE, #GL_MODULATE )

  ; when texture area is small, bilinear filter the closest mipmap
  glTexParameterf(#GL_TEXTURE_2D, #GL_TEXTURE_MIN_FILTER, #GL_LINEAR_MIPMAP_NEAREST );
  ; when texture area is large, bilinear filter the original
  glTexParameterf(#GL_TEXTURE_2D, #GL_TEXTURE_MAG_FILTER, #GL_LINEAR );

  rv = gluBuild2DMipmaps(#GL_TEXTURE_2D, 1, pWidth, pHeight, #GL_LUMINANCE, #GL_UNSIGNED_BYTE, *mem)

  FreeMemory(*mem)
  If rv <> 0
    Debug PeekS(gluErrorString(rv))
    ;glDeleteTextures(1, @*Image\TexID)
    ProcedureReturn 0
  EndIf

  ProcedureReturn TexID
EndProcedure

Procedure InitGL()
  glClearColor(0.0, 0.0, 0.0, 0.0)

  glEnable(#GL_TEXTURE_2D)
  glEnable(#GL_BLEND)

  glBlendFunc(#GL_SRC_ALPHA, #GL_ONE);
  glPixelStorei(#GL_UNPACK_ALIGNMENT, 1);
   
  glShadeModel(#GL_SMOOTH)
  glClearDepth(1.0)
  glEnable(#GL_DEPTH_TEST)
  glDepthMask(#GL_TRUE);
  glDepthFunc(#GL_LEQUAL)
  glHint(#GL_PERSPECTIVE_CORRECTION_HINT, #GL_NICEST)
EndProcedure

Procedure ResizeScene(width, height)
  If height < 1 : height = 1 : EndIf
  If width < 1 : width = 1 : EndIf

  glViewport(0, 0, width, height)
  glMatrixMode(#GL_PROJECTION)
  glLoadIdentity()

  gluPerspective(45, width / height, 0.1,  1000)

  glMatrixMode(#GL_MODELVIEW)
  glLoadIdentity()
EndProcedure

Procedure DrawScene()
glEnable(#GL_TEXTURE_2D)
  glClear(#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)

  glLoadIdentity()
  glTranslatef(0, 0, -5)

  glBindTexture(#GL_TEXTURE_2D, WallTexture)

  glBegin(#GL_QUADS);

  glTexCoord2f(0.0, 0.0);
  glVertex3f(0.0, 0.0,  1.0);   // Bottom Left Of The Texture and Quad
  glTexCoord2f(1.0, 0.0);
  glVertex3f( 1.0, 0.0,  1.0);   // Bottom Right Of The Texture and Quad
  glTexCoord2f(1.0, 1.0);
  glVertex3f( 1.0,  1.0,  1.0);   // Top Right Of The Texture and Quad
  glTexCoord2f(0.0, 1.0);
  glVertex3f(0.0,  1.0,  1.0);   // Top Left Of The Texture and Quad


  glEnd( );
EndProcedure


InitSprite() : InitKeyboard()
OpenWindow (0, 100, 100, 512, 512, "OpenGL Window")
OpenWindowedScreen(WindowID(0), 0, 0, 512, 512, 0, 0, 0, #PB_Screen_WaitSynchronization)

glDisable(#GL_TEXTURE_RECTANGLE_ARB)
PB_Screen_Target = #GL_TEXTURE_2D

; load textures
#width = 64
#height = 64

WallTexture = GenerateTexture(#width, #height)

InitGL()

Repeat
  Select WindowEvent()
    Case #PB_Event_CloseWindow
      Break
  EndSelect

  ExamineKeyboard()
  If KeyboardReleased(#PB_Key_Escape)
    Break
  EndIf

  DrawScene()
  FlipBuffers()
  ResizeScene(WindowWidth(0), WindowHeight(0))

  Repeat
  glError = glGetError()
  Select glError
    Case 0
      Break
    Default
      Debug PeekS(gluErrorString(glError))
  EndSelect
  ForEver
ForEver

Re: OpenGL & Textures

Posted: Tue Apr 20, 2010 11:14 pm
by IdeasVacuum
PB4.4x86, WinXP, NVIDIA GeForce 7900, OpenGL 2.1.2

Weird here too. With or without

Code: Select all

WallTexture = GenerateTexture(#width, #height)
All I see is a black windowed screen with a white square, no error messages from the compiler. The output bitmap is a greyscale tiled thingy - a lot of detail in a small image.

Re: OpenGL & Textures

Posted: Tue Apr 20, 2010 11:38 pm
by Foz
I've just updated the my original post, can someone give it a go please? I can't get to anything other than my Intel netbook until tomorrow :(

Re: OpenGL & Textures

Posted: Wed Apr 21, 2010 2:14 am
by GBeebe
Just to let you know. Your example works in Linux. But have an ATI card so that bit of info probably doesn't help you. Also, I am not capable of moving the window.

Re: OpenGL & Textures

Posted: Wed Apr 21, 2010 9:29 am
by Foz
How very odd. I've just tried it on a Windows ATI machine, and the square just disappears, but you're saying in Linux on an ATI machine, it works?

*grrr* back to the drawing board!

Re: OpenGL & Textures

Posted: Thu Apr 22, 2010 2:29 am
by GBeebe
Also, I've tried to alter line:

Code: Select all

Plot(x, y, RGBA(n, n, n, 255))
to change the color, but I always get the same result: http://www.mediafire.com/i/?n2nyewytknj
edit
After reading a bit about some of the gl functions you have there, I see that you intended it on being black and white. I played around a bit with the GenerateTexture Procedure and can make colors...

Code: Select all

Procedure.i GenerateTexture(pWidth.i, pHeight.i)
  ;Protected img = CreateImage(#PB_Any, pWidth, pHeight, 24)
  ;Protected *mem = AllocateMemory(pWidth * pHeight)
  ;If Not *mem : ProcedureReturn 0 : EndIf

Protected *rgba_buffer = AllocateMemory(pWidth * pHeight * 4)
Protected *rgba.l = *rgba_buffer

  ;StartDrawing(ImageOutput(img))
  ;Protected *buffer.Ascii = *mem

  For y = 0 To pHeight-1
    For x = 0 To pWidth-1
      n = Noise(x, y) * 4
      If n < 0   : n = 0   : EndIf
      If n > 255 : n = 255 : EndIf

      PokeL(*rgba, RGBA(255, n, n, 255 - (n*2)))
      *rgba + 4
      ;Plot(x, y, RGBA(255, n, n, 255))
      ;*buffer\a = n
      ;*buffer + 1
    Next
  Next

  ;StopDrawing()
  ;SaveImage(img, #OUTPUT_TEXTURE_FILENAME$)

  Protected TexID = 0
  glGenTextures(1, @TexID)
  glBindTexture(#GL_TEXTURE_2D, TexID)
                                                
  glTexEnvf(#GL_TEXTURE_ENV, #GL_TEXTURE_ENV_MODE, #GL_MODULATE )

  ; when texture area is small, bilinear filter the closest mipmap
  glTexParameterf(#GL_TEXTURE_2D, #GL_TEXTURE_MIN_FILTER, #GL_LINEAR_MIPMAP_NEAREST );
  ; when texture area is large, bilinear filter the original
  glTexParameterf(#GL_TEXTURE_2D, #GL_TEXTURE_MAG_FILTER, #GL_LINEAR );
  
  rv = gluBuild2DMipmaps(#GL_TEXTURE_2D, 4, pWidth, pHeight, #GL_RGBA, #GL_UNSIGNED_BYTE, *rgba_buffer)

  ;FreeMemory(*mem)
  FreeMemory(*rgba_buffer)
  If rv <> 0
    Debug PeekS(gluErrorString(rv))
    ;glDeleteTextures(1, @*Image\TexID)
    ProcedureReturn 0
  EndIf

  ProcedureReturn TexID
EndProcedure
As I got very confused when trying to learn OpenGL a few years ago, I didn't get very far at all. I assume that the texture above has an alpha value, but I don't see it being applied to the screen.

Re: OpenGL & Textures

Posted: Thu Apr 22, 2010 7:56 am
by Foz
Well, it's deeper than what I thought. Last night I tried an example from the Red Book, and that too had the same problem - even with a proper RGBA texture.

I have a feeling that the OpenGL subsystem is doing some magic that I'm not aware of, and in fact this issue has been reported before: http://www.purebasic.fr/english/viewtop ... 17#p276817

So what now? If I create my own OpenGL window, then I have to handle all the the other handlers, such as keyboard, sounds, etc... which is in fact writing my own cross platform subsystem that replicates everything that the team have already done. Ugh...

Another alternative is to use GLUT that has been posted, but for some reason, it doesn't play nice with the PureBasic debugger.

I've settled on asking Fred a question, and depending on the response will see where I go from here.

If I don't get a response where I can work with the current PB system... well, the would depend if others are willing to join in in creating a new OpenGL subsystem which does everything that PB already does, but with access to the OpenGL api. I don't want to rewrite it by myself.

If no one wants to do that, then I'll switch to GLUT and see how my mileage goes with that.

Re: OpenGL & Textures

Posted: Thu Apr 22, 2010 11:48 am
by Foz
I love Fred :mrgreen:

He's solved the problem :)

edit *** spoke too soon

The issue at first glance is the fact that the OpenGL texture state was set to GL_TEXTURE_RECTANGLE_ARB. So disabling it, and setting the Screen Target to use 2d Textures, appeared to have fixed the problem for ATIs... but not for nvidia's

Re: OpenGL & Textures

Posted: Fri Apr 23, 2010 2:36 am
by GBeebe
I've got alpha working, along with figuring out how to move, rotate, and "zoom" the image:

Code: Select all

;#OUTPUT_TEXTURE_FILENAME$ = "output check.bmp"



Global WallTexture

Global obj_x.f, obj_y.f, obj_z.f, obj_a
obj_z = -5


;{--- OpenGL Setup
CompilerIf Subsystem("OpenGL")
CompilerElse
  MessageRequester("ERROR", "Set the subsystem To OpenGL")
  End
CompilerEndIf

#GL_BLEND = $0BE2
#GL_COLOR_BUFFER_BIT = $00004000
#GL_DEPTH_BUFFER_BIT = $00000100
#GL_DEPTH_TEST = $0B71
#GL_LEQUAL = $0203
#GL_LINEAR = $2601
#GL_LINEAR_MIPMAP_NEAREST = $2701
#GL_LUMINANCE = $1909
#GL_MODELVIEW = $1700
#GL_MODULATE = $2100
#GL_NICEST = $1102
#GL_PERSPECTIVE_CORRECTION_HINT = $0C50
#GL_PROJECTION = $1701
#GL_QUADS = $0007
#GL_SMOOTH = $1D01
#GL_TEXTURE_2D = $0DE1
#GL_TEXTURE_ENV = $2300
#GL_TEXTURE_ENV_MODE = $2200
#GL_TEXTURE_MAG_FILTER = $2800
#GL_TEXTURE_MIN_FILTER = $2801
#GL_TEXTURE_WRAP_S = $2802
#GL_TEXTURE_WRAP_T = $2803
#GL_TRUE = 1
#GL_UNSIGNED_BYTE = $1401

#GL_SRC_ALPHA = $0302
#GL_ONE = 1
#GL_UNPACK_ALIGNMENT = $0CF5


CompilerIf #PB_Compiler_OS = #PB_OS_Linux
ImportC "/usr/lib/libX11.a"+Chr('"')+" -l"+Chr('"')+"GL"
CompilerElse
Import "Opengl32.lib"
CompilerEndIf
   glBegin(a.l)
   glBindTexture(a.l,b.l)
   glClear(a.l)
   glClearColor(a.f,b.f,c.f,d.f)
   glClearDepth(a.d)
   glDepthFunc(a.l)
   glDepthMask(a.c)
   glEnable(a.l)
   glEnd()
   glGenTextures(a.l,b.l)
   glGetError()
   glHint(a.l,b.l)
   glLoadIdentity()
   glMatrixMode(a.l)
   glShadeModel(a.l)
   glTexCoord2f(a.f,b.f)
   glTexEnvf(a.l,b.l,c.f)
   glTexParameterf(a.l,b.l,c.f)
   glTranslatef(a.f,b.f,c.f)
   glVertex3f(a.f,b.f,c.f)
   glViewport(a.l,b.l,c.l,d.l)
   glColor4f(a.f,b.f,c.f,d.f); As "glColor4f"
     glBlendFunc(a.l,b.l) ; As "glBlendFunc@8"
   glPixelStorei(a.l,b.l) ; As "glPixelStorei@8"
  glRotatef(a.f,b.f,c.f,d.f)
EndImport

CompilerIf #PB_Compiler_OS = #PB_OS_Linux
ImportC "/usr/lib/libGLU.a"
CompilerElse
Import "Glu32.lib"
CompilerEndIf
   gluBuild2DMipmaps(a.l,b.l,c.l,d.l,e.l,f.l,g.l)
   gluErrorString(a.l)
   gluPerspective(a.d,b.d,c.d,d.d)
EndImport
;}

Procedure Noise(x, y)
  Static salt = 0
  salt = salt ! x & y
  ProcedureReturn salt
EndProcedure

Procedure.i GenerateTexture(pWidth.i, pHeight.i)
  ;Protected img = CreateImage(#PB_Any, pWidth, pHeight, 24)
  ;Protected *mem = AllocateMemory(pWidth * pHeight)
  ;If Not *mem : ProcedureReturn 0 : EndIf

Protected *rgba_buffer = AllocateMemory(pWidth * pHeight * 4)
Protected *rgba.l = *rgba_buffer

  ;StartDrawing(ImageOutput(img))
  ;Protected *buffer.Ascii = *mem

  For y = 0 To pHeight-1
    For x = 0 To pWidth-1
      ;n = Noise(x, y) * 4
      ;If n < 0   : n = 0   : EndIf
      ;If n > 255 : n = 255 : EndIf

      PokeL(*rgba, RGBA(255, 0, 0, 255 - (y*4)+1))
      *rgba + 4
      ;Plot(x, y, RGBA(255, n, n, 255))
      ;*buffer\a = n
      ;*buffer + 1
    Next
  Next

  ;StopDrawing()
  ;SaveImage(img, #OUTPUT_TEXTURE_FILENAME$)

  Protected TexID = 0
  glGenTextures(1, @TexID)
  glBindTexture(#GL_TEXTURE_2D, TexID)
                                                
  glTexEnvf(#GL_TEXTURE_ENV, #GL_TEXTURE_ENV_MODE, #GL_MODULATE )

  ; when texture area is small, bilinear filter the closest mipmap
  glTexParameterf(#GL_TEXTURE_2D, #GL_TEXTURE_MIN_FILTER, #GL_LINEAR_MIPMAP_NEAREST );
  ; when texture area is large, bilinear filter the original
  glTexParameterf(#GL_TEXTURE_2D, #GL_TEXTURE_MAG_FILTER, #GL_LINEAR );
  
  rv = gluBuild2DMipmaps(#GL_TEXTURE_2D, 4, pWidth, pHeight, #GL_RGBA, #GL_UNSIGNED_BYTE, *rgba_buffer)

  ;FreeMemory(*mem)
  FreeMemory(*rgba_buffer)
  If rv <> 0
    Debug PeekS(gluErrorString(rv))
    ;glDeleteTextures(1, @*Image\TexID)
    ProcedureReturn 0
  EndIf

  ProcedureReturn TexID
EndProcedure

Procedure InitGL()

    #GL_RGBA = $1908
    #GL_SRC_COLOR = $0300
    #GL_DST_COLOR = $0306
  
  glClearColor(0.0, 1.0, 0.0, 1.0)

  glEnable(#GL_TEXTURE_2D)
  glEnable(#GL_BLEND)
  ;glColor4f(1.0,1.0,1.0,1.0);	
  glBlendFunc(#GL_SRC_ALPHA, $0303);
  glPixelStorei(#GL_UNPACK_ALIGNMENT, 1);
   
  glShadeModel(#GL_SMOOTH)
  glClearDepth(1.0)
  glEnable(#GL_DEPTH_TEST)
  glDepthMask(#GL_TRUE);
  glDepthFunc(#GL_LEQUAL)
  glHint(#GL_PERSPECTIVE_CORRECTION_HINT, #GL_NICEST)
EndProcedure

Procedure ResizeScene(width, height)
  If height < 1 : height = 1 : EndIf
  If width < 1 : width = 1 : EndIf

  glViewport(0, 0, width, height)
  glMatrixMode(#GL_PROJECTION)
  glLoadIdentity()

  gluPerspective(45, width / height, 0.1,  1000)

  glMatrixMode(#GL_MODELVIEW)
  glLoadIdentity()
EndProcedure

Procedure DrawScene()
glEnable(#GL_TEXTURE_2D)
  glClear(#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)

  glLoadIdentity()
  glTranslatef(obj_x.f, obj_y.f, obj_z.f)
  glRotatef(obj_a, 0, 0, 1)
  glBindTexture(#GL_TEXTURE_2D, WallTexture)

  glBegin(#GL_QUADS);
;glBegin($0004) ;GL_TRIANGLES

  glTexCoord2f(0.0, 0.0);
  glVertex3f(0.0, 0.0,  1.0);   // Bottom Left Of The Texture and Quad
  glTexCoord2f(1.0, 0.0);
  glVertex3f( 1.0, 0.0,  1.0);   // Bottom Right Of The Texture and Quad
  glTexCoord2f(1.0, 1.0);
  glVertex3f( 1.0,  1.0,  1.0);   // Top Right Of The Texture and Quad
  glTexCoord2f(0.0, 1.0);
  glVertex3f(0.0,  1.0,  1.0);   // Top Left Of The Texture and Quad


  glEnd( );
EndProcedure


InitSprite() : InitKeyboard()
OpenWindow (0, 100, 100, 512, 512, "OpenGL Window")
OpenWindowedScreen(WindowID(0), 0, 0, 512, 512, 0, 0, 0, #PB_Screen_WaitSynchronization)

; load textures
#width = 64
#height = 64

WallTexture = GenerateTexture(#width, #height)

InitGL()
KeyboardMode(#PB_Keyboard_International)

Repeat
  Select WindowEvent()
    Case #PB_Event_CloseWindow
      Break
  EndSelect

  ExamineKeyboard()
  If KeyboardReleased(#PB_Key_Escape)
    Break
  EndIf
  
  If KeyboardPushed(#PB_Key_Up)
    obj_y - 0.01
  EndIf
  
  If KeyboardPushed(#PB_Key_Down)
    obj_y + 0.01
  EndIf
  
  If KeyboardPushed(#PB_Key_Left)
    obj_x - 0.01
  EndIf
  
  If KeyboardPushed(#PB_Key_Right)
    obj_x + 0.01
  EndIf
  
  If KeyboardPushed(#PB_Key_PageUp)
    obj_z + 0.01
  EndIf
  
  If KeyboardPushed(#PB_Key_PageDown)
    obj_z - 0.01
  EndIf  
  
  If KeyboardPushed(#PB_Key_Z)
    obj_a + 1
  EndIf
  
  If KeyboardPushed(#PB_Key_X)
    obj_a - 1
  EndIf
  
  DrawScene()
  FlipBuffers()
  ResizeScene(WindowWidth(0), WindowHeight(0))

  Repeat
  glError = glGetError()
  Select glError
    Case 0
      Break
    Default
      Debug PeekS(gluErrorString(glError))
  EndSelect
  ForEver
ForEver
Is there a linux user with an Nvidia card around here? I wouldn't think that it's PB's subsystem that is causing the problem you get, perhaps it is OpenGL itself, or the way it is setup? If it is the subsystem, I would totally be on board writing a wrapper with everyone, as long as it doesn't split into non-cross platform versions.

Re: OpenGL & Textures

Posted: Fri Apr 23, 2010 9:13 pm
by Foz
Yeah, it's me who has the nVidia Linux machine... and that's what's causing look for what it could possibly be.

Your example is missing the constant

Code: Select all

#GL_RGBA = $1908
once you add that in, I get a bright green background and a white square on my nVidia machine.

glxinfo returns:
OpenGL vendor string: NVIDIA Corporation
OpenGL renderer string: GeForce 8800 GT/PCI/SSE2/3DNOW!
OpenGL version string: 2.1.2 NVIDIA 173.14.22
I'm going to try just using the software renderer and see if that makes a difference...

Re: OpenGL & Textures

Posted: Fri Apr 23, 2010 10:29 pm
by Foz
... and I appear to have hit the jackpot!

The issue appears to lie with the nVidia 173 drivers. After removing them and trying Mesa, it worked. I then noticed that I hadn't been using the *latest* 195 drivers. So in it goes, and lo and behold! Textures!

Something is seriously wrong with those old drivers - which is something to keep in mind if people have trouble in the future.

The key is as Fred rightly pointed out, that the texture state was set up differently (which is done on OpenScreen() ), and the trying to mesh to incompatible texture states had the drivers in a tizzy.

Once you disable the GL_TEXTURE_RECTANGLE_ARB textures, then you are good to go (see my first post for the fixed version). I can confirm that it works on Win Intel, Linux Intel, Linux nVidia, Win ATI.

Thanks Fred for your help! :mrgreen: