why i can't make the shapes to rotate ? even the yrot are global, i miss something.
when we call glutWireTeapot_(0.5) it seems to call the glut32 and it works, but when we call glutWireTeapot(0.5) there is a polink error.
the glutWireRhombicDodecahedron() ; are from freeglut only and it is displayed okay
also glutWireCylinder is from the freeglut only and it is okay, but the glutWireSierpinskiSponge from freeglut only but it gives error
and thanks for Samuel and Danilo for the posts.
Code: Select all
IncludeFile "freeglut_ext.pb"
IncludeFile "freeglut_std.pb"
Import "freeglut.lib"
glutCreateWindow(Title.p-ascii) ; changed for UNICODE mode
glutDisplayFunc(*Proc)
glutIdleFunc(*func)
glutGetWindow()
glutInit(argc.i, argv.b)
glutInitDisplayMode(Flags.i)
glutInitWindowSize(Width.i, Height.i)
glutInitWindowPosition(StartX, StartY.i)
glutMainLoop()
glutMainLoopEvent()
glutSetOption(Action.i, Option.i)
glutSwapBuffers()
glutSetWindowTitle(title.p-ascii)
glutWireTeapot(lenght.f)
glutWireDodecahedron()
glutWireRhombicDodecahedron()
glutWireSierpinskiSponge(a.i, b.d, c.d)
glutWireCylinder(radius.d, height.d, slices.i,stacks.i);
EndImport
Global yrot.f
Declare RenderLoop()
Declare IdleLoop()
Define.i argc = 0
Dim argv.s(0)
argv(0) = ""
glutInit(@argc, @argv)
glutInitDisplayMode(#GLUT_DOUBLE | #GLUT_RGBA)
glutInitWindowSize(800, 600)
glutInitWindowPosition(0, 0)
glutCreateWindow("Freeglut Window")
glutDisplayFunc(@RenderLoop())
glutIdleFunc(@IdleLoop())
glClearColor_(0.9, 0.9, 0.9, 1.0)
glutSetOption(#GLUT_ACTION_ON_WINDOW_CLOSE,#GLUT_ACTION_GLUTMAINLOOP_RETURNS)
glutMainLoop()
End
Procedure RenderLoop()
glClear_(#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT) ;Clear The Screen And The Depth Buffer
glLoadIdentity_()
#GL_COLOR_BUFFER_BIT = 16384
glClear_(#GL_COLOR_BUFFER_BIT)
glScalef_(1,1,1)
;gluLookAt_( 0, 0, 0,
; 0, 0, 0,
; 0, 1, 0 )
;glDisable_(#GL_LIGHTING)
glClearColor_(0, 0, 0, 0)
yrot.f+1
glRotatef_(yrot,0.0,1.0,0.0) ;Rotate On The Y Axis By yrot
glPushMatrix_() ; Save the original Matrix coordinates
glMatrixMode_(#GL_MODELVIEW)
;glTranslatef_(0.0, 0.0, 0.0);
glColor3f_(0.0, 0.6, 0.0)
glutWireTeapot_(0.5)
glColor3f_(1.0, 1.0, 0.0)
;glutWireTorus_(0.3,0.4,12,12)
glScalef_(0.2,0.2,0.2)
glutWireDodecahedron_()
glScalef_(1,1,1)
;glutWireRhombicDodecahedron() ;
;glutWireSierpinskiSponge(int num_levels, const GLdouble offset[ 3 ], GLdouble scale);
;glutWireSierpinskiSponge(3, 4, 1)
glutWireCylinder(2, 2, 8,5);
glPopMatrix_()
glFinish_()
glutSwapBuffers()
EndProcedure
Procedure IdleLoop()
;Debug "Idle"
EndProcedure
this is why i prefer glut since its functions works natively even in openGLgadget (needs glut32.dll look the file links here
http://purebasic.fr/english/viewtopic.p ... 23#p463756).
Code: Select all
OpenWindow(0, 0, 0, 800, 600, "Glut Shapes")
SetWindowColor(0, 0)
OpenGLGadget(0, 0, 0, WindowWidth(0) , WindowHeight(0), #PB_OpenGL_Keyboard )
SetActiveGadget(0)
SetWindowColor(0, 0)
HideWindow(0, #False)
Global yrot.f ;Y Rotation
glClearColor_ (0.0, 0.0, 0.0, 0.0);
glShadeModel_ (#GL_SMOOTH)
glEnable_(#GL_LIGHTING);
glEnable_(#GL_LIGHT0);
glEnable_(#GL_DEPTH_TEST);
Procedure.l DrawGLScene()
glClear_(#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT) ;Clear The Screen And The Depth Buffer
glLoadIdentity_() ;Reset The View
gluLookAt_( 0, 10, 1, ;great explanation for gluLookAt http://www.gamedev.net/topic/211831-can-some-one-post-a-example-of-glulookat/
0, 0, -10,
0, 1, 0 )
glViewport_(0, 0, WindowWidth(0), WindowHeight(0))
glMatrixMode_(#GL_PROJECTION)
glLoadIdentity_()
gluPerspective_(30.0, Abs(WindowWidth(0) / WindowHeight(0)), 0.1, 500.0)
glMatrixMode_(#GL_MODELVIEW)
; viewing transformation
glTranslatef_(0.0, 0.0, -10.0);
glPushMatrix_() ; Save the original Matrix coordinates
;glMatrixMode_(#GL_MODELVIEW)
glClear_ (#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)
glDisable_(#GL_LIGHTING)
glRotatef_(angle, 0.0, 1.0, 0.0)
glScalef_(0.4,0.4,0.4)
glBegin_(#GL_TRIANGLES) ; start drawing a triangle
glColor3f_(1.0, 0.0, 0.0);
glVertex3f_( 0.0, 1.0, 0.0) ; top
glColor3f_(0.0, 1.0, 0.0);
glVertex3f_(-1.0,-1.0, 0.0) ; bottom left
glColor3f_(0.0, 0.0, 1.0);
glVertex3f_( 1.0,-1.0, 0.0) ; bottom right
glEnd_() ; finished
glPopMatrix_()
yrot+0.5
glRotatef_(yrot,0.0,1.0,0.0) ;Rotate On The Y Axis By yrot
glColor3f_(1.0, 0.0, 1.0)
glutWireDodecahedron_()
glColor3f_(0.0, 0.6, 0.0)
glutWireIcosahedron_()
glPushMatrix_()
glTranslatef_(2.0, 0.0, -2.0);
glutWireTeapot_(1)
glPopMatrix_()
glPushMatrix_()
glColor3f_(0.6, 0.6, 0.0)
glTranslatef_(-3.0, 0.0, 0.0);
glutWireTorus_(0.3,0.8,16,16);
glPopMatrix_()
ProcedureReturn #True ;Keep Going
EndProcedure
Repeat
Event = WindowEvent()
If Event = #PB_Event_Gadget And EventGadget() = 0
If EventType() = #PB_EventType_KeyDown
key = GetGadgetAttribute(0,#PB_OpenGL_Key )
Select key
Case #PB_Shortcut_Up
;some sode
Case #PB_Shortcut_Escape
quit = 1
EndSelect
EndIf
EndIf
DrawGLScene()
SetGadgetAttribute(0, #PB_OpenGL_FlipBuffers, #True)
Delay(2)
Until quit = 1 Or Event = #PB_Event_CloseWindow
End