Simple Windowed OpenGL Framework - for OpenGL beginners

Developed or developing a new product in PureBasic? Tell the world about it.
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Simple Windowed OpenGL Framework - for OpenGL beginners

Post by luis »

[Win32, PureBasic 4.02-4.30, OpenGL]

I wrote this simple framework in PB to make experiments while learning OpenGL, maybe some other people starting right now can found it useful to learn how to use OpenGL with PB.

So, what can you learn from this ? (or if you prefer, what did I learn doing this ?)

* how to setup a windowed OpenGL framework
* how to check for errors after calling an OpenGL function
* how to render a scene while switching resolution on the fly
* how to do simple multithreading and event synchronization
* how to check for OpenGL extensions and use them
* how to execute a demo at the same speed with VSync enabled at 60 Hz (60 FPS) and with VSync disabled drawing at 250 FPS (for example)
* how to count the number of FPS your application is rendering
* how to separate every demo from the framework code, coding it in a dedicated include file
* how to enable multisample to do full scene antialiasing
* how to render some nice text in 3d (not using fixed bitmaps)
* how to grab a texture from memory and apply it to a polygon
* how to do some simple blending effects
* how to use display lists to speed up your rendering
* how to implement basic fog effect
* how to add a light to a scene and specify color tracking for materials
* how to load an RGB image, transform it to RGBA (add an alpha channel) and use it to do blending effects (sprites, etc.)
* how to switch back and forth from #GL_PROJECTION to #GL_MODELVIEW and how to use them both on the same scene, pushing and popping them from the stack


Image



NOTE: this program still use a lot of .l variable declaration, now it works with 4.30 but when coding a new program now you should use .i or avoid the type declaration for integers.

See this article about portability by Freak: http://www.purebasic.fr/blog/?p=42

For the rest, it still can be useful to any Opengl+PB beginner, even if in the meantime I learned a lot more and probably I would rewrite this differently. Maybe I'll do !



EDIT: now SGL is available -> viewtopic.php?t=81764
Last edited by luis on Mon Jun 05, 2023 11:34 am, edited 23 times in total.
byo
Enthusiast
Enthusiast
Posts: 635
Joined: Mon Apr 02, 2007 1:43 am
Location: Brazil

Post by byo »

Nice, very nice.
This should get me started.
Thanks.
Brice Manuel

Post by Brice Manuel »

Wowzers, thank you very much for sharing this.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Cracking! :)
I may look like a mule, but I'm not a complete ass.
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Post by luis »

You are all welcome, I'm still adding "demos" to that, but right now I'm doing something else and I thought I could post what I done at the moment.

Cheers :)
Amundo
Enthusiast
Enthusiast
Posts: 200
Joined: Thu Feb 16, 2006 1:41 am
Location: New Zealand

Post by Amundo »

Very nice, thanks for sharing your work!!

Hope there's more to come.
Win10, PB6.x, okayish CPU, onboard video card, fuzzy monitor (or is that my eyesight?)
"When the facts change, I change my mind" - John Maynard Keynes
Inf0Byt3
PureBasic Fanatic
PureBasic Fanatic
Posts: 2236
Joined: Fri Dec 09, 2005 12:15 pm
Location: Elbonia

Post by Inf0Byt3 »

[Removed]

Luis has uploaded it and edited the links. See the first post.
Last edited by Inf0Byt3 on Mon Oct 08, 2007 12:35 pm, edited 1 time in total.
None are more hopelessly enslaved than those who falsely believe they are free. (Goethe)
Xqerience2003
User
User
Posts: 10
Joined: Fri Oct 05, 2007 8:10 pm

Post by Xqerience2003 »

nice :D
Baldrick
Addict
Addict
Posts: 860
Joined: Fri Jul 02, 2004 6:49 pm
Location: Australia

Post by Baldrick »

Nice? This is some really good stuff! :D
Inf0Byt3
PureBasic Fanatic
PureBasic Fanatic
Posts: 2236
Joined: Fri Dec 09, 2005 12:15 pm
Location: Elbonia

Post by Inf0Byt3 »

Yup, it should get anybody started within minutes :).
None are more hopelessly enslaved than those who falsely believe they are free. (Goethe)
User avatar
electrochrisso
Addict
Addict
Posts: 989
Joined: Mon May 14, 2007 2:13 am
Location: Darling River

Post by electrochrisso »

Great work, this helps with my learning a lot.
Thanks.
energy
User
User
Posts: 19
Joined: Sat Aug 04, 2007 1:05 pm
Location: Germany

Post by energy »

Great work.....
For me absolutly great stuff for trying to do OPENGL
Go on, i like yur Demo
Thanks

Cheers
eNeRGy
BasicGuy
User
User
Posts: 70
Joined: Sat Apr 26, 2003 4:37 am
Location: US

Post by BasicGuy »

Very nice! Thx for sharing your work! 8)
jpd
Enthusiast
Enthusiast
Posts: 167
Joined: Fri May 21, 2004 3:31 pm

Post by jpd »

wow,
Impressionante! :shock:
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Post by luis »

Updated for 4.30 (beta). :wink:
Last edited by luis on Wed Dec 17, 2008 10:24 pm, edited 2 times in total.
Post Reply