A little "HowTo" use OpenGL in GLBasic

Previous topic - Next topic

Schranz0r

Hi my friends,

i will share with you guys my litte 3D test with OpenGL in GLbasic.
It's just a start on how to use a "Camera" to move like in Minecraft (Creativemode).
I update the gl.gbas a bit to make it possible to use RenderLists in GLB, the only thing i add was:

Code (glbasic) Select

INLINE
} extern "C" { GLuint __stdcall glGenLists( GLuint range );; }; namespace __GLBASIC__{
ENDINLINE
FUNCTION glGenLists: range
INLINE
return OGL glGenLists(range);
ENDINLINE
ENDFUNCTION


RenderLists speed up the rendering by ->>>  :o  ... :D
It give you a good start on how to use OpenGL and on how to create objects!

Maybe it gives you a start for youre next game ( hope so ), let me know it!

if you have any questions, ask me.


Maybe i code some more features into it like a  OBJ loader, that was my next point on the list :D


EDIT: Fix the upload, now its working sry! 
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

erico

#1
Nice Schranzor, I will give a try. :good:

edit: strange, I get this:
Quote
_______________________________________
*** Configuration: WIN32 ***
precompiling:
GPC - GLBasic Precompiler V.9.988 SN:37233beb - 3D, NET
..\Samples\Common\gl.gbas (failed to open)
"Axes.gbas"(24) warning : GPC1001 probably unassigned variable : GL_COMPILE
"Axes.gbas"(25) warning : GPC1001 probably unassigned variable : GL_LINES
"Object.gbas"(47) warning : GPC1001 probably unassigned variable : GL_QUADS
"OpenGLUtils.gbas"(10) warning : GPC1001 probably unassigned variable : GL_TEXTURE_2D
"OpenGLUtils.gbas"(10) warning : GPC1001 probably unassigned variable : GL_TEXTURE_MIN_FILTER
"OpenGLUtils.gbas"(10) warning : GPC1001 probably unassigned variable : GL_NEAREST
"OpenGLUtils.gbas"(11) warning : GPC1001 probably unassigned variable : GL_TEXTURE_MAG_FILTER
"SimpleOpenGLGame.gbas"(106) error : GPC0009 call to undefined function : glRotatef

Schranz0r

#2
i fix the upload!
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Hemlos

Lots of questions:

Sorry about my ignorance, what are renderlists?

I dont see how this create a speed increase, what is needed to do this?
I will try to apply this to APE,  my 3d particle system.

I like the idea of an OBJ loader, perhaps you can fix the glbasic object converter instead?

And since youre tinkering....one real big problem with GLBasic 3d is the z ordering.....i have not yet found a solution, no matter how objects are ordered onto the screen according to z depth(even physically coded), there are still  weird artifacts like transparencies and blobs of incorrect lighting/color etc.


Bing ChatGpt is pretty smart :O

mentalthink

Schranz0r thanks , I don't test because I'm in Linux, but from OpenGL 3.0 you don't need download any .h inst?¿, I read Nvidia make something you don't need to say to the compiler nothing.

Ok the render list, what it's, ?¿ I'm equal like Hemlos I don't know what are this.

For place a obj import really this have to be very very easy, I real a lot of documentation on the web about .obj, and seems the best friendly and easy format for play with it.

For anyone are interested in OpenGl and 3D , you have in English this huge and awesome web, I think it's a very important guy into OpenGL...
http://nehe.gamedev.net/

erico

Works fine now. :good:
I will save it to examine further.

The camera rotations go smooth here but the movement kind of jitters here and there, why so?

Schranz0r

Hey no stuttering here....

renderlist:


only draw/create the object one time, then send it to the graphicscard.
the only thing you need in the mainloop is to call the list on the card!

Larger objects will be rendering much faster then immediate mode!
If you need to change the object, recreate the list one time not every frame like immediate mode.
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Hemlos

#7
 :giveup:

Im looking through all the code, i dont see anything remotely close to what you mentioned:
renderlists
immediate mode
creative mode

Where is the tutorial?  :S
Bing ChatGpt is pretty smart :O

kanonet

Displaylists are depreciated and not supported in OpenGL 3.1+ core profile (ok, doesnt matter for us) and OpenGL ES. So you can not run this on mobile devices. Also GL_QUADS does not exist in OpenGL ES too (replace with GL_TRIANGLE_STRIP).

I recommend to not use gl.gbas, instead write all your rendering stuff in INLINE C++ and OpenGL. So you avoid the wrapper overhead, and get some tiny speed improvement. See my libSPRITE how to do it. Also multmatrix is faster then doing multiple rotate/translate stuff again and again, which is why I do this in my (not yet officially published) Entity System.
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

erico

Quote from: Schranz0r on 2014-Aug-14
Hey no stuttering here....

None here for rotations.
Translations give some, significants ones.

I´m not good enough to figure out why. :(


kanonet

Sounds like the same shuttering you can get in GLBasic too, its caused by float inaccuracy and setting up the camera. If the engine creator is careful it can be avoided.
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

matchy

Looks good and perhaps I will give it a try.

Schranz0r

#12
I don't care about mobile and whats not supportet in newer version...

It's just a way to start.
It's the easy way and not the perfect one. If you new to GL you can't go from zero to hero in a day...

Whats the "new" way to render? VAO or VBO?
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

kanonet

I just wanted to state this, so users can decide if this meets their needs.

VAo and VBO both are possible AFAIK.
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

fuzzy70

Thanks for this, it will come in very handy in the near (hopefully) future. I'm about to start learning C++ as I want to learn more about OpenGL although more in a 2D context rather than 3D. As practically every OpenGL tutorial is C/C++ based a basic grounding in C/C++ will not do me any harm & will be useful for other things (there is so much useful code out there also).

Luckily skimming through the tutorials there is nothing really heavy looking C/C++ wise although GLEW & GLUT get mentioned quite often which currently mean nothing to me as of yet so will cross that bridge when I get to it.

Lee
"Why don't you just make ten louder and make ten be the top number and make that a little louder?"
- "These go to eleven."

This Is Spinal Tap (1984)