OpenGL?
-
- Always Here
- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: OpenGL?
If you outline what you wish to do, somebody on this forum should be able to help you. If you search the forum, there are a number of posts about OpenGL.
OpenGL Example
OpenGL Example
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: OpenGL?
What exactly is your 'coding question'?Swos2009 wrote:I did love learn OpenGl but one things put me off is that there is no Documents or Example or Tutorials for OpenGL.

Re: OpenGL?
I want to learn more about OpenGL as I love the rotation of 3D which make look so easy instead of coding lots of Maths to do it!What exactly is your 'coding question'?
I start move round the triangles but why it is slow?
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
OpenWindow(0, 270, 100, 640, 480, "Cross-platform OpenGL demo")
SetWindowColor(0, 0)
OpenGLGadget(0, 0, 0, WindowWidth(0) , WindowHeight(0))
Repeat
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)
glLoadIdentity_()
glClear_(#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)
glLoadIdentity_()
glTranslatef_(0.0, 0.0, -8.0)
glColor3f_(1.0, 1.0, 1.0)
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
glBegin_(#GL_TRIANGLES) ; Start drawing a triangle
glColor3f_ ( 1.0, 0.0, 0.0) ; Set top point of triangle to Red
glVertex3f_( 0.0, 1.0, 0.0) ; First point of the triangle
glColor3f_ ( 0.0, 1.0, 0.0) ; Set left point of triangle to Green
glVertex3f_(-1.0, -1.0, 0.0) ; Second point of the triangle
glColor3f_ ( 0.0, 0.0, 1.0) ; Set right point of triangle to Blue
glVertex3f_( 1.0, -1.0, 0.0) ; Third point of the triangle
glEnd_() ; Done drawing the triangle
SetGadgetAttribute(0, #PB_OpenGL_FlipBuffers, #True)
Until WaitWindowEvent() = #PB_Event_CloseWindow
Re: OpenGL?
Hi,
you simply draw it only when an event happen.
So move always your mouse, or ... (possible without code change
)
remove the Wait from WaitWindowEvent(), or ... (easiest way for your code)
create a thread, or ...
use a timer. (demonstrated below)
Bernd
you simply draw it only when an event happen.
So move always your mouse, or ... (possible without code change

remove the Wait from WaitWindowEvent(), or ... (easiest way for your code)
create a thread, or ...
use a timer. (demonstrated below)
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
Procedure Draw()
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)
glLoadIdentity_()
glClear_(#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)
glLoadIdentity_()
glTranslatef_(0.0, 0.0, -8.0)
glColor3f_(1.0, 1.0, 1.0)
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
glBegin_(#GL_TRIANGLES) ; Start drawing a triangle
glColor3f_ ( 1.0, 0.0, 0.0) ; Set top point of triangle to Red
glVertex3f_( 0.0, 1.0, 0.0) ; First point of the triangle
glColor3f_ ( 0.0, 1.0, 0.0) ; Set left point of triangle to Green
glVertex3f_(-1.0, -1.0, 0.0) ; Second point of the triangle
glColor3f_ ( 0.0, 0.0, 1.0) ; Set right point of triangle to Blue
glVertex3f_( 1.0, -1.0, 0.0) ; Third point of the triangle
glEnd_() ; Done drawing the triangle
SetGadgetAttribute(0, #PB_OpenGL_FlipBuffers, #True)
EndProcedure
Define Event.i
OpenWindow(0, 270, 100, 640, 480, "Cross-platform OpenGL demo")
SetWindowColor(0, 0)
OpenGLGadget(0, 0, 0, WindowWidth(0) , WindowHeight(0))
AddWindowTimer(0, 1, 25)
Repeat
Event = WaitWindowEvent()
If Event = #PB_Event_Timer
If EventTimer() = 1
Draw()
EndIf
EndIf
Until Event = #PB_Event_CloseWindow
Re: OpenGL?
thanks Bernd.
Timer is important to make things smooth
One things bugs me that I try do 3D Cubes by using glBegin(#GL_POLYGON) but I get the error saying it isnt functions....
Timer is important to make things smooth

One things bugs me that I try do 3D Cubes by using glBegin(#GL_POLYGON) but I get the error saying it isnt functions....