kryton9
26-02-2010, 03:36
The attachment contains the necessary model file for the teapot and also the source code.
' Example 4.3 First OpenGL Program
' From Stan Blank's Book:
' "Python Programming in OpenGL
' "A Graphical Approach to Programming
' Converted by Kent Sarikaya
' Last modified: February 25, 2010
' thinBasic does not use GLUT, we use instead tbgl
Uses "TBGL"
' It is nice to use Constants instead of just numbers
%teapot = 1
' We need to load our teapot mesh
TBGL_m15LoadModel "teapot.m15", "", %teapot, 0, %TBGL_NORMAL_SMOOTH
' We are not using any special lighting in this example
TBGL_UseLighting %FALSE
' Handle for our window
Local hWnd As DWord
' Create and show window
hWnd = TBGL_CreateWindowEx("My Second OGL Program", 250, 250, 32, %TBGL_WS_WINDOWED Or %TBGL_WS_CLOSEBOX)
TBGL_ShowWindow
' Resets status of all keys
TBGL_ResetKeyState()
' Main loop
While TBGL_IsWindow(hWnd)
TBGL_ClearFrame
' This gives us our wireframe look
TBGL_PolygonLook %GL_LINE
' Move the teapot away from the camera so we can see it, the camera by default is at position 0,0,0
TBGL_Translate 0,0,-1.75
' I imported the model in the wrong direction so I will compensate for the rotation here
' 90 degress in the y axis
TBGL_Rotate 90, 0,1,0
TBGL_m15DrawModel %teapot
TBGL_DrawFrame
' ESCAPE key to exit application
If TBGL_GetWindowKeyState(hWnd, %VK_ESCAPE) Then Exit While
Wend
TBGL_DestroyWindow
'Python source page 28
'# First Python OpenGL program
'# ogl1.py
'from OpenGL.GLUT import *
'from OpenGL.GL import *
'from OpenGL.GLU import *
'def Draw():
' glClear(GL_COLOR_BUFFER_BIT)
' glutWireTeapot(0.5)
' glFlush()
'glutInit(sys.argv)
'glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB)
'glutInitWindowSize(250, 250)
'glutInitWindowPosition(100, 100)
'glutCreateWindow("My Second OGL Program")
'glutDisplayFunc(Draw)
'glutMainLoop()
'# End of program
' Example 4.3 First OpenGL Program
' From Stan Blank's Book:
' "Python Programming in OpenGL
' "A Graphical Approach to Programming
' Converted by Kent Sarikaya
' Last modified: February 25, 2010
' thinBasic does not use GLUT, we use instead tbgl
Uses "TBGL"
' It is nice to use Constants instead of just numbers
%teapot = 1
' We need to load our teapot mesh
TBGL_m15LoadModel "teapot.m15", "", %teapot, 0, %TBGL_NORMAL_SMOOTH
' We are not using any special lighting in this example
TBGL_UseLighting %FALSE
' Handle for our window
Local hWnd As DWord
' Create and show window
hWnd = TBGL_CreateWindowEx("My Second OGL Program", 250, 250, 32, %TBGL_WS_WINDOWED Or %TBGL_WS_CLOSEBOX)
TBGL_ShowWindow
' Resets status of all keys
TBGL_ResetKeyState()
' Main loop
While TBGL_IsWindow(hWnd)
TBGL_ClearFrame
' This gives us our wireframe look
TBGL_PolygonLook %GL_LINE
' Move the teapot away from the camera so we can see it, the camera by default is at position 0,0,0
TBGL_Translate 0,0,-1.75
' I imported the model in the wrong direction so I will compensate for the rotation here
' 90 degress in the y axis
TBGL_Rotate 90, 0,1,0
TBGL_m15DrawModel %teapot
TBGL_DrawFrame
' ESCAPE key to exit application
If TBGL_GetWindowKeyState(hWnd, %VK_ESCAPE) Then Exit While
Wend
TBGL_DestroyWindow
'Python source page 28
'# First Python OpenGL program
'# ogl1.py
'from OpenGL.GLUT import *
'from OpenGL.GL import *
'from OpenGL.GLU import *
'def Draw():
' glClear(GL_COLOR_BUFFER_BIT)
' glutWireTeapot(0.5)
' glFlush()
'glutInit(sys.argv)
'glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB)
'glutInitWindowSize(250, 250)
'glutInitWindowPosition(100, 100)
'glutCreateWindow("My Second OGL Program")
'glutDisplayFunc(Draw)
'glutMainLoop()
'# End of program