#include once "FBTinyGL.bi" ' test of glEnable(GL_BLEND) ' (internal I use pink as transparent color) ' using textures needs a 24/32-bit image screenres 8,8,32,,-1 ' create image with pink background color ' NOTE you can use any size but internal all textures ' are scaled down or up to 256 x 256 pixels dim as any ptr img = ImageCreate(256,256) Circle img,(128 ,128),120,rgb(255,255, 0),,,,F Circle img,(128-48, 64), 32,rgb(255,255,255),,,,F Circle img,(128+48, 64), 32,rgb(255,255,255),,,,F Circle img,(128-48, 70), 16,rgb( 0, 0, 0),,,,F Circle img,(128+48, 70), 16,rgb( 0, 0, 0),,,,F Circle img,(128 ,128), 48,rgb( 0, 0, 0),1.57*2,1.57*4 Circle img,(128 ,129), 48,rgb( 0, 0, 0),1.57*2,1.57*4 Circle img,(128 ,130), 48,rgb( 0, 0, 0),1.57*2,1.57*4 dim as integer scr_w = 640 dim as integer scr_h = 480 ' NOTE: You can use all fbgfx modes (1,2,4,8,15,16,24 or 32) ' but internal I render all in 16-bit dim as integer scr_b = 16 screenres scr_w,scr_h,scr_b ' create a render context ' TinyGL allocates the color and depth buffer. dim as GFX_CONTEXT ptr ctx=CreateRenderContext() ' if we are in palette mode 224 is white if scr_b<15 then color 224 ' minimal OpebGL init glMatrixMode(GL_PROJECTION) gluPerspective(45.0, scr_w/scr_h, 0.1, 100.0) glMatrixMode(GL_MODELVIEW) glClearColor(0,.5,.5) ' allocate OpenGL texture dim as ulong Tex glGenTextures(1,@Tex) glBindTexture(GL_TEXTURE_2D, Tex) glEnable(GL_TEXTURE_2D) ' create texture from fbgfx image pixels dim as ubyte ptr pPixels dim as integer iWidth,iHeight,iBytesPerPixel ImageInfo img,iWidth,iHeight,iBytesPerPixel,,pPixels glTexImage2D(GL_TEXTURE_2D,,iBytesPerPixel,iWidth,iHeight,,,,pPixels) 'glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_FASTEST) 'glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_DONT_CARE) 'glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST) dim as single rtex dim as integer frames,fps=60 dim as double tLast=timer() dim as long mode while inkey="" if (frames mod 1000)=0 then glGetIntegerv(GL_BLEND,@mode) if mode then glDisable(GL_BLEND) else glEnable(GL_BLEND) end if end if glClear(GL_COLOR_BUFFER_BIT) glPushMatrix() glTranslatef(0,0,-5) glRotatef(rtex, 1, 1, 1) glBegin(GL_QUADS) glTexCoord2f(0.0, 0.0) : glVertex3f(-1,-1,0) glTexCoord2f(1.0, 0.0) : glVertex3f( 1,-1,0) glTexCoord2f(1.0, 1.0) : glVertex3f( 1, 1,0) glTexCoord2f(0.0, 1.0) : glVertex3f(-1, 1,0) glEnd() glPopMatrix() rtex += 100 * iif(fps>0,1/fps,0) frames+= 1 screenlock SwapBuffers(ctx) ' copy the color buffer to screen draw string (0,0),"frames: " & frames & " fps: " & fps glGetIntegerv(GL_BLEND,@mode) draw string (0,16),"GL_BLEND: " & iif (mode,"on","off") screenunlock if frames mod 10=0 then dim as double tNow=timer() fps = 10 / (tNow-tLast) tLast=tNow end if 'sleep 10 wend