It is currently Fri May 24, 2013 4:09 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Pure OpenGL demo. (good looking car rendering)
PostPosted: Mon Mar 26, 2012 2:01 am 
Offline
User
User

Joined: Sat Dec 10, 2011 7:53 pm
Posts: 10
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:
*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:
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.

Top
 Profile  
 
 Post subject: Re: Pure OpenGL demo. (good looking car rendering)
PostPosted: Mon Mar 26, 2012 11:02 am 
Offline
Addict
Addict
User avatar

Joined: Wed Aug 31, 2005 11:09 pm
Posts: 2240
Location: Italy
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/

_________________
[ Home ] [ My PC ] [ New to PB ? ]


Top
 Profile  
 
 Post subject: Re: Pure OpenGL demo. (good looking car rendering)
PostPosted: Mon Mar 26, 2012 5:06 pm 
Offline
User
User

Joined: Sat Dec 10, 2011 7:53 pm
Posts: 10
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.


Top
 Profile  
 
 Post subject: Re: Pure OpenGL demo. (good looking car rendering)
PostPosted: Mon Mar 26, 2012 6:03 pm 
Offline
Addict
Addict

Joined: Fri Oct 23, 2009 2:33 am
Posts: 2862
Location: Wales, UK
Nice work Peter! I like the realism of the windscreen glass.

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
 
 Post subject: Re: Pure OpenGL demo. (good looking car rendering)
PostPosted: Mon Mar 26, 2012 7:11 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Aug 31, 2005 11:09 pm
Posts: 2240
Location: Italy
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 :)

_________________
[ Home ] [ My PC ] [ New to PB ? ]


Top
 Profile  
 
 Post subject: Re: Pure OpenGL demo. (good looking car rendering)
PostPosted: Mon Mar 26, 2012 8:14 pm 
Offline
User
User

Joined: Sat Dec 10, 2011 7:53 pm
Posts: 10
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.


Top
 Profile  
 
 Post subject: Re: Pure OpenGL demo. (good looking car rendering)
PostPosted: Mon Mar 26, 2012 8:19 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Aug 31, 2005 11:09 pm
Posts: 2240
Location: Italy
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

_________________
[ Home ] [ My PC ] [ New to PB ? ]


Top
 Profile  
 
 Post subject: Re: Pure OpenGL demo. (good looking car rendering)
PostPosted: Fri Jul 27, 2012 8:40 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Oct 22, 2003 2:51 am
Posts: 734
Location: Canada
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:
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye