Regarding my topic concerning pixel-perfect images
I figured out how to use non-power-of-two textures. For those who like an example:
ghislain
I figured out how to use non-power-of-two textures. For those who like an example:
Strict Local c_width:Float = 640 Local c_height:Float = 480 GLGraphics c_width, c_height Local myExtensions:String = String.FromCString( glGetString( GL_EXTENSIONS ) ).ToLower() ?macos If myExtensions.find("gl_ext_texture_rectangle") = -1 Then RuntimeError "Extension not supported!" End End If ? glviewport (0,0, c_width, c_height) ' origin of avbl screen + width & height glmatrixmode (gl_projection) ' modelview, projection or texture matrix glloadidentity () ' set 4x4 identity matrix gluortho2d (0.0,c_width,c_height, 0.0) ' creates a matrix For projecting 2d coordinates glclear(gl_color_buffer_bit) glmatrixmode (gl_modelview) glLoadidentity () ' Enable non-power-of-two textures glEnable (gl_TEXTURE_RECTANGLE_EXT) ' <--- !!! ' load a pixmap Local pmap:TPixmap = LoadPixmap ("mapkansas.bmp") If pmap.format<>PF_RGBA8888 pmap=pmap.Convert( PF_RGBA8888 ) ' convert to RGBA Local w:Float = PixmapWidth (pmap) Local h:Float = PixmapHeight (pmap) ' Create/Assign Texture ' All GL_TEXTURE_2D is replaced by GL_TEXTURE_RECTANGLE_EXT Local texName:Int glPixelStorei GL_UNPACK_ALIGNMENT, 1 glGenTextures 1, Varptr texName glBindTexture gl_texture_rectangle_ext, texName ' <--- !!! glTexImage2D gl_texture_rectangle_ext, 0, GL_RGBA8, pmap.width, pmap.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pmap.pixels ' <--- !!! glBegin (gl_quads) ' TL glTexCoord2f 0.0, 0.0 glvertex2f 0.0, 0.0 ' TR glTexCoord2f w, 0.0 ' <--- !!! All TexCoord's are in pixels instead of [0.0 - 1.0] glVertex2f w, 0.0 ' BR glTexCoord2f w, h glVertex2f w, h ' BL glTexCoord2f 0.0, h glVertex2f 0.0, h glEnd Flip WaitKey() End
ghislain