Hi guys!
Im new to Allegro5 and OpenGL. I was really exicted when i got my first 3D cube to be drawn. but yesterday I got really depressed when I got this problem... I've googled it like 3000000 times but it seems nobody else has this horrible problem.
Im uploading a screenshot:
{"name":"thump_8343734crap.png","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/3\/e\/3ec224dba32d566b596a8a7f9825b519.png","w":331,"h":200,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/3\/e\/3ec224dba32d566b596a8a7f9825b519"}
As u can see it must be related with the way I configure the DEPTH BUFFER... but I really dont know what I'm doing wrong.
I'm using Code::Blocks 12.11 C++ with MINGW 4.7 and the I'm not sure what openGL version im using but it's the one provided with MINGW 4.7
And here is my whole code:
THANKYOU so much in advance!! Id be so pleased if you can solve this...
If you're on Linux and you're using the noveau (sp?) display driver, that's probably the reason. Use the proprietary binary driver from the OEM.
As u can see it must be related
No, I can't see anything from that tiny screenshot and little bit of code. Explain the problem, what you expect to see and what you actually see.
BTW Allegro 5.1 has functions for managing the depth buffer. If you don't want to use them at least look at the documentation. The function names are different but you can easily match them up to OpenGL functions, and the documentation is pretty clear about how you use the depth buffer (at least it was what I needed to figure it out.)
Ok sorry for my bad explanation.
What I see: a cube and a green face, the green face is further than the cube but I can see it somewhat overlapping the cube.(weird rendering maybe?)
What I want to see: a cube and a green face, the green face should just be seen where the cube is not covering it.
Arthur: Im using Windows7, sorry for not telling that in my 1st post :S
Trent: I can't find any of those funcions to hadle depth buffer in allegro5. U sure they are in the documentation?
PS: I think I should forget about this and jump to OpenGL3.x and maybe this was just the result of using deprecated libraries, what you think?
Although learning OpenGL 3 would be a good idea, the example you have should still work. I couldn't find anything wrong with it, so I can only guess that the driver is to blame. Have you updated your graphics driver recently? Also what graphics card do you have?
Link to Allegro 5.1 reference manual: http://alleg.sourceforge.net/a5docs/refman
Have a look at the graphics routines, I think there you can find something of interest, even thou me too can't really see what could be wrong with your code.
Thanks for your answers. I have an ATI Mobility Radeon HD 3650 ive just updated my drivers but still get this weird result...
Im hitting my head against the wall... I really dont know what to do to solve this D:
EDIT: I run the .exe on my friend's PC and got the same problem :S
I've compiled and run this with MSVC11 on windows7.
The program behaves a bit differently from what I expected.....but I do not see any "weird" transparency....instead seems that depth is inddeed managed wrong (in the screenshot I have attached I expected the green face to stand BEHIND the violet cube face).
Using the keyboard thou, I would have expected to be able to rotare allround the two objects but seems to me that the shapes are mostly deforming instead....so for me it's a bit hard to understand what's going on.
Your code is wrong, from the gluPerspective documentation http://www.opengl.org/sdk/docs/man2/xhtml/gluPerspective.xml:
void gluPerspective(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar);
zNear must never be set to 0
But you have:
ClippingBorder1=0 ... gluPerspective( Angle, Ratio, ClippingBorder1, ClippingBorder2);
OH MY GOD! SO stupid me! Ty so much!!! it was just that I set zNear to 0.1 and now it runs perfect!! Thanks so much really thanks so much!!
Okay, now it's official...I do not understamd what's going on in this demo.
Okay, now it's official...I do not understamd what's going on in this demo.
Why? Its just a bit of code which draws a cube and a single face, I set up the keyboard to be able to move with WASD, increase or reduce field of vision with ZX, and look around with mouse. I had a mistake setting zNear to 0 that's all.
Actually, most of the time the cube and the face get badly deformed both by mouse movement and using keys.....that's what I do not understand
the cube and the face get badly deformed both by mouse movement and using keys
I didn't look at the code, but that can happen if you keep rotating the same matrix because errors accumulate. You're supposed to set a matrix to the identity, then rotate by the accumulated rotation angle.
Didnt' really got around checking the code or anything....you know I had a very hard Friday there....it finished 11AM this morning (thou I was out skiing nonetheless).
I actually feel very uncomfortable with the way this demo rotates/stretches things.
Setting the clippingborder1 to positive resolved the depth check problems, but then the rest to me is really diffcult to copy with.
Anyway cookies to joecarl, this ismple demo got me thinking about a couple thing I could do in the future.... 