Home

Add

Edit

With Linenumbers

Code in Textfield

Download

#INCLUDE Once "fbgfx.bi"
#INCLUDE Once "GL/glext.bi"
#INCLUDE Once "GL/glu.bi"
#INCLUDE Once "GL/gl.bi"

Screenres 800, 600, 32, , FB.GFX_OPENGL
GLViewport 0, 0, 800, 600
GLMatrixMode GL_PROJECTION
GLLoadIdentity
GLuPerspective 45.0, 800 / 600, 0.1, 100.0
GLMatrixMode GL_MODELVIEW
GLLoadIdentity
GLClearColor 1 / 255 * &H00, 1 / 255 * &H00, 1 / 255 * &H66, 0.0
GLClearDepth 1.0
GLEnable GL_DEPTH_TEST
GLClear GL_COLOR_BUFFER_BIT Or GL_DEPTH_BUFFER_BIT

'GLEnable(GL_CULL_FACE)
'GLEnable(GL_BLEND)
'GLBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)

Dim TTextureID As Uinteger
Dim TImg As Any Ptr = Imagecreate(100, 100, 32)
Dim TImgW As Integer
Dim TImgH As Integer
Dim TImgP As Integer
Dim TImgPtr As Any Ptr
Dim TImgRow As Uinteger Ptr
ImageInfo(TImg, TImgW, TImgH, , TImgP, TImgPtr)
Line TImg, (0, 0)-(99, 99), &HFFFF0000, BF
Line TImg, (20, 20)-(79, 79), &H0000FF00, BF
Line TImg, (40, 40)-(59, 59), &HFF0000FF, BF

GLGenTextures 1, @TTextureID
GLBindTexture GL_TEXTURE_2D, TTextureID
GLTexImage2D GL_TEXTURE_2D, 0, GL_RGBA, TImgW, TImgH, 0, GL_BGRA, GL_UNSIGNED_BYTE, TImgPtr
GLTexParameteri GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR
GLTexParameteri GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR
'GLTexEnvf GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND
Imagedestroy(TImg)

Dim TPosX As Double
Dim TPosY As Double
Dim TPosZ As Double

Do Until Inkey() = Chr(27)
    GLClear(GL_COLOR_BUFFER_BIT Or GL_DEPTH_BUFFER_BIT)
    
    GLEnable(GL_TEXTURE_2D)
    GLBindTexture(GL_TEXTURE_2D, TTextureID)
    'GLEnable(GL_CULL_FACE)
    'GLEnable(GL_POLYGON_STIPPLE)
    GLEnable(GL_BLEND)
    GLBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
    
    
    TPosX = 0.0: TPosY = 0.0: TPosZ = -3.0
    GLBegin(GL_QUADS)
    GLColor4f(0.0, 1.0, 1.0, 1.0)
    GLTexCoord2D(0, 0): GLVertex3F(TPosX - 0.5, TPosY - 0.5, TPosZ)
    GLTexCoord2D(1, 0): GLVertex3F(TPosX - 0.5, TPosY, TPosZ)
    GLTexCoord2D(1, 1): GLVertex3F(TPosX, TPosY, TPosZ)
    GLTexCoord2D(0, 1): GLVertex3F(TPosX, TPosY - 0.5, TPosZ)
    GLEnd
    
    
    TPosX = 0.12: TPosY = 0.12: TPosZ = -2.9
    GLBegin(GL_QUADS)
    GLColor4f(0.0, 1.0, 1.0, 1.0)
    GLTexCoord2D(0, 0): GLVertex3F(TPosX - 0.5, TPosY - 0.5, TPosZ)
    GLTexCoord2D(1, 0): GLVertex3F(TPosX - 0.5, TPosY, TPosZ)
    GLTexCoord2D(1, 1): GLVertex3F(TPosX, TPosY, TPosZ)
    GLTexCoord2D(0, 1): GLVertex3F(TPosX, TPosY - 0.5, TPosZ)
    GLEnd
    
    
    GLDisable(GL_TEXTURE_2D)
    GLDisable(GL_BLEND)
    
    Flip()
    Sleep 10, 1
Loop

Screen 0, , , FB.GFX_NULL
End 0