Pure OpenGL demo. (good looking car rendering)

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
d.j.peters
User
User
Posts: 10
Joined: Sat Dec 10, 2011 7:53 pm

Pure OpenGL demo. (good looking car rendering)

Post 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)
Last edited by d.j.peters on Mon Mar 26, 2012 4:55 pm, edited 1 time in total.
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

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

Post 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/
"Have you tried turning it off and on again ?"
A little PureBasic review
d.j.peters
User
User
Posts: 10
Joined: Sat Dec 10, 2011 7:53 pm

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

Post 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.
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

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

Post by IdeasVacuum »

Nice work Peter! I like the realism of the windscreen glass.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

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

Post 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 :)
"Have you tried turning it off and on again ?"
A little PureBasic review
d.j.peters
User
User
Posts: 10
Joined: Sat Dec 10, 2011 7:53 pm

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

Post 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.
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

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

Post 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
"Have you tried turning it off and on again ?"
A little PureBasic review
User avatar
Guimauve
Enthusiast
Enthusiast
Posts: 742
Joined: Wed Oct 22, 2003 2:51 am
Location: Canada

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

Post 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
Post Reply