Page 1 of 1

Pure OpenGL demo. (good looking car rendering)

Posted: Mon Mar 26, 2012 2:01 am
by d.j.peters
I tryed OpenGL without Engine3D and Sprite 3D.

Here are the result: for Linux and Windows x86 ~11MB zip file (~28MB extracted) source code included.
Download: PureOpenGLDemo.zip

Wold be cool if someone can test it on 64 bit Linux/Windows too.

Thank you

DJ.

PureBasiuc Gtk window as OpenGL render target:

Code: Select all

*X11Display = gdk_x11_get_default_xdisplay_()
hWin = OpenWindow(id, x,y,w,h,title,flags)
If id=#PB_Any
  id=hWin
EndIf
hWin=WindowID(id)
; a missing flush / sync command or something else on my linux box need this wait
Repeat : Delay(100) : Until IsWindow(id)<>0
Protected *Widget.GtkWidget = hWin
Protected *win = *Widget\Window
; X11 window from Gtk window
X11Win = gdk_x11_drawable_get_xid_(*win)
*vi = glXChooseVisual(*X11Display, 0, @attr(0))
hRC = glXCreateContext(*X11Display, *vi, 0,#GL_TRUE)
glXMakeCurrent(*X11Display,X11Win,hRC)
PureBasic native Window as OpenGL render targetz:

Code: Select all

Protected pfd.PIXELFORMATDESCRIPTOR
Protected pf.l
hWin = OpenWindow(id, x,y,w,h,title,flags)
If id=#PB_Any
  id=hWin
EndIf
hWin=WindowID(id)
 
hDC = GetDC_(hWin)
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   = 24
pfd\cDepthBits   = 16
pf = ChoosePixelFormat_(hDC,pfd)
SetPixelFormat_(hDC, pf, pfd)
hRC = wglCreateContext_(hDC)
wglMakeCurrent_(hDC,hRC)

Re: Pure OpenGL demo. (good looking car rendering)

Posted: Mon Mar 26, 2012 11:02 am
by luis
Nice to see some linux native opengl code, good work :)

The demo works under Windows 7 64 bit (exe compiled as 64 bit). Only thing the objects are more near to the viewer when I compile from the source. In the exe you put in the zip the objects are a little more far.

Is this the model format used ? http://www.c3d.org/

Re: Pure OpenGL demo. (good looking car rendering)

Posted: Mon Mar 26, 2012 5:06 pm
by d.j.peters
luis wrote:The demo works under Windows 7 64 bit (exe compiled as 64 bit).
Good to know thank you for testing.
luis wrote:Only thing the objects are more near to the viewer when I compile from the source.
You can set the camera position glTranslatef().
luis wrote:Is this the model format used ? http://www.c3d.org/
No it's my own car 3d format. I can use different models in one file.
Different levels of details, a low poly version for stencil shadow a version with many physical attributes and descriptors for the sound engine.

The cars self are not made by me and only for private use and testing.

DJ.

Re: Pure OpenGL demo. (good looking car rendering)

Posted: Mon Mar 26, 2012 6:03 pm
by IdeasVacuum
Nice work Peter! I like the realism of the windscreen glass.

Re: Pure OpenGL demo. (good looking car rendering)

Posted: Mon Mar 26, 2012 7:11 pm
by luis
d.j.peters wrote:You can set the camera position glTranslatef().
I know, I was reporting that only to let you know the exe and the source were giving two different results :)

Re: Pure OpenGL demo. (good looking car rendering)

Posted: Mon Mar 26, 2012 8:14 pm
by d.j.peters
There are two primary open questions in my mind.

1) does it works without any changes on a 64 bit Linux ?
2) Is a pure basic window on mac a GTK window too ?

DJ.

Re: Pure OpenGL demo. (good looking car rendering)

Posted: Mon Mar 26, 2012 8:19 pm
by luis
d.j.peters wrote: 2) Is a pure basic window on mac a GTK window too ?
It is not, judging from this :

http://www.purebasic.fr/blog/?cat=9

Re: Pure OpenGL demo. (good looking car rendering)

Posted: Fri Jul 27, 2012 8:40 pm
by Guimauve
d.j.peters wrote:There are two primary open questions in my mind.

1) does it works without any changes on a 64 bit Linux ?

DJ.
No it doesn't work as is, I have to change lib import to :

Code: Select all

ImportC "-lGL"
ImportC "-lGLU"
in both "GL.pbi" and "GLU.pbi" to make your code to work on Linux Mint 13 x64. Otherwise everything work fine.

Best regards
Guimauve