Allegro.cc - Online Community

Allegro.cc Forums » Off-Topic Ordeals » [A5 + OpenGL] Drawing an overlay over 3-D

This thread is locked; no one can reply to it. rss feed Print
[A5 + OpenGL] Drawing an overlay over 3-D
Chris Katko
Member #1,881
January 2002
avatar

I've got a bunch of 3-D routines now, and they work decent now. However, I can no longer directly draw to the screen. Whatever quad Allegro draws to is transformed off into oblivion somewhere.

Do I figure I need to reset some matrices so that Allegro can draw to the correct place. However, I'm not sure what to set them to.

Thanks in advance,
--Chris Katko

[off-topic ordeals? A habit I guess!]

-----sig:
“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs
"Political Correctness is fascism disguised as manners" --George Carlin

Trezker
Member #1,739
December 2001
avatar

Here's how I do it. I push old projection matrix before going into 3D mode, then pop it to get back allegro's setup.

#SelectExpand
1void Init_perspective_view(float fov, float aspect, float near, float far) 2{ 3 glMatrixMode(GL_PROJECTION); 4 glPushMatrix(); 5 glLoadIdentity(); 6 gluPerspective(fov, aspect, near, far); 7 glMatrixMode(GL_MODELVIEW); 8 glLoadIdentity(); 9} 10 11void Pop_view() 12{ 13 //Return to Allegros 2D world 14 glMatrixMode(GL_PROJECTION); 15 glPopMatrix(); 16 glMatrixMode(GL_MODELVIEW); 17 glLoadIdentity(); 18}

Thomas Fjellstrom
Member #476
June 2000
avatar

You might want to use this stuff to switch back and forth. At least it'd be a bit easier. And then you know it should be saving and restoring all state that allegro may need.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

furinkan
Member #10,271
October 2008
avatar

I've only the faintest idea what I'm talking about here, but I'm pretty sure there is a function to retrieve a matrix that is in use. You will have to find out how to store the matrix Allegro uses for projection, do your 3d stuff, then restore the matrix before drawing with allegro.

You will probably have to (manually?) set any GL states you may have changed. ???

[EDIT]
oh, allegro does that too. Right on! ;D

Go to: