-=:: FBSL ::=-

(C)2001-2010 by Gerome GUILLEMIN, Mehdi BOUAZIZ and Mike LOBANOVSKY
It is currently Wed Sep 08, 2010 2:34 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 13 posts ] 
Author Message
 Post subject: OpenGL Apps Made Easy (Skeleton OGLApp Class)
PostPosted: Sun Feb 07, 2010 12:25 am 
Offline
FBSL Administrator
FBSL Administrator
User avatar

Joined: Tue Apr 19, 2005 7:22 am
Posts: 890
This is a very early version of an OpenGL application class that resembles simple OpenGL windows created by GLUT libraries.

It will be developed further to include more functionality like e.g. simplified message handling, primarily to deal with mouse and keyboard events.

But even now you can see that writing OGL applications may be almost as easy as writing console programs. For example, the classical colored triangle example needs only the following code:
Code:
#Uses "@|WIN32"
#Option Strict

#Include "COGLTestApp.inc"

Dim TestApp As New COGLTestApp("OpenGL Test Bench", AddressOf Render)
Center(TestApp.hWnd())
Show(TestApp.hWnd())
TestApp.Run()

Sub Render()
   glBegin(GL_TRIANGLES)
      glColor3d(1.0, 0.0, 0.0)
      glVertex2i(0, 1)
      glColor3d(0.0, 1.0, 0.0)
      glVertex2i(-1, -1)
      glColor3d(0.0, 0.0, 1.0)
      glVertex2i(1, -1)
   glEnd()
End Sub


Mike :)


Attachments:
File comment: OpenGL Demo 1
OGLApp.zip [7.78 KiB]
Downloaded 12 times

_________________
Mike
(2.2GHz Intel Core2 Duo w/ 4GB RAM, GeForce 8600 w/ 1GB VRAM, Windows XP Pro Russian Sp3)
Top
 Profile  
 
 Post subject: Re: OpenGL Apps Made Easy (Skeleton OGLApp Class)
PostPosted: Sun Feb 07, 2010 3:30 am 
Offline
FBSL Administrator
FBSL Administrator
User avatar

Joined: Sat Mar 12, 2005 8:06 pm
Posts: 2877
Location: Paris -- France
Hello Mike,

XTra nice Class !!!
Very useful and reusable !
Thanks :)

_________________
Yours,

(¯`·._.·[Gerome GUILLEMIN]·._.·´¯)
:: Full SETUP w. HELP 07th of September 2010 ::
http://gedd123.free.fr/FBSLv3.exe [3.4.0.7]
http://gedd123.free.fr/FBSLv3bin.zip [minimal]
Laissons les jolies femmes aux hommes sans imagination. / Let us leave pretty women to men without imagination.(M.Proust)
The success is a defeat for the one who does not want to dance any more! (H.F. Thiefaine)


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 07, 2010 1:10 pm 
Offline
FBSL geek
FBSL geek
User avatar

Joined: Sun Oct 29, 2006 3:22 pm
Posts: 284
Location: France (Nord)
Thanks Mike :)

But I've a little question about 'OGLTestBench.fbs' :
Why the background (behind the triangle) is continually flashing with strange things ... on my PC (Win XP/SP3).

Image
:?

_________________
> B e r t r a n d <


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 07, 2010 1:22 pm 
Offline
FBSL Administrator
FBSL Administrator
User avatar

Joined: Sat Mar 12, 2005 8:06 pm
Posts: 2877
Location: Paris -- France
taobert wrote:
Thanks Mike :)

But I've a little question about 'OGLTestBench.fbs' :
Why the background (behind the triangle) is continually flashing with strange things ... on my PC (Win XP/SP3).

Image
:?


Taobert,

And about :
- your CPU ? 64 or 32 bits ?
- your video card ? RAM ?
- your screen resolution ? 32k, 24k, 16k or 256 colors ?

_________________
Yours,

(¯`·._.·[Gerome GUILLEMIN]·._.·´¯)
:: Full SETUP w. HELP 07th of September 2010 ::
http://gedd123.free.fr/FBSLv3.exe [3.4.0.7]
http://gedd123.free.fr/FBSLv3bin.zip [minimal]
Laissons les jolies femmes aux hommes sans imagination. / Let us leave pretty women to men without imagination.(M.Proust)
The success is a defeat for the one who does not want to dance any more! (H.F. Thiefaine)


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 07, 2010 2:36 pm 
Offline
FBSL geek
FBSL geek
User avatar

