More OpenGL stuff
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by halo.
I can't figure out how to convert floats to double floats. I put the double-float lib in userlibraries, but don't know the command...it's not glu32f().
glulookat requires 18 parameters, so obviously the 2xF function must return two values.
Can anyone show me how to do this?
I can't figure out how to convert floats to double floats. I put the double-float lib in userlibraries, but don't know the command...it's not glu32f().
glulookat requires 18 parameters, so obviously the 2xF function must return two values.
Can anyone show me how to do this?
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by halo.
Here is what I am working with. As you can see, the object is completely flat. I am assuming GLULOOKAT will give it some perspective?
#pi=3.14159265
hWnd = OpenWindow(0,10,10,300,300,#PB_Window_SystemMenu,"OpenGL Test")
pfd.PIXELFORMATDESCRIPTOR
hdc = GetDC_(hWnd)
pfd\nSize = SizeOf(PIXELFORMATDESCRIPTOR)
pfd\nVersion = 1
pfd\dwFlags = #PFD_SUPPORT_OPENGL|#PFD_DOUBLEBUFFER|#PFD_DRAW_TO_WINDOW
pfd\dwLayerMask = #PFD_MAIN_PLANE
pfd\iPixelType = #PFD_TYPE_RGBA
pfd\cColorBits = 16
pfd\cDepthBits = 16
SetPixelFormat_(hdc,ChoosePixelFormat_(hdc,pfd),pfd)
hrc=wglCreateContext_(hdc)
wglMakeCurrent_(hdc,hrc)
Global Argc.l
Argc=1
Global Argv.s
Argv=""
glutInit_(@Argc,Argv)
IncludeFile "OpenGL.pbi"
glViewport_(0,0,WindowWidth-30,WindowHeight-30)
;glpolygonmode_ (#gl_front,#gl_line)
;gllinestipple_ (1,255)
glclearcolor_(0,0,1.0,1)
Global x.f
Global y.f
Global z.f
Global pitch.f
Global yaw.f
Global roll.f
Procedure Draw(hdc)
glClear_(#GL_COLOR_BUFFER_BIT|#GL_DEPTH_BUFFER_BIT)
glPushMatrix_()
glMatrixMode_(#GL_PROJECTION)
;glulookat_ (0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0,0)
;glTranslatef_(x.f,y.f,z.f)
glRotatef_ (pitch,1.0,0,0)
glRotatef_ (yaw,0,1.0,0)
glRotatef_ (roll,0,0,1.0)
;pitch+0.1
yaw+0.1
;roll+0.1
x.f=0.5
m.f=-0.5
glEnable_ (#GL_DEPTH_TEST)
glEnable_ (#GL_CULL_FACE)
glEnable_ (#GL_LIGHTING)
glEnable_ (#GL_LIGHT0)
;glEnable_ (#GL_LINE_STIPPLE)
glBegin_ (#GL_POLYGON)
glNormal3f_(0.0,0.0,-1.0)
glVertex3f_(m,x,m)
glVertex3f_(m,m,m)
glVertex3f_(x,m,m)
glVertex3f_(x,x,m)
glEnd_()
glBegin_ (#GL_POLYGON)
glNormal3f_(0.0,0.0,1.0)
glVertex3f_(m,m,x)
glVertex3f_(m,x,x)
glVertex3f_(x,x,x)
glVertex3f_(x,m,x)
glEnd_()
glBegin_ (#GL_POLYGON)
glNormal3f_(-1.0,0.0,0.0)
glVertex3f_(m,m,m)
glVertex3f_(m,x,m)
glVertex3f_(m,x,x)
glVertex3f_(m,m,x)
glEnd_()
glBegin_ (#GL_POLYGON)
glNormal3f_(1.0,0.0,0.0)
glVertex3f_(x,m,x)
glVertex3f_(x,x,x)
glVertex3f_(x,x,m)
glVertex3f_(x,m,m)
glEnd_()
glBegin_ (#GL_POLYGON)
glNormal3f_(0.0,1.0,0.0)
glVertex3f_(x,x,m)
glVertex3f_(x,x,x)
glVertex3f_(m,x,x)
glVertex3f_(m,x,m)
glEnd_()
glBegin_ (#GL_POLYGON)
glNormal3f_(0.0,-1.0,0.0)
glVertex3f_(m,m,m)
glVertex3f_(m,m,x)
glVertex3f_(x,m,x)
glVertex3f_(x,m,m)
glEnd_()
glPopMatrix_()
glFinish_()
SwapBuffers_(hdc)
EndProcedure
Repeat
Select WindowEvent()
Case #PB_EventCloseWindow
End
EndSelect
Draw(hdc)
ForEver
Here is what I am working with. As you can see, the object is completely flat. I am assuming GLULOOKAT will give it some perspective?
#pi=3.14159265
hWnd = OpenWindow(0,10,10,300,300,#PB_Window_SystemMenu,"OpenGL Test")
pfd.PIXELFORMATDESCRIPTOR
hdc = GetDC_(hWnd)
pfd\nSize = SizeOf(PIXELFORMATDESCRIPTOR)
pfd\nVersion = 1
pfd\dwFlags = #PFD_SUPPORT_OPENGL|#PFD_DOUBLEBUFFER|#PFD_DRAW_TO_WINDOW
pfd\dwLayerMask = #PFD_MAIN_PLANE
pfd\iPixelType = #PFD_TYPE_RGBA
pfd\cColorBits = 16
pfd\cDepthBits = 16
SetPixelFormat_(hdc,ChoosePixelFormat_(hdc,pfd),pfd)
hrc=wglCreateContext_(hdc)
wglMakeCurrent_(hdc,hrc)
Global Argc.l
Argc=1
Global Argv.s
Argv=""
glutInit_(@Argc,Argv)
IncludeFile "OpenGL.pbi"
glViewport_(0,0,WindowWidth-30,WindowHeight-30)
;glpolygonmode_ (#gl_front,#gl_line)
;gllinestipple_ (1,255)
glclearcolor_(0,0,1.0,1)
Global x.f
Global y.f
Global z.f
Global pitch.f
Global yaw.f
Global roll.f
Procedure Draw(hdc)
glClear_(#GL_COLOR_BUFFER_BIT|#GL_DEPTH_BUFFER_BIT)
glPushMatrix_()
glMatrixMode_(#GL_PROJECTION)
;glulookat_ (0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0,0)
;glTranslatef_(x.f,y.f,z.f)
glRotatef_ (pitch,1.0,0,0)
glRotatef_ (yaw,0,1.0,0)
glRotatef_ (roll,0,0,1.0)
;pitch+0.1
yaw+0.1
;roll+0.1
x.f=0.5
m.f=-0.5
glEnable_ (#GL_DEPTH_TEST)
glEnable_ (#GL_CULL_FACE)
glEnable_ (#GL_LIGHTING)
glEnable_ (#GL_LIGHT0)
;glEnable_ (#GL_LINE_STIPPLE)
glBegin_ (#GL_POLYGON)
glNormal3f_(0.0,0.0,-1.0)
glVertex3f_(m,x,m)
glVertex3f_(m,m,m)
glVertex3f_(x,m,m)
glVertex3f_(x,x,m)
glEnd_()
glBegin_ (#GL_POLYGON)
glNormal3f_(0.0,0.0,1.0)
glVertex3f_(m,m,x)
glVertex3f_(m,x,x)
glVertex3f_(x,x,x)
glVertex3f_(x,m,x)
glEnd_()
glBegin_ (#GL_POLYGON)
glNormal3f_(-1.0,0.0,0.0)
glVertex3f_(m,m,m)
glVertex3f_(m,x,m)
glVertex3f_(m,x,x)
glVertex3f_(m,m,x)
glEnd_()
glBegin_ (#GL_POLYGON)
glNormal3f_(1.0,0.0,0.0)
glVertex3f_(x,m,x)
glVertex3f_(x,x,x)
glVertex3f_(x,x,m)
glVertex3f_(x,m,m)
glEnd_()
glBegin_ (#GL_POLYGON)
glNormal3f_(0.0,1.0,0.0)
glVertex3f_(x,x,m)
glVertex3f_(x,x,x)
glVertex3f_(m,x,x)
glVertex3f_(m,x,m)
glEnd_()
glBegin_ (#GL_POLYGON)
glNormal3f_(0.0,-1.0,0.0)
glVertex3f_(m,m,m)
glVertex3f_(m,m,x)
glVertex3f_(x,m,x)
glVertex3f_(x,m,m)
glEnd_()
glPopMatrix_()
glFinish_()
SwapBuffers_(hdc)
EndProcedure
Repeat
Select WindowEvent()
Case #PB_EventCloseWindow
End
EndSelect
Draw(hdc)
ForEver
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by MrVainSCL.
Hi halo
I dont know it this would help you...!?
gluCylinderf_,Long,Float,Float,Float,Long,Long
None
gluDiskf_,Long,Float,Float,Long,Long
None
gluLookAtf_,Float,Float,Float,Float,Float,Float,Float,Float,Float
None
gluOrtho2Df_,Float,Float,Float,Float
None
gluPartialDiskf_,Long,Float,Float,Long,Long,Float,Float
None
gluPerspectivef_,Float,Float,Float,Float
None
gluPickMatrixf_,Float,Float,Float,Float,Long
None
gluProjectf_,Float,Float,Float,Float,Float,Long,Float,Float,Float
None
gluSpheref_,Long,Float,Long,Long
None
gluUnProjectf_,Float,Float,Float,Float,Float,Long,Float,Float,Float
None
PIII450, 256MB Ram, 6GB HD, RivaTNT, DirectX8.1, SB AWE64, Win2000 + all Updates...
greetz
MrVainSCL! aka Thorsten
Hi halo
I dont know it this would help you...!?
gluCylinderf_,Long,Float,Float,Float,Long,Long
None
gluDiskf_,Long,Float,Float,Long,Long
None
gluLookAtf_,Float,Float,Float,Float,Float,Float,Float,Float,Float
None
gluOrtho2Df_,Float,Float,Float,Float
None
gluPartialDiskf_,Long,Float,Float,Long,Long,Float,Float
None
gluPerspectivef_,Float,Float,Float,Float
None
gluPickMatrixf_,Float,Float,Float,Float,Long
None
gluProjectf_,Float,Float,Float,Float,Float,Long,Float,Float,Float
None
gluSpheref_,Long,Float,Long,Long
None
gluUnProjectf_,Float,Float,Float,Float,Float,Long,Float,Float,Float
None
PIII450, 256MB Ram, 6GB HD, RivaTNT, DirectX8.1, SB AWE64, Win2000 + all Updates...
greetz
MrVainSCL! aka Thorsten
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by traumatic.
i added some colours to your code so that you can see what's going on. you rendered a totally white cube with lighting turned on without setting up light. all sides of the cubes look identically (black with light, white without light), so you can't see anything '3d'.
have a look at the following mainloop.
i commented some obsolete lines of your code and added the ones with '; !' :
btw.: don't forget glLoadIdentity_() to clear the matrix as you won't want to elt the cube spin faster and faster...
does this help?
no! gluLookAt() only defines the camera's location and orientation.Originally posted by halo
Here is what I am working with. As you can see, the object is completely flat. I am assuming GLULOOKAT will give it some perspective?
i added some colours to your code so that you can see what's going on. you rendered a totally white cube with lighting turned on without setting up light. all sides of the cubes look identically (black with light, white without light), so you can't see anything '3d'.
have a look at the following mainloop.
i commented some obsolete lines of your code and added the ones with '; !' :
btw.: don't forget glLoadIdentity_() to clear the matrix as you won't want to elt the cube spin faster and faster...
Code: Select all
Procedure Draw(hdc)
glClear_(#GL_COLOR_BUFFER_BIT|#GL_DEPTH_BUFFER_BIT)
;glPushMatrix_()
;glMatrixMode_(#GL_PROJECTION)
glLoadIdentity_() ; !
;glulookat_ (0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0,0)
;glTranslatef_(x.f,y.f,z.f)
glRotatef_ (pitch,1.0,0,0)
glRotatef_ (yaw,0,1.0,0)
glRotatef_ (roll,0,0,1.0)
pitch+0.1
yaw+0.6
roll+0.1
x.f=0.5
m.f=-0.5
glEnable_ (#GL_DEPTH_TEST)
glEnable_ (#GL_CULL_FACE)
;glEnable_ (#GL_LIGHTING)
;glEnable_ (#GL_LIGHT0)
;glEnable_ (#GL_LINE_STIPPLE)
glColor3f_(1.0, 1.0, 1.0) ; !
glBegin_ (#GL_POLYGON)
glNormal3f_(0.0,0.0,-1.0)
glVertex3f_(m,x,m)
glVertex3f_(m,m,m)
glVertex3f_(x,m,m)
glVertex3f_(x,x,m)
glEnd_()
glColor3f_(1.0, 0.0, 1.0) ; !
glBegin_ (#GL_POLYGON)
glNormal3f_(0.0,0.0,1.0)
glVertex3f_(m,m,x)
glVertex3f_(m,x,x)
glVertex3f_(x,x,x)
glVertex3f_(x,m,x)
glEnd_()
glColor3f_(1.0, 1.0, 0.0) ; !
glBegin_ (#GL_POLYGON)
glNormal3f_(-1.0,0.0,0.0)
glVertex3f_(m,m,m)
glVertex3f_(m,x,m)
glVertex3f_(m,x,x)
glVertex3f_(m,m,x)
glEnd_()
glColor3f_(1.0, 0.0, 0.0) ; !
glBegin_ (#GL_POLYGON)
glNormal3f_(1.0,0.0,0.0)
glVertex3f_(x,m,x)
glVertex3f_(x,x,x)
glVertex3f_(x,x,m)
glVertex3f_(x,m,m)
glEnd_()
glColor3f_(0.0, 1.0, 0.0) ; !
glBegin_ (#GL_POLYGON)
glNormal3f_(0.0,1.0,0.0)
glVertex3f_(x,x,m)
glVertex3f_(x,x,x)
glVertex3f_(m,x,x)
glVertex3f_(m,x,m)
glEnd_()
glColor3f_(0.0, 0.0, 0.0) ; !
glBegin_ (#GL_POLYGON)
glNormal3f_(0.0,-1.0,0.0)
glVertex3f_(m,m,m)
glVertex3f_(m,m,x)
glVertex3f_(x,m,x)
glVertex3f_(x,m,m)
glEnd_()
;glPopMatrix_()
;glFinish_()
SwapBuffers_(hdc)
EndProcedure
does this help?
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by halo.
Not to be a smart ass, but how would that help? I am trying to render it with perspective, and all you did was color it and rotate it differently. I cut out all the excess stuff I didn't need, because I am trying to get the perspective and glu stuff working.
Not to be a smart ass, but how would that help? I am trying to render it with perspective, and all you did was color it and rotate it differently. I cut out all the excess stuff I didn't need, because I am trying to get the perspective and glu stuff working.
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by halo.
This code produces a perspective view, although something is obviously wrong. The screen is all staticky and flickery:
#pi=3.14159265
hWnd=OpenWindow(0,10,10,300,300,#PB_Window_SystemMenu,"OpenGL Test")
pfd.PIXELFORMATDESCRIPTOR
hdc = GetDC_(hWnd);
pfd\nSize = SizeOf(PIXELFORMATDESCRIPTOR)
pfd\nVersion = 1
pfd\dwFlags = #PFD_SUPPORT_OPENGL|#PFD_DOUBLEBUFFER|#PFD_DRAW_TO_WINDOW
pfd\dwLayerMask = #PFD_MAIN_PLANE
pfd\iPixelType = #PFD_TYPE_RGBA
pfd\cColorBits = 16
pfd\cDepthBits = 16
SetPixelFormat_(hdc,ChoosePixelFormat_(hdc,pfd),pfd)
hrc=wglCreateContext_(hdc)
wglMakeCurrent_(hdc,hrc)
IncludeFile "OpenGL.pbi"
Global Argc.l
Argc=1
Global Argv.s
Argv=""
glutInit_(@Argc,Argv)
glutCreateWindow_("Opening An OpenGL Window")
;glViewport_(0,0,WindowWidth-30,WindowHeight-30)
;glpolygonmode_ (#gl_front,#gl_line)
;glpolygonmode_ (#gl_back,#gl_line)
;gllinestipple_ (1,255)
glclearcolor_(0,0,1.0,1)
Global x.f
Global y.f
Global z.f
Global pitch.f
Global yaw.f
Global roll.f
Procedure Draw(hdc)
glClear_(#GL_COLOR_BUFFER_BIT|#GL_DEPTH_BUFFER_BIT)
;glPushMatrix_()
glMatrixMode_(#GL_PROJECTION)
glLoadIdentity_() ; !
;glulookat_ (0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0,0)
;glTranslatef_(x.f,y.f,z.f)
glRotatef_ (pitch,1.0,0,0)
glRotatef_ (yaw,0,1.0,0)
glRotatef_ (roll,0,0,1.0)
pitch+0.1
yaw+0.6
roll+0.1
x.f=0.5
m.f=-0.5
glEnable_ (#GL_DEPTH_TEST)
glEnable_ (#GL_CULL_FACE)
;glEnable_ (#GL_LIGHTING)
;glEnable_ (#GL_LIGHT0)
;glEnable_ (#GL_LINE_STIPPLE)
glColor3f_(1.0, 1.0, 1.0) ; !
glBegin_ (#GL_POLYGON)
glNormal3f_(0.0,0.0,-1.0)
glVertex3f_(m,x,m)
glVertex3f_(m,m,m)
glVertex3f_(x,m,m)
glVertex3f_(x,x,m)
glEnd_()
glColor3f_(1.0, 0.0, 1.0) ; !
glBegin_ (#GL_POLYGON)
glNormal3f_(0.0,0.0,1.0)
glVertex3f_(m,m,x)
glVertex3f_(m,x,x)
glVertex3f_(x,x,x)
glVertex3f_(x,m,x)
glEnd_()
glColor3f_(1.0, 1.0, 0.0) ; !
glBegin_ (#GL_POLYGON)
glNormal3f_(-1.0,0.0,0.0)
glVertex3f_(m,m,m)
glVertex3f_(m,x,m)
glVertex3f_(m,x,x)
glVertex3f_(m,m,x)
glEnd_()
glColor3f_(1.0, 0.0, 0.0) ; !
glBegin_ (#GL_POLYGON)
glNormal3f_(1.0,0.0,0.0)
glVertex3f_(x,m,x)
glVertex3f_(x,x,x)
glVertex3f_(x,x,m)
glVertex3f_(x,m,m)
glEnd_()
glColor3f_(0.0, 1.0, 0.0) ; !
glBegin_ (#GL_POLYGON)
glNormal3f_(0.0,1.0,0.0)
glVertex3f_(x,x,m)
glVertex3f_(x,x,x)
glVertex3f_(m,x,x)
glVertex3f_(m,x,m)
glEnd_()
glColor3f_(0.0, 0.0, 0.0) ; !
glBegin_ (#GL_POLYGON)
glNormal3f_(0.0,-1.0,0.0)
glVertex3f_(m,m,m)
glVertex3f_(m,m,x)
glVertex3f_(x,m,x)
glVertex3f_(x,m,m)
glEnd_()
;glPopMatrix_()
;glFinish_()
glutswapbuffers_ ()
SwapBuffers_(hdc)
EndProcedure
Repeat
Draw(hdc)
Select WindowEvent()
Case #PB_EventCloseWindow
End
EndSelect
ForEver
This code produces a perspective view, although something is obviously wrong. The screen is all staticky and flickery:
#pi=3.14159265
hWnd=OpenWindow(0,10,10,300,300,#PB_Window_SystemMenu,"OpenGL Test")
pfd.PIXELFORMATDESCRIPTOR
hdc = GetDC_(hWnd);
pfd\nSize = SizeOf(PIXELFORMATDESCRIPTOR)
pfd\nVersion = 1
pfd\dwFlags = #PFD_SUPPORT_OPENGL|#PFD_DOUBLEBUFFER|#PFD_DRAW_TO_WINDOW
pfd\dwLayerMask = #PFD_MAIN_PLANE
pfd\iPixelType = #PFD_TYPE_RGBA
pfd\cColorBits = 16
pfd\cDepthBits = 16
SetPixelFormat_(hdc,ChoosePixelFormat_(hdc,pfd),pfd)
hrc=wglCreateContext_(hdc)
wglMakeCurrent_(hdc,hrc)
IncludeFile "OpenGL.pbi"
Global Argc.l
Argc=1
Global Argv.s
Argv=""
glutInit_(@Argc,Argv)
glutCreateWindow_("Opening An OpenGL Window")
;glViewport_(0,0,WindowWidth-30,WindowHeight-30)
;glpolygonmode_ (#gl_front,#gl_line)
;glpolygonmode_ (#gl_back,#gl_line)
;gllinestipple_ (1,255)
glclearcolor_(0,0,1.0,1)
Global x.f
Global y.f
Global z.f
Global pitch.f
Global yaw.f
Global roll.f
Procedure Draw(hdc)
glClear_(#GL_COLOR_BUFFER_BIT|#GL_DEPTH_BUFFER_BIT)
;glPushMatrix_()
glMatrixMode_(#GL_PROJECTION)
glLoadIdentity_() ; !
;glulookat_ (0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0,0)
;glTranslatef_(x.f,y.f,z.f)
glRotatef_ (pitch,1.0,0,0)
glRotatef_ (yaw,0,1.0,0)
glRotatef_ (roll,0,0,1.0)
pitch+0.1
yaw+0.6
roll+0.1
x.f=0.5
m.f=-0.5
glEnable_ (#GL_DEPTH_TEST)
glEnable_ (#GL_CULL_FACE)
;glEnable_ (#GL_LIGHTING)
;glEnable_ (#GL_LIGHT0)
;glEnable_ (#GL_LINE_STIPPLE)
glColor3f_(1.0, 1.0, 1.0) ; !
glBegin_ (#GL_POLYGON)
glNormal3f_(0.0,0.0,-1.0)
glVertex3f_(m,x,m)
glVertex3f_(m,m,m)
glVertex3f_(x,m,m)
glVertex3f_(x,x,m)
glEnd_()
glColor3f_(1.0, 0.0, 1.0) ; !
glBegin_ (#GL_POLYGON)
glNormal3f_(0.0,0.0,1.0)
glVertex3f_(m,m,x)
glVertex3f_(m,x,x)
glVertex3f_(x,x,x)
glVertex3f_(x,m,x)
glEnd_()
glColor3f_(1.0, 1.0, 0.0) ; !
glBegin_ (#GL_POLYGON)
glNormal3f_(-1.0,0.0,0.0)
glVertex3f_(m,m,m)
glVertex3f_(m,x,m)
glVertex3f_(m,x,x)
glVertex3f_(m,m,x)
glEnd_()
glColor3f_(1.0, 0.0, 0.0) ; !
glBegin_ (#GL_POLYGON)
glNormal3f_(1.0,0.0,0.0)
glVertex3f_(x,m,x)
glVertex3f_(x,x,x)
glVertex3f_(x,x,m)
glVertex3f_(x,m,m)
glEnd_()
glColor3f_(0.0, 1.0, 0.0) ; !
glBegin_ (#GL_POLYGON)
glNormal3f_(0.0,1.0,0.0)
glVertex3f_(x,x,m)
glVertex3f_(x,x,x)
glVertex3f_(m,x,x)
glVertex3f_(m,x,m)
glEnd_()
glColor3f_(0.0, 0.0, 0.0) ; !
glBegin_ (#GL_POLYGON)
glNormal3f_(0.0,-1.0,0.0)
glVertex3f_(m,m,m)
glVertex3f_(m,m,x)
glVertex3f_(x,m,x)
glVertex3f_(x,m,m)
glEnd_()
;glPopMatrix_()
;glFinish_()
glutswapbuffers_ ()
SwapBuffers_(hdc)
EndProcedure
Repeat
Draw(hdc)
Select WindowEvent()
Case #PB_EventCloseWindow
End
EndSelect
ForEver
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Danilo.
This is a procedure from the code i wrote for you:
You see the line "gluPerspectivef_( 80.0, width / height, 0.1, 100.0)" ??
cya,
...Danilo
(registered PureBasic user)
This is a procedure from the code i wrote for you:
Code: Select all
Procedure ReSizeGLScene(width, height)
If height = 0 : height = 1 : EndIf
glViewport_(0,0,width,height)
glMatrixMode_(#GL_Projection)
glLoadIdentity_()
gluPerspectivef_( 80.0, width / height, 0.1, 100.0)
glMatrixMode_(#GL_ModelView)
glLoadIdentity_()
EndProcedurecya,
...Danilo
(registered PureBasic user)
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by halo.
Unfortunately, your demo produces a nice black screen for me. I suspect it is the 24-bit textures. A good general rule with 3D stuff is to go with the lowest-quality options as the default, to ensure compatability, and avoid tons of support emails.
Unfortunately, your demo produces a nice black screen for me. I suspect it is the 24-bit textures. A good general rule with 3D stuff is to go with the lowest-quality options as the default, to ensure compatability, and avoid tons of support emails.
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by traumatic.
Maybe you'd better try a gluPerspective() / modelview combo instead of gl_projection but what can I say.... now you're even mixing up glut with opengl.... Please, either use plain ogl or glut... not both.
Whatever: I'd better give up now since you don't even seem to know the basics of opengl so all of your questions are not pb-related problems and I really don't know how to help you any further except writing the code for you (even this didn't help as it seems also danilo's code wasn't of any use for you)
Please, if you really want to code opengl - try to understand the basics and learn them off by heart.
If all of the official opengl-documentations are too boring for you - read Nehe's tutorials (I know I'm repeating myself here).
If you're having any questions after learning I'll of course be there trying to help you.
No offending intended.
traumatic
I did that to show you that your display already was perspective. you couldn't see anything because it was all black (or white).Originally posted by halo
Not to be a smart ass, but how would that help? I am trying to render it with perspective, and all you did was color it and rotate it differently.
Maybe you'd better try a gluPerspective() / modelview combo instead of gl_projection but what can I say.... now you're even mixing up glut with opengl.... Please, either use plain ogl or glut... not both.
Whatever: I'd better give up now since you don't even seem to know the basics of opengl so all of your questions are not pb-related problems and I really don't know how to help you any further except writing the code for you (even this didn't help as it seems also danilo's code wasn't of any use for you)
Please, if you really want to code opengl - try to understand the basics and learn them off by heart.
If all of the official opengl-documentations are too boring for you - read Nehe's tutorials (I know I'm repeating myself here).
If you're having any questions after learning I'll of course be there trying to help you.
No offending intended.
traumatic
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by traumatic.
Sorry, I forgot to explain why I was talking about 'mixing up glut with opengl':
initpart:
OpenWindow() including pfd-setup etc. is the plain windows-way to setup an opengl rendering context where glutCreateWindow() is the glut-way to open a window and setup required things.
same for mainloop:
glutswapbuffers_() ; glut-way to exchange front and back buffer
SwapBuffers_(hdc) ; pure windows method to achieve the same
you should either use glut and live with the restrictions and speed-loss involved or use plain opengl - it's up to you.
using glutSwapBuffers() and SwapBuffers() one after the other only results in switching from off- to on-screen display twice.
Sorry, I forgot to explain why I was talking about 'mixing up glut with opengl':
initpart:
OpenWindow() including pfd-setup etc. is the plain windows-way to setup an opengl rendering context where glutCreateWindow() is the glut-way to open a window and setup required things.
same for mainloop:
glutswapbuffers_() ; glut-way to exchange front and back buffer
SwapBuffers_(hdc) ; pure windows method to achieve the same
you should either use glut and live with the restrictions and speed-loss involved or use plain opengl - it's up to you.
using glutSwapBuffers() and SwapBuffers() one after the other only results in switching from off- to on-screen display twice.
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by halo.
Trauma, your example is not perspective. It's orthogonal, just from a different angle. Objects in the distance would not appear smaller.
I believe this code does everything properly, and only relies on glut. However, it doesn't display anything for me, and I have no idea why. According to the stuff I have read, it should be working:
IncludeFile "OpenGl.pbi"
Procedure Display()
glClear_(#GL_COLOR_BUFFER_BIT|#GL_DEPTH_BUFFER_BIT)
glMatrixMode_(#GL_ModelView)
glLoadIdentity_()
glBegin_ (#GL_POLYGON)
glNormal3f_(0.0,0.0,-1.0)
glVertex3f_(m,x,m)
glVertex3f_(m,m,m)
glVertex3f_(x,m,m)
glVertex3f_(x,x,m)
glEnd_()
glBegin_ (#GL_POLYGON)
glNormal3f_(0.0,0.0,1.0)
glVertex3f_(m,m,x)
glVertex3f_(m,x,x)
glVertex3f_(x,x,x)
glVertex3f_(x,m,x)
glEnd_()
glBegin_ (#GL_POLYGON)
glNormal3f_(-1.0,0.0,0.0)
glVertex3f_(m,m,m)
glVertex3f_(m,x,m)
glVertex3f_(m,x,x)
glVertex3f_(m,m,x)
glEnd_()
glBegin_ (#GL_POLYGON)
glNormal3f_(1.0,0.0,0.0)
glVertex3f_(x,m,x)
glVertex3f_(x,x,x)
glVertex3f_(x,x,m)
glVertex3f_(x,m,m)
glEnd_()
glBegin_ (#GL_POLYGON)
glNormal3f_(0.0,1.0,0.0)
glVertex3f_(x,x,m)
glVertex3f_(x,x,x)
glVertex3f_(m,x,x)
glVertex3f_(m,x,m)
glEnd_()
glBegin_ (#GL_POLYGON)
glNormal3f_(0.0,-1.0,0.0)
glVertex3f_(m,m,m)
glVertex3f_(m,m,x)
glVertex3f_(x,m,x)
glVertex3f_(x,m,m)
glEnd_()
glutSwapBuffers_()
EndProcedure
Global Argc.l : Argc = 1
Global Argv.s : Argv = ""
glutInit_(@Argc,Argv)
glutInitWindowSize_(200,200 )
glutInitWindowPosition_(100,100)
glutCreateWindow_("OpenGL Test")
glClearColor_(0.0,0.0,1.0,0.0)
glShadeModel_(#GL_FLAT)
glutDisplayFunc_(@Display())
glutMainLoop_()
End
Trauma, your example is not perspective. It's orthogonal, just from a different angle. Objects in the distance would not appear smaller.
I believe this code does everything properly, and only relies on glut. However, it doesn't display anything for me, and I have no idea why. According to the stuff I have read, it should be working:
IncludeFile "OpenGl.pbi"
Procedure Display()
glClear_(#GL_COLOR_BUFFER_BIT|#GL_DEPTH_BUFFER_BIT)
glMatrixMode_(#GL_ModelView)
glLoadIdentity_()
glBegin_ (#GL_POLYGON)
glNormal3f_(0.0,0.0,-1.0)
glVertex3f_(m,x,m)
glVertex3f_(m,m,m)
glVertex3f_(x,m,m)
glVertex3f_(x,x,m)
glEnd_()
glBegin_ (#GL_POLYGON)
glNormal3f_(0.0,0.0,1.0)
glVertex3f_(m,m,x)
glVertex3f_(m,x,x)
glVertex3f_(x,x,x)
glVertex3f_(x,m,x)
glEnd_()
glBegin_ (#GL_POLYGON)
glNormal3f_(-1.0,0.0,0.0)
glVertex3f_(m,m,m)
glVertex3f_(m,x,m)
glVertex3f_(m,x,x)
glVertex3f_(m,m,x)
glEnd_()
glBegin_ (#GL_POLYGON)
glNormal3f_(1.0,0.0,0.0)
glVertex3f_(x,m,x)
glVertex3f_(x,x,x)
glVertex3f_(x,x,m)
glVertex3f_(x,m,m)
glEnd_()
glBegin_ (#GL_POLYGON)
glNormal3f_(0.0,1.0,0.0)
glVertex3f_(x,x,m)
glVertex3f_(x,x,x)
glVertex3f_(m,x,x)
glVertex3f_(m,x,m)
glEnd_()
glBegin_ (#GL_POLYGON)
glNormal3f_(0.0,-1.0,0.0)
glVertex3f_(m,m,m)
glVertex3f_(m,m,x)
glVertex3f_(x,m,x)
glVertex3f_(x,m,m)
glEnd_()
glutSwapBuffers_()
EndProcedure
Global Argc.l : Argc = 1
Global Argv.s : Argv = ""
glutInit_(@Argc,Argv)
glutInitWindowSize_(200,200 )
glutInitWindowPosition_(100,100)
glutCreateWindow_("OpenGL Test")
glClearColor_(0.0,0.0,1.0,0.0)
glShadeModel_(#GL_FLAT)
glutDisplayFunc_(@Display())
glutMainLoop_()
End
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm