iDevGames Forums
Rectangle Textures and RubyGameCommon - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: Rectangle Textures and RubyGameCommon (/thread-6013.html)



Rectangle Textures and RubyGameCommon - Skorche - Dec 22, 2004 03:43 PM

Edit: solved the problem

This might be more of a Rectangle texture problem than RGC.
First of all, I added the rectangle texture constant myself, so it does exist and compiled fine.

So I have this code:
Code:
GL.Enable(GL::TEXTURE_RECTANGLE_EXT)    
GL.PixelStore(GL::UNPACK_ALIGNMENT, 1)
        
texNum = GL.GenTextures(1)[0]        
GL.BindTexture(GL::TEXTURE_RECTANGLE_EXT, texNum[0])
    
texPNG = load_png_image(fileName)
    
GL.TexParameter(GL::TEXTURE_RECTANGLE_EXT, GL::TEXTURE_WRAP_S, wrap)
GL.TexParameter(GL::TEXTURE_RECTANGLE_EXT, GL::TEXTURE_WRAP_T, wrap)
GL.TexParameter(GL::TEXTURE_RECTANGLE_EXT, GL::TEXTURE_MAG_FILTER, filter)
GL.TexParameter(GL::TEXTURE_RECTANGLE_EXT, GL::TEXTURE_MIN_FILTER, filter)
        
GL.TexImage2D(GL::TEXTURE_RECTANGLE_EXT, 0, GL::RGBA,
            texPNG['width'], texPNG['height'],
            0, GL::RGBA, GL::UNSIGNED_BYTE,
            texPNG['data'])

GL.Begin(GL::QUADS)
        GL.TexCoord(0, 0)
        GL.Vertex(xmin, ymin)
        GL.TexCoord(100, 0)
        GL.Vertex(xmax, ymin)
        GL.TexCoord(100, 100)
        GL.Vertex(xmax, ymax)
        GL.TexCoord(0, 100)
        GL.Vertex(xmin, ymax)
GL.End


I've taken out everything but the texturing code.

When drawn, all I get is a white squares, even with a solid color texture.
If I replace the TEXTURE_RECTANGLE_EXT with TEXTURE_2D, and change the texturing coordinates it works correctly.

On the other hand, I went to one of my programs in C and and tried to use GL_RECTANGLE_EXT and it told me it was undefined. Is there some special header needed? I also remember hearing that you need to load extensions explicitly, is this true?


Rectangle Textures and RubyGameCommon - Josh - Dec 22, 2004 03:46 PM

GL_RECTANGLE_EXT should be in <OpenGL/glext.h>


Rectangle Textures and RubyGameCommon - Skorche - Dec 22, 2004 04:35 PM

*Smacks forehead again* Once again, after spending an hour looking for the problem, I find it shortly after posting.

I had simply missed a line in one of the files that set the texture target back to TEXTURE_2D.

Anyway, a new question. Is GL_TEXTURE_RECTANGLE_EXT supported cross platform? If it is, I should mention to Keith to add it.

Josh: Thanks, the Apple docs didn't mention any extra includes.


Rectangle Textures and RubyGameCommon - OneSadCookie - Dec 22, 2004 07:05 PM

NV_texture_rectangle, EXT_texture_rectangle, ARB_texture_rectangle, all the same thing. I can add the constant to the file if you want Smile


Rectangle Textures and RubyGameCommon - Skorche - Dec 22, 2004 07:34 PM

OneSadCookie Wrote:NV_texture_rectangle, EXT_texture_rectangle, ARB_texture_rectangle, all the same thing. I can add the constant to the file if you want Smile

I don't see why it shouldn't be made official.