So how do I render something in 3D?

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by halo.

All I want to do is pass a dll a buffer containing objects, subobjects, verts, and tris. Loading the geometry into the bank from a file or from scratch is no problem. I can easily come up with the actual geometry data, I just need to pass it to a DLL and render it. How can I do this?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Danilo.

"Just" write a 3D engine or buy one (there are also
free engines available: http://www.3dengines.de/ )
DirectX, OpenGL, Software, ... you have the choice.

cya,
...Danilo

(registered PureBasic user)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by halo.

I messed around with the OpenGL cube a bit. Mostly just used polygons, since quads are pretty useless for anything except rendering a cube!

Things I notice:
-camera range is way narrow...the object moves out of the z range very easily.
-verts positioned at less than 0 get positioned at 0.

All I need to do is render some polys with textures. I don't even need to use lights, except a single directional vertex light, just to distinguish the faces. I want to be able to build the meshes and position the camera, then render it. Can anyone help me with this? I do a lot of 3D stuff and know exactly what I need, and it would speed things up if someone can fill me in who has messed with this method.

Code: Select all

IncludeFile "OpenGL.pbi"

Global RollAxisX.f
Global RollAxisY.f
Global RollAxisZ.f
Global position.f

Procedure Draw(hdc)

;pre-render stuff
glClear_ (#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)
glEnable_(#GL_LIGHTING)
glEnable_(#GL_LIGHT0)

;set up axes
glPushMatrix_()
glMatrixMode_(#GL_MODELVIEW)
position=position+0.001
glTranslatef_(Sin(position),Cos(position),0)
glRotatef_ (RollAxisZ, 0, 0, 0.001)
RollAxisZ+0.5

;construct mesh
glBegin_  (#GL_POLYGON)
glNormal3f_(0,0,1.0)
glVertex3f_(0.5,0.5,0) 
glVertex3f_(0,0.5,0)
glVertex3f_(0,0,0)
glVertex3f_(0.5,0,0)
glEnd_()

;render
glPopMatrix_()
glFinish_()
SwapBuffers_(hdc)

EndProcedure

hWnd = OpenWindow(0,10,10,300,300,#PB_Window_SystemMenu,"")
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)
glEnable_ (#GL_CULL_FACE)
glViewport_(0,0,WindowWidth-30,WindowHeight-30)

Repeat
  Select WindowEvent()
    Case #PB_EventCloseWindow
      End
    EndSelect
  Draw(hdc)
ForEver

[code]
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by halo.

Guys, if you just show me how to do a few things with the rendering, I can write your 3D engine for you. It's not exactly a mind-boggling task to load meshes and stores them in buffers. I have a lot of experience with this kind of thing, and it would just be helpful if I could get my few simple questions answered so I can move on with this.

I wrote a DLL in PB that performs boolean ops and constructive solid geometry, for loading Quake .map files, and I use it with Blitz. 3D stuff can be done in PB pretty easily...I just need to figure out how to render it.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by traumatic.

What do you mean?

Do you want to know how to use glNormal, glTexCoord, glVertex (you don't need anything more to render models), glBindTexture and learn about vertexarrays/dispalylists or.... what?
You're talking about OpenGL, aren't you?

I'd really like to help you - but I just don't understand!
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by halo.

-camera range is way narrow...the object moves out of the z range very easily. How do I move and rotate the camera, and change the range?

-verts positioned at less than 0 get positioned at 0.

-when building a polygon, are you supposed to use a glbegin() and glend() for each face?

-Are there docs on the GL commands? Is it opengl32.lib I am dealing with?

It appears that PureBasic already has 3D support. It would be a very small step to write a bunch of functions for loading meshes, collision, etc.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by traumatic.
Originally posted by halo

-camera range is way narrow...the object moves out of the z range very easily. How do I move and rotate the camera, and change the range?
you can use glTranslate and glRotate to move the coordinate system or the object. opengl provides functions to choose between modelview and projection/ortho view

doing the clipping and keeping everything the way you want to is part of the 'not mind-boggling task' to write an engine

try glTranslatef(0.0, 0.0, -10.0) to get 'further away' of your object.
-verts positioned at less than 0 get positioned at 0.
that seems to be a bug in purebasic.
setup a variable with your negative value first, then use the variable, in case of the above example do

z.f=-10.0
glTranslatef_(0.0, 0.0, z.f)
that'll do the trick
-when building a polygon, are you supposed to use a glbegin() and glend() for each face?
quoting the OpenGL reference manual (Win32 sdk):

The glBegin and glEnd functions delimit the vertexes that define a primitive or a group of like primitives. The glBegin function accepts a single argument that specifies which of ten ways the vertexes are interpreted.

-Are there docs on the GL commands? Is it opengl32.lib I am dealing with?
opengl32 - yes, most of the time.

reading recommendations:
http://nehe.gamedev.net - great tutorials
http://www.opengl.org/ - official home of opengl

you may also search for the blue and the red book
It appears that PureBasic already has 3D support.
OpenGl implementation. that is
It would be a very small step to write a bunch of functions for loading meshes, collision, etc.
well...
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by halo.

I've done all this **** from scratch already, just not in OpenGL or with PB. I already wrote constructuve solid geometry and boolean ops in PureBasic. Collision isn't that hard, if you set it up right. There are equations that do all the work for you.

How do I extend the camera range? It appears to have a range between -1 and +1. I want to be able to see further-away objects.

I don't need to know how to move an object. I need to know how to move the camera. Is the camera always at 0,0,0, and all coord systems are relative to it? I doubt so very much. How do I move and rotate the camera?

Where are the opengl32 docs? I need an actual link of something to download that is not a part of 100-meg download.

If you want this to happen, help me get this set up.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by halo.

This creates an n-sided polygon. It's easy to add sides and another cap to make a cylinder:

#pi=3.14159265

IncludeFile "OpenGL.pb"
hWnd = OpenWindow(0,10,10,300,300,#PB_Window_SystemMenu,"")

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)
glEnable_ (#GL_CULL_FACE)
glViewport_(0,0,WindowWidth-30,WindowHeight-30)

Global pitch.f
Global yaw.f
Global roll.f
Global position.f

Procedure Draw(hdc)

;pre-render stuff
glClear_ (#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)
glEnable_(#GL_LIGHTING)
glEnable_(#GL_LIGHT0)

;set up axes
glPushMatrix_()
glMatrixMode_(#GL_PROJECTION)
;position=position+0.001
;glTranslatef_(Sin(position),Cos(position),0.0)
;glRotatef_ (roll,0,0,1.0)
;roll+0.5

;construct mesh
glBegin_ (#GL_POLYGON)
x.f=-0.5
y.f=-0.5
z.f=-0.5
glNormal3f_(x,y,1.0)
sides.f=32
For n=0 To sides
angle.f=n
angle=2*#pi*angle/sides
x.f=Cos(angle)*0.75
y.f=Sin(angle)*0.75
glVertex3f_(x,y,0)
Next
glEnd_()

;render
glPopMatrix_()
glFinish_()
SwapBuffers_(hdc)

EndProcedure

Repeat
Select WindowEvent()
Case #PB_EventCloseWindow
End
EndSelect
Draw(hdc)
ForEver
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Danilo.

OpenGL help is in the MS platform SDK (OpenGL.chm).

Code: Select all

IncludeFile "OpenGL.pbi"
 
Structure GLviewInfo
  hWnd.l
  hDC.l
  glContext.l
EndStructure
 
Structure StartGLthread
  ViewNumber.l
  hWnd.l
EndStructure
 
#GLviews = 5
 
Dim Threads.l(#GLviews)
Dim StopThread.l(#GLviews)
 
Dim DrawGLview_RollAxisX.f(#GLviews)
Dim DrawGLview_RollAxisY.f(#GLviews)
Dim DrawGLview_RollAxisZ.f(#GLviews)
Dim DrawGLview_position.f(#GLviews)
Dim DrawGLview_rotatespeed.f(#GLviews)
Dim DrawGLview_circlespeed.f(#GLviews)
Dim DrawGLview_deltatime.f(#GLviews)
Dim DrawGLview_oldmillisecs.f(#GLviews)
Dim DrawGLview_StartTime.l(#GLviews)
 
Dim DrawCube_RollAxisX.f(#GLviews)
Dim DrawCube_RollAxisY.f(#GLviews)
Dim DrawCube_RollAxisZ.f(#GLviews)
Dim DrawCube_RotateSpeedX.f(#GLviews)
Dim DrawCube_RotateSpeedY.f(#GLviews)
Dim DrawCube_RotateSpeedZ.f(#GLviews)
Dim DrawCube_ZoomFactor.f(#GLviews)
Dim DrawCube_deltatime.f(#GLviews)
Dim DrawCube_oldmillisecs.f(#GLviews)
 
Dim GL_ViewWindow.GLviewInfo(#GLviews) ; How many GLviews ??
 
 
Procedure SetupGLWindow(ViewNumber,Window)
Shared GL_ViewWindow
 pfd.PIXELFORMATDESCRIPTOR 
 hdc = GetDC_(Window)
 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) 
 GL_ViewWindow(ViewNumber)\hWnd = Window
 GL_ViewWindow(ViewNumber)\glContext = hrc
 
 glEnable_ (#GL_CULL_FACE)    ; This will enhance the rendering speed as all the back face will be
                             ; ignored. This works only with CLOSED objects like a cube... Singles
                             ; planes surfaces will be visibles only on one side. 
 
 GetClientRect_(Window,WinSize.RECT)
 
 glViewport_(0,0,WinSize\right,WinSize\bottom)
 ReleaseDC_(Window,hdc)
 wglMakeCurrent_(0,0)
EndProcedure
 
 
 
Procedure DrawGLview_Thread(ViewNumber)
Shared DrawGLview_RollAxisX, DrawGLview_RollAxisY, DrawGLview_RollAxisZ
Shared DrawGLview_position , DrawGLview_circlespeed, DrawGLview_rotatespeed
Shared GL_ViewWindow, DrawGLview_deltatime, DrawGLview_oldmillisecs
Shared DrawGLview_StartTime, StopThread
 
   GL_ViewWindow(ViewNumber)\hDC = GetDC_(GL_ViewWindow(ViewNumber)\hWnd)
   wglMakeCurrent_(GL_ViewWindow(ViewNumber)\hDC,GL_ViewWindow(ViewNumber)\glContext) 
 
Repeat
 DrawGLview_deltatime(ViewNumber) = TimeGetTime_() - DrawGLview_oldmillisecs(ViewNumber)
 DrawGLview_oldmillisecs(ViewNumber) = TimeGetTime_()
 DrawGLview_StartTime(ViewNumber) = TimeGetTime_()
 
 
 
   ;pre-render stuff 
   glClear_ (#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT) 
   glEnable_(#GL_LIGHTING) 
   glEnable_(#GL_LIGHT0)
 
   ;set up axes 
   glPushMatrix_() 
   glMatrixMode_(#GL_MODELVIEW) 
   DrawGLview_position(ViewNumber) = DrawGLview_position(ViewNumber)+DrawGLview_circlespeed(ViewNumber)+(DrawGLview_deltatime(ViewNumber)/1000)
   glTranslatef_(Sin(DrawGLview_position(ViewNumber)),Cos(DrawGLview_position(ViewNumber)),0) 
   glRotatef_ (DrawGLview_RollAxisZ(ViewNumber), 0, 0, 0.001) 
   DrawGLview_RollAxisZ(ViewNumber)+DrawGLview_rotatespeed(ViewNumber)+(DrawGLview_deltatime(ViewNumber)/1000)
 
   ;construct mesh 
   glBegin_ (#GL_POLYGON) 
   glNormal3f_(0,0,1.0) 
   glVertex3f_(0.5,0.5,0) 
   glVertex3f_(0,0.5,0) 
   glVertex3f_(0,0,0) 
   glVertex3f_(0.5,0,0) 
   glEnd_()
    
   ;render 
   glPopMatrix_() 
   glFinish_() 
   SwapBuffers_(GL_ViewWindow(ViewNumber)\hDC)
   ;ReleaseDC_(GL_ViewWindow(ViewNumber)\hWnd,GL_ViewWindow(ViewNumber)\hDC)
    
   While TimeGetTime_() - DrawGLview_StartTime(ViewNumber) < 40: Sleep_(1):Wend ; 1000ms / 25 frames = 40
Until StopThread(ViewNumber) = 1
; End of thread
ReleaseDC_(GL_ViewWindow(ViewNumber)\hWnd,GL_ViewWindow(ViewNumber)\hDC)
StopThread(ViewNumber) = 0
EndProcedure
 
 
Procedure Start_DrawGLview(ViewNum,hWnd)
      SetupGLWindow(ViewNum,hWnd)
      Threads(ViewNum) = CreateThread(@DrawGLview_Thread(),ViewNum)
EndProcedure
 
 
Procedure DrawCube_Thread(ViewNumber)
Shared GL_ViewWindow, StopThread
Shared DrawCube_RollAxisX, DrawCube_RollAxisY, DrawCube_RollAxisZ
Shared DrawCube_RotateSpeedX, DrawCube_RotateSpeedY, DrawCube_RotateSpeedZ
Shared DrawCube_ZoomFactor
 
  GL_ViewWindow(ViewNumber)\hDC = GetDC_(GL_ViewWindow(ViewNumber)\hWnd)
  wglMakeCurrent_(GL_ViewWindow(ViewNumber)\hDC,GL_ViewWindow(ViewNumber)\glContext) 
 
Repeat
 DrawCube_deltatime(ViewNumber) = TimeGetTime_() - DrawCube_oldmillisecs(ViewNumber)
 DrawCube_oldmillisecs(ViewNumber) = TimeGetTime_()
 DrawGLview_StartTime(ViewNumber) = TimeGetTime_()
 
  glPushMatrix_()                  ; Save the original Matrix coordinates
  glMatrixMode_(#GL_MODELVIEW)
 
  ;glTranslatef_(0, 0, DrawCube_ZoomFactor(ViewNumber))  ;  move it forward a bit
 
  glRotatef_ (DrawCube_RollAxisX(ViewNumber), 1.0, 0, 0) ; rotate around X axis
  glRotatef_ (DrawCube_RollAxisY(ViewNumber), 0, 1.0, 0) ; rotate around Y axis
  glRotatef_ (DrawCube_RollAxisZ(ViewNumber), 0, 0, 1.0) ; rotate around Z axis
  
  DrawCube_RollAxisX(ViewNumber) + DrawCube_RotateSpeedX(ViewNumber) +(DrawCube_deltatime(ViewNumber)/1000)
  DrawCube_RollAxisY(ViewNumber) + DrawCube_RotateSpeedY(ViewNumber) +(DrawCube_deltatime(ViewNumber)/1000)
  DrawCube_RollAxisZ(ViewNumber) + DrawCube_RotateSpeedZ(ViewNumber) +(DrawCube_deltatime(ViewNumber)/1000)
 
  ; clear framebuffer And depth-buffer
 
  glClear_ (#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)
 
  ; draw the faces of a cube
   
  ; draw colored faces
 
  glDisable_(#GL_LIGHTING)
  glBegin_  (#GL_QUADS)
   
  ; Build a face, composed of 4 vertex ! 
  ; glBegin() specify how the vertexes are considered. Here a group of
  ; 4 vertexes (GL_QUADS) form a rectangular surface.
 
  ; Now, the color stuff: It's r,v,b but with float values which
  ; can go from 0.0 To 1.0 (0 is .. zero And 1.0 is full intensity) 
   
  glNormal3f_ (0,0,1.0)
  glColor3f_  (0,0,1.0)
  glVertex3f_ (0.5,0.5,0.5)   
  glColor3f_  (0,1.0,1.0)         
  glVertex3f_ (-0.5,0.5,0.5)
  glColor3f_  (1.0,1.0,1.0)
  glVertex3f_ (-0.5,-0.5,0.5)
  glColor3f_  (0,0,0)
  glVertex3f_ (0.5,-0.5,0.5) 
 
  ; The other face is the same than the previous one 
  ; except the colour which is nice blue To white gradiant
 
  glNormal3f_ (0,0,-1.0)
  glColor3f_  (0,0,1.0)
  glVertex3f_ (-0.5,-0.5,-0.5)
  glColor3f_  (0,0,1.0)
  glVertex3f_ (-0.5,0.5,-0.5)
  glColor3f_  (1.0,1.0,1.0)
  glVertex3f_ (0.5,0.5,-0.5)
  glColor3f_  (1.0,1.0,1.0)
  glVertex3f_ (0.5,-0.5,-0.5)
   
  glEnd_()
   
  ; draw shaded faces
 
  glEnable_(#GL_LIGHTING)
  glEnable_(#GL_LIGHT0)
  glBegin_ (#GL_QUADS)
 
  glNormal3f_ (   0, 1.0,   0)
  glVertex3f_ ( 0.5, 0.5, 0.5)
  glVertex3f_ ( 0.5, 0.5,-0.5)
  glVertex3f_ (-0.5, 0.5,-0.5)
  glVertex3f_ (-0.5, 0.5, 0.5)
 
  glNormal3f_ (0,-1.0,0)
  glVertex3f_ (-0.5,-0.5,-0.5)
  glVertex3f_ (0.5,-0.5,-0.5)
  glVertex3f_ (0.5,-0.5,0.5)
  glVertex3f_ (-0.5,-0.5,0.5)
 
  glNormal3f_ (1.0,0,0)
  glVertex3f_ (0.5,0.5,0.5)
  glVertex3f_ (0.5,-0.5,0.5)
  glVertex3f_ (0.5,-0.5,-0.5)
  glVertex3f_ (0.5,0.5,-0.5)
 
  glNormal3f_ (-1.0,   0,   0)
  glVertex3f_ (-0.5,-0.5,-0.5)
  glVertex3f_ (-0.5,-0.5, 0.5)
  glVertex3f_ (-0.5, 0.5, 0.5)
  glVertex3f_ (-0.5, 0.5,-0.5)
 
  glEnd_()
 
  glPopMatrix_()
  glFinish_()
 
  SwapBuffers_(GL_ViewWindow(ViewNumber)\hDC)
  While TimeGetTime_() - DrawGLview_StartTime(ViewNumber) < 40: Sleep_(1):Wend ; 1000ms / 25 frames = 40
Until StopThread(ViewNumber) = 1
; End of thread
ReleaseDC_(GL_ViewWindow(ViewNumber)\hWnd,GL_ViewWindow(ViewNumber)\hDC)
StopThread(ViewNumber) = 0
EndProcedure
 
 
Procedure Start_DrawCube(ViewNum,hWnd)
      SetupGLWindow(ViewNum,hWnd)
      Threads(ViewNum) = CreateThread(@DrawCube_Thread(),ViewNum)
EndProcedure
 
 
Procedure.l OpenGLview(number,x,y,width,height)
   ;
   ; Open child window for OpenGL
   ;
   #GL_Style  = #WS_CHILD|#WS_CLIPSIBLINGS|#WS_CLIPCHILDREN|#WS_VISIBLE|#WS_BORDER
   #GL_XStyle = #WS_EX_OVERLAPPEDWINDOW
   Shared OpenGLview_MainWnd.l, OpenGLview_hInstance
 
 
   !EXTERN _PB_Window_Current
   !MOV dword EAX, [_PB_Window_Current]
   !MOV dword [v_OpenGLview_MainWnd], EAX    ; Get current Window ( UseWindow() )
   !MOV dword EAX, [_PB_Instance]
   !MOV dword [v_OpenGLview_hInstance], EAX  ; Get application instance
 
 
   class$ = "OpenGLview_"+Str(number)
 
 
   wc.WNDCLASSEX
   wc\cbSize        = SizeOf(WNDCLASSEX)
   wc\style         = 0
   wc\lpfnWndProc   = GetWindowLong_(OpenGLview_MainWnd,#GWL_WNDPROC) 
   wc\cbClsExtra    = 0 
   wc\cbWndExtra    = 0 
   wc\hInstance     = OpenGLview_hInstance
   wc\hIcon         = 0 
   wc\hCursor       = LoadCursor_(0, #IDC_CROSS)  ; #IDC_ARROW   = Arrow
                                                  ; #IDC_SIZEALL = Size Arrow
                                                  ; #IDC_CROSS   = Cross
   wc\hbrBackground = CreateSolidBrush_(RGB($8F,$8F,$8F))
   wc\lpszMenuName  = 0
   wc\lpszClassName = @class$
   wc\hIconSm       = 0
   RegisterClassEx_(@wc)
 
 
   ProcedureReturn CreateWindowEx_( #GL_XStyle,class$,"",#GL_Style,x,y,width,height,OpenGLview_MainWnd,0,OpenGLview_hInstance,0)
EndProcedure
 
 
Procedure Stop_Threads()
   For a = 1 To #GLviews
       StopThread(a) = 1
   Next a
   Delay(100)
EndProcedure
 
 
 
 
;-------------------------
;-------------------------
;     START
;-------------------------
;-------------------------
MainWnd.l = OpenWindow( 0,400,400,420,420,#PB_Window_SystemMenu,"OpenGL viewer" ) 
 
; Open GL windows
view1 = OpenGLview(1, 10, 10,200,200):
        : DrawGLview_rotatespeed(1) = 3.33
        : DrawGLview_circlespeed(1) = 0.02
 
view2 = OpenGLview(2,210, 10,200,200):
        : DrawCube_RotateSpeedX(2) = 5.0   ; The speed of the rotation For the 3 axis
        : DrawCube_RotateSpeedY(2) = 5.0
        : DrawCube_RotateSpeedZ(2) = 5.0
        ;: DrawCube_ZoomFactor(2) = 0       ; Distance of the camera. Negative value = zoom back
 
view3 = OpenGLview(3, 10,210,200,200):
        : DrawCube_RotateSpeedX(3) = 15.0   ; The speed of the rotation For the 3 axis
        : DrawCube_RotateSpeedY(3) = 10.3
        : DrawCube_RotateSpeedZ(3) = 12.12
        ;: DrawCube_ZoomFactor(3) = 0       ; Distance of the camera. Negative value = zoom back
 
view4 = OpenGLview(4,210,210,200,200):
        : DrawGLview_rotatespeed(4) = 10.31
        : DrawGLview_circlespeed(4) = 0.1
 
 
;While WindowEvent():Wend
Start_DrawGLview(1,view1)
Start_DrawCube(2,view2)
Start_DrawCube(3,view3)
Start_DrawGLview(4,view4)
 
Repeat 
  Select WaitWindowEvent(): 
     Case #PB_EventCloseWindow
          Stop_Threads():End
  EndSelect
  ;Delay(1)
ForEver



cya,
...Danilo

(registered PureBasic user)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by halo.

That example doesn't appear to do anything the original cube doesn't. I tried moving the cube back, and it appears that there is no perspective. The renderings are just orthogonal, which isn't 3D at all.

Can you show me an example of an actual perspective view, i.e. objects getting smaller as they move away?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by halo.

Can't find any docs or SDK. I just downloaded an opengl thing that turnes out to be just a bunch of C and some DLL's, no docs.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by traumatic.
Originally posted by halo

Can't find any docs or SDK.
do you actually read what other people post?

well, my last try:

get the redbook here: http://ask.ii.uib.no/ebt-bin/nph-dweb/d ... OpenGL_PG/
(opengl.org / documentation / specs & manual pages)

and read the tutorials by nehe - you'll know almost everything about opengl afterwards
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by halo.

I was talking about the MS opengl32.lib documentation. I prefer to get information from the primary source, but that tutorial may be useful as well. If anyone could track down the MS docs, I'd appreciate it.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Paul.
I prefer to get information from the primary source... If anyone could track down the MS docs, I'd appreciate it.
Hmm, then why haven't you visited the Microsoft site yet??
Download the Microsoft Platform SDK, it contains everything you will ever need for API specific stuff.
Yes... all OpenGL is in there as well !!
(Danilo has already told you this)

http://www.microsoft.com/msdownload/pla ... sdkupdate/

*By the way, someone has already started an OpenGL 3D engine in ASM, the libraries are available on the Resources Site
Post Reply