Allegro.cc - Online Community

Allegro.cc Forums » Game Design & Concepts » Is trying to create 3D using primitives a good idea?

This thread is locked; no one can reply to it. rss feed Print
Is trying to create 3D using primitives a good idea?
Sythical
Member #14,461
July 2012

Hello, I'm considering to try and use the 2D primitives that are available in Allegro to create simple 3D objects (and have methods to rotate the object and stuff). The problem is I'm not sure if this is a good idea so I wanted to ask for advice. I'm under the impression that 3D is generated by drawing different 2D primitives but that doesn't sound very efficient or optimised and I'm guessing there are techniques to draw 3D that are used in programs designed for 3D?

I don't plan on making something too complicated and just want to get a better understanding of how things work. I don't study computer graphics until the third year of my course and not too keen on waiting ::)

Not too sure if I'm asking this in the right section but this seemed like a better place than the programming section.

Thank you for reading!

SiegeLord
Member #7,827
October 2006
avatar

Hello, I'm considering to try and use the 2D primitives that are available in Allegro to create simple 3D objects (and have methods to rotate the object and stuff).

The only ones that are useful would be the al_calculate_* functions. If you want spheres/cones/cubes/etc you're going to have to write them yourself (not too hard) OR load them from external data files (MD2 file format is exceedingly easy to understand and parse and most 3D authoring programs support it). Once you get your vertex data in order just send it along to al_draw_prim / al_draw_indexed_prim.

Quote:

I'm under the impression that 3D is generated by drawing different 2D primitives

You can interpret this to be a correct statement if you stretch your definitions a bit... but suggest forgetting that notion. 3D is generated by using 3 coordinates for vertices instead of 2 as well as using 3D projection matrices.

The only 3D example in Allegro that I can think of is ex_projection. You could try looking at it perhaps.

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Sythical
Member #14,461
July 2012

Thank you for your reply SiegeLord.

So based on your answer, it's not a silly idea to calculate the vertices/coordinates of a 3D model and use what's available in to draw it. Do operating systems only provide functions that allow a programmer to draw 2D primitives (or functions for 3D based on functions for 2D)? Thanks.

Edit:
Just read a bit about GDI in Windows, I'm having trouble wording the question but what I'm essentially asking is whether 3D is normally drawn by calling functions that are responsible for drawing 2D. Or are there special optimised functions provided that are used instead.

SiegeLord
Member #7,827
October 2006
avatar

Or are there special optimised functions provided that are used instead.

Yes, special optimized functions are used instead, although in Allegro these special functions are also used for 2D stuff (this is possible since 2D is a special case of 3D).

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Sythical
Member #14,461
July 2012

Okay I think I have a better understanding now, thank you for your replies!

weapon_S
Member #7,859
October 2006
avatar

That's what (most) graphics cards are for. It might be interesting to note that 3D images generally only consist of triangles (in 3D space), with images ("textures") applied to them.
There are other techniques, but at the moment they are more technical tricks than used methods as far as I know. (And I don't know a lot.)

Arthur Kalliokoski
Second in Command
February 2005
avatar

Of course you can use untextured lit triangles.

{"name":"c7f2a3b9604ee2b7458aacb159d74c46.png","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/c\/7\/c7f2a3b9604ee2b7458aacb159d74c46.png","w":1024,"h":768,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/c\/7\/c7f2a3b9604ee2b7458aacb159d74c46"}c7f2a3b9604ee2b7458aacb159d74c46.png

https://www.allegro.cc/forums/thread/609459/946455#target

They all watch too much MSNBC... they get ideas.

Go to: