What Exactly is OpenGL?

BlitzMax Forums/OpenGL Module/What Exactly is OpenGL?

Clyde(Posted 2005) [#1]
What is OPEN GL?

I've had BMAX Beta for allmost a week now, and am make slow progress - but thats understandable, as it is a different lease of life for Blitz.

At first I was under the impression that OpenGL was a strictly 3D language incorparated as an added extra for BMAX as there wasnt any 3D inbuilt command set.

And after back tracking on the forum posts, I've got a thinking that is isnt a 3D only set of functions, but it is infact what lies beneath a majority of BMAX. So it's quite a nifty bit of kit is Open GL. Is Open GL, the same as Open Glide?

Being honest I'm not a particulary well clued up programmer, I just code for a nice fun hobby when and where able somethings I understand more then others - and Blitz is a great piece of work, and a great excuse to get creative.

Btw - please say if anything I've inputted here, is somewhat right. And this message it will enlighten others as well.


N(Posted 2005) [#2]
What is OPEN GL?


http://opengl.org/about/overview.html

Is Open GL, the same as Open Glide?


No, thank god.


col(Posted 2005) [#3]
Opengl is a graphics API, same as DirectX is a graphics API. It allows programmers access to use the hardware graphics through a set of functions.

Blitz3D uses DirectX
BlitzMax allow us access Opengl but can be programmed to access DirectX or just about anything you want to use really!


N(Posted 2005) [#4]
Opengl is a graphics API, same as DirectX is a graphics API.


Er, wrong- sortof, anyways. Mostly nitpicking that follows.

DirectX is an over-all API, it has classes for handling everything from sound to input to graphics to- well, you get the idea. OpenGL is just graphics. Big difference.

The correct statement would be "OpenGL is a graphics API much like how Direct3D is a graphics API".


col(Posted 2005) [#5]
Oops. I agree. I stand corrected. Thanks for that.


ImaginaryHuman(Posted 2005) [#6]
OpenGL is a rendering library that can do all kinds of drawing in 2D and 3D with many features such as lighting, textures, color, etc.. lots of advanced features too. It acts as an interface between you as the programmer and some kind of display hardware. If your computer has hardware graphics acceleration - that uses the graphics card's processor - the OpenGL automatically draws stuff using that, which is a lot faster. Otherwise it figures it all out in `software` and then transfers the end result to the screen.

OpenGL runs programs of OpenGL commands which draws stuff in a sequence. You can draw as much stuff as you like as many times as you like before ever flipping the screen to see the results. You generally draw to a `backbuffer` and later flip the buffer with a front buffer to see what has been drawn - double buffered to prevent flicker.

OpenGL can make things rotate and change size and be drawn in many different ways without too much effort from the programmer. You don't have to know all the math involved.

In BlitzMax, OpenGL is basically a big list of functions that you can call to do each step of the drawing process. BlitzMax has a further set of functions called Max2D which are `higher level` and let you do simple stuff like drawing rectangles, lines, ovals and points. It automatically translates those simple commands into OpenGL programs which the OpenGL driver then executes to draw images on your display. There is currently no official set of higher level commands for doing the full breadth of 3D possibilities - ie a Max3D module doesn't exist yet. Eventually this will let you do various 3D stuff much more simply.

You can write OpenGL programs directly and mix them in with any other BlitzMax commands. BlitzMax runs the BlitzMax commands and the OpenGL driver runs the OpenGL commands. Since Max3D will be based on OpenGL, anything it does you can also do directly with OpenGL functions. You could, right now, set up 3D scenes, lights, animations, models, terrains, effects, etc by directly writing OpenGL programs. BlitzMax has the full OpenGL 1.2 command set built in so you can use any of the functions available.

OpenGL is also an industry-standard non-Microsoft rendering library used by a lot of companies and individuals. It takes a lot of the hard work out of making stuff draw.


Loonie(Posted 2005) [#7]
OpenGL = Open Graphics Library.

=)

sorry. had to.


Clyde(Posted 2005) [#8]
What a fantastic description AngelDaniel; thanks so much.

Im extremely fascinated even more so by everything now!

By using any of the BMAX drawing commands (DrawRect, DrawPoly, Plot, Oval, etc,etc) will be exactly the same speed as using a direct openGL command?


Najdorf(Posted 2005) [#9]
Ha ha, you write programs using only the primitive drawing commands? Me too :-P!

I dont know if they are as fast as direct opengl, but I can tell you they are AMAZINGLY fast, never seen anything like that in a basic language before.


Clyde(Posted 2005) [#10]
Some stuff is quicker than other Blitz's, but when drawing and most especially; manipulating special effects - above 256x256 and this is with using writepixel- it's increasingly slow as previously with the other flavours of Blitz. And I have a Geforce4 MX graphics card, Pentium4 2.5 Ghz processor and 512 MB Ram. So theretically, it should be running at comfortable FPS speeds. 24FPS at 640x480 is alittle bit of a rubbish score for drawing.

And the main reason for asking about OpenGL, is there is alot of confusion on what it's for - as there's alot of 3D only examples. Seeming as BMAX uses OpenGL as it's core, then it would be excellent to see more 2D examples / tutorials and information on it included in the reference manuals etc. As the details of what commands do (all round) is not very clear at all.

Does anyone know if there's any difference in speed to the inbuilt readymade commands like Plot x,y, writepixel, to using direct OpenGL commands? Also BR any chance of the GL extensions to have a unique colour.

Thanks
THUMBZ


ImaginaryHuman(Posted 2005) [#11]
In almost all cases, direct OpenGL will be at least a little faster than using Max2D routines. Why? Because the Max2D routines do other processing as part of providing you, the programmer, with a simpler higher-level interface. You can, I'm sure, render a lot more single pixels (plots - which are individual vertexes) using an array of points rather than making lots and lots of calls to Plot. There are also other routines which are faster if you do the OpenGL yourself rather than the Max2D route because you might be able to eliminate steps which you don't need. For example the DrawPixmap function, each time you call it, it might perform a format conversion, as well as an operation to flip the pixmap vertically - all OpenGL commands have an origin in the bottom left corner so the pixmap has to be vertically flipped to render bottom to top correctly. You can cut all that out and just set up and call the OpenGL routine, DrawPixels - to directly draw a pre-flipped pixmap without a format conversion of a flip operation. This makes it much faster. Just one example.

You can probably get more speed with direct OpenGL but ease-of-use with Max2D, and since it's pretty fast anyway you might not mind the overhead.


flying willy(Posted 2005) [#12]
And more speed still, by using C++. If you're gonna go down that low level route, why use blitz anyway? thats something I've never understood.


ImaginaryHuman(Posted 2005) [#13]
Well, it's okay to go one step, you don't have to go to the extreme of writing in assembler.


Najdorf(Posted 2005) [#14]
>And more speed still, by using C++. If you're gonna go down that low level route, why use blitz anyway? thats something I've never understood.

Because at least you dont have to learn the windows api, the mac API and linux API to make a window, take input, use timers, play sounds, manage events......


Alberto(Posted 2005) [#15]
"Because at least you dont have to learn the windows api..."

Honestly it seems to me a rather weak explanation.
I have been designing (better, trying to design) games using C++ and opengl \ directx ,before switching to blitz3d .
For sure, I did not take this decision because of such reasons.
Same as flying willy I wonder what is the real advantage of using BlitzMax.
It might be :
"BlitzMax has a further set of functions called Max2D which are `higher level`.."
Ok,But MAX3D is a must,in my opinion, otherwise..


Najdorf(Posted 2005) [#16]
Your right, the purpose of blitz languages is to have a higher level set of commands to make things easier and faster, however it is still useful also if you want to use direct opengl "easily" (ok, you might use something such as SDL or allegroGL or GLUT, still I like Max better)

Personally I'm not interested in 3D, I feel there is so much you can create in 2D that has not been explored. But if you want to do 3D fast, I agree, MAX3D is a must, or you might as well go for SDL.

Ciao Albe'


Tom(Posted 2005) [#17]
I've heard quite a few people say "what is the advantage of max over C/C++ ?"

It will *always* be 'ease of use' IMO. Because there's no B3D type 'engine' in max at the moment, people immediately think it's a skeleton language and compare it to C/C++, what they're forgetting is all the underlying stuff that *is* in max, and how easy it is to use it all.

Oh yeah, and it's fun! Not a word I'd associate with CPP

Take it easy!
Tom


tonyg(Posted 2005) [#18]
I'm with Najdorf here. I still want to do 2D games and think there is a lot more to explore.
I'm struggling to determine how much direct Opengl will help with 2D games.
I've been messing with OGL lights (please can we have 2d lights in BMAX above lightblend!!!) and find them fiddly and a bit slow. I admit this is probably because I'm not using them correctly.
Is anybody working on Max/OGL hybrid code, specifically in 2D? If so , how are you getting on?


Alberto(Posted 2005) [#19]
Tom
I do not forget the underlying stuff, I just wonder "What for?"
I mean, everybody can learn c\c++ in a couple of months but designing a 3d engine starting from openGl or direct x , is an other matter.
You must work full time a couple of years to design a decent 3d engine.
Honestly I would prefer a Blitz3D SDK , updated to direct x 9.c , accessible via C++,C#,or VB.
In anycase a 3D Module is must, in my opinion