Hi guys!!! ¿Can someone explain me how to draw a 3d object on allegro 5? for example a 3d cube.
You might check out this post from this thread.
Well, I never thought Allegro 5 had its own 3D drawing functions... That OpenGL/D3D where the only way to draw something else apart from 2D objects. You even got textures applied to the geometry Mark, awesome! Will look deeper on that API when I have more time.
Yeah, with allegro 5.1 you can also do portable 3D drawing with al_draw_prim and al_draw_indexed_prim. I even wrote a 3d model handler (model.c) an .obj file loader (objfile.c) which you can use under the Sleepycat license here: https://github.com/beoran/ekq/tree/master/src
Yeah, you can draw 3D stuff with it, but I assume that once you're actually doing more complicated and more advanced stuff or are aiming for great graphics, you're better off using OpenGL or Direct3D directly. I imagine that Allegro 5 adds quite some overhead to draw these "primitives" (I'm not sure), but more importantly, Allegro 5 still lacks a lot off essential functionality that you'll want in a 3D game, like smapler states, for example. If you need some of that fuctionality, you have no choice but to use the respective APIs directly. Also Allegro is still stuck on Direct3D 9 and an older version of OpenGL (3.2 I think? Might be system-dependent.). You can actually gain a lot by using the newer versions of those APIs, especially in the case of Direct3D (Direct3D 12 may not be widely available yet, but you can achieve console-level performance with it). For a complex 3D game, even the slighest performance gain will ultimately matter. For a simple 2D game, probably not so much, so here it's no problem to actually keep using D3D9, unless you actually need some of the new functionality (like geometry shaders or whatever).
For simple 3D stuff, Allegro is great, though. For example, imagine you want a 3D world map in your game (in the form of a simple sphere), or certain 3D collectibles or maybe even a boss fight using 3D components. The capabilities are there, so you'd only have to actually do it.
Yeah, of course the 3D capabilities of Allegro are limited, although the performance should be OK. However, for not only for the oocational 2d, but also for retro-style 3D games, I think what Allegro can do is already quite nice.
Thanks for the help guys, but i have a problem, i can`t use this functions:
al_clear_depth_buffer(),
ALLEGRO_DEPTH_TEST(),
al_rotate_transform_3d(),
al_translate_transform_3d(),
al_perspective_transform(),
al_set_projection_transform();
I use allegro 5.0.10 and import this:
#include <allegro5/allegro.h>
#include <allegro5/allegro_primitives.h>
Ohhh, you need Allegro 5.1.x.
Make sure you get the latest, too.