it is displayed on my screen the helix ,points,line, circle. my vga card is nvidea Geforce GT 520. try to comment plot(...) since plotting points are heavy task.
but we can (cheat), make your opengl gadget smaller and draw the heavy working things outside the gl area: look this screen:

and here we simulate the Full screen by using openwindow flags
#PB_Window_Maximize | #PB_Window_BorderLess )
but then we need to enable opengl keys so to exit by pressing ESC:
OpenGLGadget(0, 100, 100, 600 , 600,
#PB_OpenGL_Keyboard ); added #PB_OpenGL_Keyboard
SetActiveGadget(0); set opengl gadget as active
then add something like this routine to work with opengl gadget keys:
Code: Select all
If Event = #PB_Event_Gadget And EventGadget() = 0
If EventType() = #PB_EventType_KeyDown
key = GetGadgetAttribute(0,#PB_OpenGL_Key )
Select key
Case #PB_Shortcut_Add; if pressing "+"
;some code
Case #PB_Shortcut_Escape
quit = 1
EndSelect
EndIf
EndIf
i forgot to add the Demivec advice in the previous code
http://www.purebasic.fr/english/viewtop ... 00#p445686
the Demivec advice may be the cure to the line+circle disappearance problem on your computer
Note: me too want to put the glsl shapes inside something like a room, i will think about this later.
Code: Select all
;EnableExplicit
Global RollAxisX.f
Global RollAxisY.f
Global RollAxisZ.f
Global RotateSpeedX.f = 2 ; The speed of the rotation For the 3 axis
Global RotateSpeedY.f = 2
Global RotateSpeedZ.f = 2
Global running = 1
Global angle.f, R.f, t.f, ZoomFactor.f = 1
Global rot.f = 3
Declare.l spiral_render()
ExamineDesktops()
OpenWindow(0, 30, 30, DesktopWidth(0), DesktopHeight(0), "OpenGL demo", #PB_Window_Maximize | #PB_Window_BorderLess )
SetWindowColor(0, RGB(100,100,0))
OpenGLGadget(0, 100, 100, 600 , 600, #PB_OpenGL_Keyboard )
glLineWidth_(3)
SetActiveGadget(0); set opengl gadget as active
Define event, quit
Repeat
Repeat
event = WindowEvent()
If event = #PB_Event_CloseWindow
quit = #True
EndIf
If Event = #PB_Event_Gadget And EventGadget() = 0
If EventType() = #PB_EventType_KeyDown
key = GetGadgetAttribute(0,#PB_OpenGL_Key )
Select key
Case #PB_Shortcut_Add; if pressing "+"
;some code
Case #PB_Shortcut_Escape
quit = 1
EndSelect
EndIf
EndIf
Until event = 0 Or quit = #True
spiral_render()
StartDrawing(WindowOutput(0))
DrawText(200, 110, "hello world")
For y=40 To 80
For x=30 To 70
Plot(x,y,RGB(Random(255), Random(255), Random(255)))
Next
Next
LineXY(300, 10, 300, 500 , RGB(0,255,0))
Circle(100,200, 60, RGB(255,255,0))
StopDrawing()
SetGadgetAttribute(0, #PB_OpenGL_FlipBuffers, #True)
Delay(10)
Until quit = #True
Procedure.l spiral_render()
glPushMatrix_() ; Save the original Matrix coordinates
glMatrixMode_(#GL_MODELVIEW)
;glTranslatef_(0, 0, -120) ; move it forward a bit
glRotatef_ (RollAxisX, 1.0, 0, 0) ; rotate around X axis
glRotatef_ (RollAxisY, 0, 1.0, 0) ; rotate around Y axis
glRotatef_ (RollAxisZ, 0, 0, 1.0) ; rotate around Z axis
RollAxisX + RotateSpeedX
RollAxisY + RotateSpeedY
RollAxisZ + RotateSpeedZ
; clear framebuffer And depth-buffer
glClear_ (#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)
glDisable_(#GL_LIGHTING)
glClear_(#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT) ;Clear The Screen And The Depth Buffer
glLoadIdentity_() ;Reset The View
glViewport_(0, 0, WindowWidth(0), WindowHeight(0))
glMatrixMode_(#GL_PROJECTION)
glLoadIdentity_()
;gluPerspective_(90.0, Abs(WindowWidth(0) / WindowHeight(0)), 0.1, 1000.0)
glFrustum_(-10.0, 10.0, -10.0, 10.0, 10.0, 1000.0);
R.f = 30.0; // Radius of helix.
t.f = -10*#PI; // Angle parameter along helix.
glClear_(#GL_COLOR_BUFFER_BIT);
glColor3f_(1.0, 0.7, 0.0);
glPushMatrix_();
;The Trick: To align the axis of the helix along the y-axis prior To rotation
;And then Return it To its original location.
glTranslatef_(-30.0, 0.0, -120);
glRotatef_(angle, 1, 1, 1);
glTranslatef_(0.0, 0.0, 60.0);
;glPointSize_(5);
angle.f + rot
glBegin_(#GL_LINE_STRIP);
;glBegin_(#GL_POINTS);
While t <= 10 * #PI
glVertex3f_(R * Cos(t), t, R * Sin(t) - 60.0);
t = t+(#PI/40.0)
Wend
glEnd_();
glPopMatrix_();
glFinish_()
EndProcedure