28398
Anmeldungsdatum: 25.04.2008 Beiträge: 1917
|
Verfasst am: 07.07.2008, 21:03 Titel: |
|
|
Keiner ne Idee?
Es ist wirklich merkwürdig.
Mit denselben Programm in C = einwandfrei, sobald FB = geht nich
EDIT:
LOOOOL
FB True = -1 != GL_TRUE (was glfw nutzt)
Okay, der Code ist vollständig inordnung, wenn man alles mit GL_FALSE überprüft damn:
Code: |
#Ifdef __FB_WIN32__
#Include "windows.bi"
#EndIf
#Include "gl/gl.bi"
#Include "gl/glu.bi"
#Include "gl/glfw.bi"
'----------------------------------------------------------------------
' DrawScene() - Main OpenGL drawing function that is called each frame
'----------------------------------------------------------------------
Sub DrawScene ()
Dim As Integer w, h
Dim As Double t
' Get current time
t = glfwGetTime()
' Get window size
glfwGetWindowSize(@w, @h)
' Make sure that height is non-zero to avoid division by zero
h = IIf(h < 1, 1, h)
' Set viewport
glViewport(0, 0, w, h)
' Clear color and depht buffers
glClearColor(0.0f, 0.0f, 0.0f, 0.0f)
glClear(GL_COLOR_BUFFER_BIT Or GL_DEPTH_BUFFER_BIT)
' Set up projection matrix
glMatrixMode(GL_PROJECTION) ' Select projection matrix
glLoadIdentity() ' Start with an identity matrix
gluPerspective( _ ' Set perspective view
65.0f, _ ' Field of view = 65 degrees
Cast(Double, w) / Cast(Double, h), _ ' Window aspect (assumes square pixels)
1.0f, _ ' Near Z clipping plane
100.0f _ ' Far Z clippling plane
)
' Set perspective view
glMatrixMode(GL_MODELVIEW) ' Select modelview matrix
glLoadIdentity() ' Start with an identity matrix
gluLookAt( _ ' Set camera position and orientation
0.0f, 0.0f, 10.0f, _ ' Camera position (x,y,z)
0.0f, 0.0f, 0.0f, _ ' View point (x,y,z)
0.0f, 1.0f, 0.0f _ ' Up-vector (x,y,z)
)
' Here is where actual OpenGL rendering calls would begin...
End Sub
'----------------------------------------------------------------------
' main() - Program entry point
'----------------------------------------------------------------------
Function main (argc As Integer, argv As ZString Ptr Ptr) As Integer
Dim As Integer ok ' Flag telling if the window was opened
Dim As Integer running ' Flag telling if the program is running
Dim As Integer glfwmajor ' GLFW major version
Dim As Integer glfwminor ' GLFW minor version
Dim As Integer glfwrev ' GLFW revision
' Initialize GLFW
If glfwInit() = GL_FALSE Then
Print "Cannot initialise GLFW!"
Return 0
EndIf
' Check version
glfwGetVersion(@glfwmajor, @glfwminor, @glfwrev)
If (glfwmajor < GLFW_VERSION_MAJOR) Or _
(glfwminor < GLFW_VERSION_MINOR) Or _
(glfwrev < GLFW_VERSION_REVISION) Then
Print "GLFW Library too old!"
glfwTerminate()
Return 0
EndIf
' Open window
ok = glfwOpenWindow( _
640, 480, _ ' Width and height of window
8, 8, 8, _ ' Number of red, green, and blue bits for color buffer
8, _ ' Number of bits for alpha buffer
24, _ ' Number of bits for depth buffer (Z-buffer)
0, _ ' Number of bits for stencil buffer
GLFW_WINDOW _ ' We want a desktop window (could be GLFW_FULLSCREEN)
)
' If we could not open a window, exit now
If ok = GL_FALSE Then
Print "could not open window!"
glfwTerminate()
Return 0
EndIf
' Set window title
glfwSetWindowTitle("My OpenGL program")
' Enable sticky keys
glfwEnable(GLFW_STICKY_KEYS)
' Main rendering loop
Do
' Call our rendering function
DrawScene()
' Swap front and back buffers (we use a double buffered display)
glfwSwapBuffers()
' Check if the escape key was pressed, or if the window was closed
running = Not (glfwGetKey(GLFW_KEY_ESC) Or glfwGetWindowParam(GLFW_OPENED))
Loop While running
' Terminate GLFW
glfwTerminate()
' Exit program
Return 0
End Function
End main(__FB_ARGC__, __FB_ARGV__)
|
Ich kann nach meinen Erfahrungen (ich habs in der Zwischenzeit mit C gemacht ) jeden openGL Programmierer GLFW ans Herz legen.
Zwar wird es seit 2007 nicht mehr weiterentwickelt, es ist jedoch solide, hat eine gute Dokumentation, leich verständliche Prinzipien, einfach zu merkende Funktionsnamen, und auch noch schöne andere Features:
Multithreading, VSync, TGA Loader für alle TGA Formate, usw. usf.
Gut okay, bei diesen Releaseintervallen kann man das jetzt wohl (noch?) schlecht beurteilen... |
|