Can anyone explain how they work and how they differ from TImage?
I've only used TImages, however, getting into opengl it seems like to create a texture, Pixmaps are the easyest... Yet I'm having trouble trying to render a image:
I'm getting some wierd errors trying to load the pixmap. Am I doing it right?
I've only used TImages, however, getting into opengl it seems like to create a texture, Pixmaps are the easyest... Yet I'm having trouble trying to render a image:
SuperStrict Framework pub.OpenGL Import BRL.GLGraphics Import BRL.Pixmap Type TSprite Field img_tex:Int Field rot:Int Method InitImage:TSprite(img:TPixmap) img_tex = GLTexFromPixmap(img) End Method Method Render(x:Int,y:Int) glTranslatef(x, y, 0.0) glRotatef(rot, 0.0, 0.0, 1.0) glBindTexture(GL_TEXTURE_2D, img_tex) glBegin(GL_QUADS) glTexCoord2f(0.0, 0.0); glVertex2i(-10, -10)' top left glTexCoord2f(1.0, 0.0); glVertex2i( 10, -10)' top right glTexCoord2f(1.0, 1.0); glVertex2i( 10, 10)' bottom right glTexCoord2f(0.0, 1.0); glVertex2i(-10, 10)' bottom left glEnd() glLoadIdentity() End Method End Type '------------------------------------------------------------------------------ GLGraphics 1024, 768 InitalizeGL() 'initalize opengl stuff Local x:Int = 300 Local y:Int = 300 Local mysprite:TSprite = LoadSprite("star.png") 'Main loop, quit on KEY_ESCAPE While Not KeyDown(KEY_ESCAPE) glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT) 'Cls but opengl If KeyDown(KEY_LEFT) x:-1 If KeyDown(KEY_RIGHT) x:+1 DrawSprite(mysprite, x, y) Flip 1 Wend End Function InitalizeGL() glShadeModel(GL_SMOOTH) glEnable(GL_TEXTURE_2D) glEnable(GL_BLEND) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) glViewport(0,0,1024,768) glMatrixMode(GL_PROJECTION) glLoadIdentity() glOrtho(0.0,1024,768,0.0,-1.0,1.0) glMatrixMode(GL_MODELVIEW) glLoadIdentity() End Function Function LoadSprite:TSprite(L:String) Local pm:TPixmap = LoadPixmap L If Not pm Return Sprite:TSprite = New TSprite Sprite.InitImage(pm) Return Sprite End Function Function DrawSprite(s:TSprite, x:Int, y:Int) If s = Null Return s.Render(x,y) End Function
I'm getting some wierd errors trying to load the pixmap. Am I doing it right?