Joined: Sun Oct 29, 2006 3:22 pm
Posts: 284
Location: France (Nord)
Gerome wrote:
And about :
- your CPU ? 64 or 32 bits ?
- your video card ? RAM ?
- your screen resolution ? 32k, 24k, 16k or 256 colors ?

Sorry, I've forgotten :oops:

- MS Windows XP Home 32-bit SP3
- CPU Intel Celeron 331 2.66GHz
- RAM 1.3GB Dane-Elec Single-Channel DDR @ 133MHz 2.5-3-3-6
- Intel 82865G Graphics Controller, memory 96MB
- Screen : 1280x768, 32 bits per pixel, 60MHz

:)

_________________
> B e r t r a n d <


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 07, 2010 2:36 pm 
Offline
FBSL Administrator
FBSL Administrator
User avatar

Joined: Sat Nov 24, 2007 3:33 pm
Posts: 316
Location: France
just try this one :
i think it could be just a needed call to the glclear function

Code:
'==================================================================
' Simple demo of COGLTestApp usage
'==================================================================

#Uses "@|WIN32"
#Option Strict

' All OpenGL defines are also loaded via this include file.
#Include "COGLTestApp.inc"

' This creates an invisible OpenGL-ready window.
Dim TestApp As New COGLTestApp("OpenGL Test Bench", AddressOf Render)

' This positions and shows it on the screen. Other global declaration and
' initialization code should also go in here -- BEFORE the TestApp window's
' main loop is set off by TestApp.Run().
Center(TestApp.hWnd())
Show(TestApp.hWnd())
glclearColor(!0,!0,!0,!1.0)
' This triggers TestApp's main loop. NO CODE FOLLOWING THIS COMMAND will be
' executed UNTIL AFTER TestApp's window is destroyed by clicking its X button.
TestApp.Run()
'==================================================================
' Any app termination code may follow, but this app ends here... :)
'==================================================================

' This is the main rendering subproc whose entry point is passed to the
' TestApp object at its creation time. The actual name is irrelevant
' since it's referenced in the class code only by its entry point.
Sub Render()
glClear(GL_COLOR_BUFFER_BIT BOr GL_DEPTH_BUFFER_BIT)
   glBegin(GL_TRIANGLES)
      glColor3d(1.0, 0.0, 0.0)
      glVertex2i(0, 1)
      glColor3d(0.0, 1.0, 0.0)
      glVertex2i(-1, -1)
      glColor3d(0.0, 0.0, 1.0)
      glVertex2i(1, -1)
   glEnd()
End Sub

