Home

Add

Edit

Without Linenumbers

Code in Textfield

Download

  1. #INCLUDE Once "fbgfx.bi"
    
  2. #INCLUDE Once "GL/gl.bi"
    
  3. #INCLUDE Once "GL/glu.bi"
    
  4. 
    
  5. Screenres 800, 600, 32, , FB.GFX_OPENGL
    
  6. GLViewport 0, 0, 800, 600
    
  7. GLMatrixMode GL_PROJECTION
    
  8. GLLoadIdentity
    
  9. GLuPerspective 45.0, 800 / 600, 0.1, 100.0
    
  10. GLMatrixMode GL_MODELVIEW
    
  11. GLLoadIdentity
    
  12. GLClearColor 1 / 255 * &H00, 1 / 255 * &H00, 1 / 255 * &H66, 0.0
    
  13. GLClearDepth 1.0
    
  14. GLEnable GL_DEPTH_TEST
    
  15. GLClear GL_COLOR_BUFFER_BIT Or GL_DEPTH_BUFFER_BIT
    
  16. 
    
  17. 'GLEnable(GL_CULL_FACE)
    
  18. 'GLEnable(GL_BLEND)
    
  19. 'GLBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
    
  20. 
    
  21. Dim TTextureID As Uinteger
    
  22. Dim TImg As Any Ptr = Imagecreate(100, 100, 32)
    
  23. Dim TImgW As Integer
    
  24. Dim TImgH As Integer
    
  25. Dim TImgP As Integer
    
  26. Dim TImgPtr As Any Ptr
    
  27. Dim TImgRow As Uinteger Ptr
    
  28. ImageInfo(TImg, TImgW, TImgH, , TImgP, TImgPtr)
    
  29. Line TImg, (0, 0)-(99, 99), &HFFFF0000, BF
    
  30. Line TImg, (20, 20)-(79, 79), &H0000FF00, BF
    
  31. Line TImg, (40, 40)-(59, 59), &HFF0000FF, BF
    
  32. 
    
  33. GLGenTextures 1, @TTextureID
    
  34. GLBindTexture GL_TEXTURE_2D, TTextureID
    
  35. GLTexImage2D GL_TEXTURE_2D, 0, GL_RGBA, TImgW, TImgH, 0, GL_RGBA, GL_UNSIGNED_BYTE, TImgPtr
    
  36. GLTexParameteri GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR
    
  37. GLTexParameteri GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR
    
  38. GLTexEnvf GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL
    
  39. Imagedestroy(TImg)
    
  40. 
    
  41. Dim TPosX As Double
    
  42. Dim TPosY As Double
    
  43. Dim TPosZ As Double
    
  44. 
    
  45. Do Until Inkey() = Chr(27)
    
  46.     GLClear(GL_COLOR_BUFFER_BIT Or GL_DEPTH_BUFFER_BIT)
    
  47.     
    
  48.     GLEnable(GL_TEXTURE_2D)
    
  49.     GLBindTexture(GL_TEXTURE_2D, TTextureID)
    
  50.     'GLEnable(GL_CULL_FACE)
    
  51.     'GLEnable(GL_POLYGON_STIPPLE)
    
  52.     'GLEnable(GL_BLEND)
    
  53.     GLBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
    
  54.     
    
  55.     
    
  56.     TPosX = 0.0: TPosY = 0.0: TPosZ = -3.0
    
  57.     GLBegin(GL_QUADS)
    
  58.     GLColor4f(0.0, 1.0, 1.0, 0.0)
    
  59.     GLTexCoord2D(0, 0): GLVertex3F(TPosX - 0.5, TPosY - 0.5, TPosZ)
    
  60.     GLTexCoord2D(1, 0): GLVertex3F(TPosX - 0.5, TPosY, TPosZ)
    
  61.     GLTexCoord2D(1, 1): GLVertex3F(TPosX, TPosY, TPosZ)
    
  62.     GLTexCoord2D(0, 1): GLVertex3F(TPosX, TPosY - 0.5, TPosZ)
    
  63.     GLEnd
    
  64.     
    
  65.     
    
  66.     TPosX = 0.12: TPosY = 0.12: TPosZ = -3.0
    
  67.     GLBegin(GL_QUADS)
    
  68.     GLColor4f(0.0, 1.0, 1.0, 0.0)
    
  69.     GLTexCoord2D(0, 0): GLVertex3F(TPosX - 0.5, TPosY - 0.5, TPosZ)
    
  70.     GLTexCoord2D(1, 0): GLVertex3F(TPosX - 0.5, TPosY, TPosZ)
    
  71.     GLTexCoord2D(1, 1): GLVertex3F(TPosX, TPosY, TPosZ)
    
  72.     GLTexCoord2D(0, 1): GLVertex3F(TPosX, TPosY - 0.5, TPosZ)
    
  73.     GLEnd
    
  74.     
    
  75.     
    
  76.     GLDisable(GL_TEXTURE_2D)
    
  77.     'GLDisable(GL_BLEND)
    
  78.     
    
  79.     Flip()
    
  80.     Sleep 10, 1
    
  81. Loop
    
  82. 
    
  83. Screen 0, , , FB.GFX_NULL
    
  84. End 0