_________________
_-=<(¯`·._.·[ CodeMan ]·._.·´¯)>=-_
Your only limit : Your imagination

FBSL V3 TESTED On :
Image

Chris (2.0GHz AMD Atlon 64 X2 3800+ w/ 4GB RAM, GeForce 9600GT w/ 1GB VRAM, Windows Vista Home Premium Fr)


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 07, 2010 2:40 pm 
Offline
FBSL geek
FBSL geek
User avatar

Joined: Sun Oct 29, 2006 3:22 pm
Posts: 284
Location: France (Nord)
Yes, it works !
A plain black background ...
Thanks Codeman
:D

_________________
> B e r t r a n d <


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 07, 2010 6:55 pm 
Offline
FBSL Administrator
FBSL Administrator
User avatar

Joined: Tue Apr 19, 2005 7:22 am
Posts: 890
taobert wrote:
Yes, it works !
A plain black background ...
Thanks Codeman
:D


Bert, can you do me a favor?

Please don't use Codeman's suggestion (use the initial script) BUT:
- in between lines 77 and 78 of COGLTestApp.inc please insert the following line: "Wc.hbrBackground = 19"
- run the script and tell me if this paints the background in black.

Under my XP SP3, this line isn't necessary. It adds a black background brush to the newly created window but, since background erasure is suppressed by
Code:
Case WM_ERASEBKGND
    Return 1

my assumption was that I won't need any background brush for this window at all.

So please check if this helps (without Codeman's amendment), will you?

Thanks,

Mike :)

_________________
Mike
(2.2GHz Intel Core2 Duo w/ 4GB RAM, GeForce 8600 w/ 1GB VRAM, Windows XP Pro Russian Sp3)


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 07, 2010 9:02 pm 
Offline
FBSL geek
FBSL geek
User avatar

Joined: Sun Oct 29, 2006 3:22 pm
Posts: 284
Location: France (Nord)
Mike Lobanovsky wrote:
Bert, can you do me a favor?

Please don't use Codeman's suggestion (use the initial script) BUT:
- in between lines 77 and 78 of COGLTestApp.inc please insert the following line: "Wc.hbrBackground = 19"
- run the script and tell me if this paints the background in black.

Under my XP SP3, this line isn't necessary. It adds a black background brush to the newly created window but, since background erasure is suppressed by
Code:
Case WM_ERASEBKGND
    Return 1

my assumption was that I won't need any background brush for this window at all.

So please check if this helps (without Codeman's amendment), will you?

Thanks,

Mike :)

No, unfortunately, this does not paint the background in black. I've a "flashing" background with black stripes scrolling up behind the triangle and sometimes I can even see intermittently some sorts of icons between those jumping black stripes.
:?

_________________
> B e r t r a n d <


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 07, 2010 9:24 pm 
Offline
FBSL geek
FBSL geek
User avatar

Joined: Sat Mar 12, 2005 10:04 pm
Posts: 454
Location: Saskatchewan
I'm seeing the same thing as Taobert. Codeman's amendment works but Mike's doesn't.

_________________
http://bobm01.sasktelwebsite.net


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 07, 2010 9:38 pm 
Offline
FBSL Administrator
FBSL Administrator
User avatar

Joined: Tue Apr 19, 2005 7:22 am
Posts: 890
Thanks guys,

This means that I can safely omit assigning a background brush to the OpenGL window since its operation is suppressed.

I presume Codeman is totally right (anyway he's much better at OpenGL than I am) though the background for me is exactly the same in both cases.

But that's a pre-release version of COGLTestApp anyway, isn't it?.. :D That's what field testing is meant for! :D

Thanks again!

Mike :)
PS: What a pity: adding glClear() reduces FPS by 20 per cent... :(

_________________
Mike
(2.2GHz Intel Core2 Duo w/ 4GB RAM, GeForce 8600 w/ 1GB VRAM, Windows XP Pro Russian Sp3)


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 07, 2010 11:54 pm 
Offline
FBSL geek
FBSL geek
User avatar

Joined: Sat Mar 12, 2005 10:04 pm
Posts: 454
Location: Saskatchewan
If we always got it perfect on the first try, we wouldn't need a Backspace key. 8)

_________________
http://bobm01.sasktelwebsite.net


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 08, 2010 1:14 pm 
Offline
FBSL Administrator
FBSL Administrator
User avatar

Joined: Sat Nov 24, 2007 3:33 pm
Posts: 316
Location: France
mike> to avoid using glclear on each frame i think you can add double buffering or maybe triple buffering to avoid clearing the backbuffer every frame, i will try to see if i can found an easy sample to explain how it work but i will stuck the fps to the vertical synchro monitor speed so it kill the fps :p

the glclear function just erase the backbuffer hdc to get a clean one to draw the new frame and is simply necessary, it could be added directly in your class render function if you add a function to specify the rgb floats components to use on init...

_________________
_-=<(¯`·._.·[ CodeMan ]·._.·´¯)>=-_
Your only limit : Your imagination

FBSL V3 TESTED On :
Image

Chris (2.0GHz AMD Atlon 64 X2 3800+ w/ 4GB RAM, GeForce 9600GT w/ 1GB VRAM, Windows Vista Home Premium Fr)


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

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 0 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
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group