gluPerspective with SFML: same compilation, different results. Graphics not showing - c++

I am using SFML library (C++) and I copy-pasted Laurent Gomila's example (http://www.sfml-dev.org/tutorials/1.6/window-opengl.php) to test OpenGL.
It worked well. But at some point I would start playing with some of the gl functions... When I changed the first paramether of this...:
gluPerspective(100.f, 1.f, 0.1f, 500.f);
I could notice some diferences when I executed the program, but the 3rd or 4th time I changedThatParameter+compiled, it stopped displaying the graphics. I backtracked to get them displayed again but... guess what? THEY DIDN'T! Same code as before, but still not graphics!
What could possibly be happening?

It ended up being that my noobness got my RAM in trouble because I was stacking memory allocations without freeing none of them.
After implementing proper deletion of memory assignment it worked as it should have.

Related

BMP texture doesn't show

I've encountered a problem whilst learning how to texture in OpenGL (from OpenGL 5th Edition Bible). The problem is that I can't display my texture. I load it from a BMP file with a function I've written myself.
Since code is quite lengthy I uploaded all neccessery files. You can download it from here.
EDIT: I've tried copying code from the mentioned book (TGA loading described there) and it doesn't work as well. It seems that loading stucks at loading image data from file (strange). I suppose it isn't relevant as far as my problem is concern.
There are general debug steps for checking for problems. I will list them below in the hope you might find the bug (and for future readers):
Does the file exist? Is the file being read properly according to the format? Did you get it to gel well with OpenGL? My suggestion: Do not mess with these things yourself. Use a library. There's an amazingly light weight SOIL (Simple OpenGL Image library)
Are you loading the textures before initialising OpenGL? This was always my problem because I used to "load" and do a glBindTexture(..) in the constructor (of some class). The objects were created before OpenGL was initialised.
Have you enabled GL_TEXTURE_2D? Check the initialise code, use: glEnable(GL_TEXTURE_2D)
Did you map the textures properly with the quad or the shape you want it on? Expanding on this here is (sort of) out of scope. There are great tutorials out there.
(Would seem stupid, but happens sometimes) Are you blacking out the object by glColor3f(0,0,0) ?
There could be more checks, but these are the ones hitting my head now

OpenGL Error underflow turns into overflow?

I am working on a project which uses OpenGL only (it's supposed to become a game one time to be specific), now after some weeks of development I stumbled across the possibility to catch OpenGL errors with GL.GetError().
Since I dislike that it only says what went wrong but not where, I want to get the error that occurs fixed though.
So here is what happens:
When launching the app there are few frames (three or four) with StackUnderflow, it switches to StackOverflow and stays that way.
I checked my Matrix-Push-Pop consistency and didn't find any unclosed matrices. It might be interesting to know that, from what I see, lighting doesn't work (all faces of the various object have the very same brightness).
Is there any other possbile cause?
(If you want to see source, there is plenty at: http://galwarcom.svn.sourceforge.net/viewvc/galwarcom/trunk/galwarcom/ )
You need to set the matrix mode before popping since each mode has a separate stack. If you do something like this, it will underflow:
glMatrixMode(GL_MODELVIEW)
glPushMatrix();
... stuff with model view ...
glMatrixMode(GL_PROJECTION)
glPushMatrix()
... stuff with project matrix ...
glPopMatrix() // projection popped
glPopMatrix() // projection again
You are doing something like this in drawHUD(), probably other places.

GLUTesselator for realtime tesselation?

I'm trying to make a vector drawing application using OpenGL which will allow the user to see the result in real time. The way I have it set up is with an edge flag callback so the glu tesselator only outputs triangles which I then pass to a VBO. I'v tried t make all my algorithms as fast as possible and this is not where my issue is. According to a few code profilers, my big slowdown occurs in a call to GLUTessEndPolygon() which is the function that makes the polygon. I have found that when the shape exceeds 100 input verticies, it gets really really slow and basically destroys all the hard work I did to optimize everything else. What can I do? I provide the normal of (0,0,1). I also tried all the tips from the GL redbook. Is there a way to make the tesselator tesselate quicker but with less precision?
Thanks
You might give poly2tri a try to see if it's any faster.

Receiving GLU_TESS_ERROR_5 from GLU Tesselator

Here is my issue. I'm tesselating complex, self intersection, multicontour polygons with hundreds of verticies. The GLU Tesselator crashes with null pointer 0x0000000 issue. It never ever crashes when I do not make self intersecting polygons. If it does not intersect, it will never crash no matter what the circumstances. I check for NULL EVERYWHERE in my application, I'm sure it's not on my side of things. I found an old version of GLU 1.2 from SGI and it never crashes, however the mesa and Windows versions based on GLU 1.3 both crash. Nothing crashes in debug mode strangly enough. To get more information I compiled Mesa's GLU and saw that first an assert fails, then if I comment that out, there is a pointer which is set to NULL from a function which fails to malloc. I'm very unsure at this point what to do. What could I do to try to solve this issue? Should I just try to make a version of Mesa's GLU which works for me? I'm just unsure how to proceed from here.
After more debugging I see I'm getting GLU_TESS_ERROR_5 which I think is a number too large error but I did a for loop to test for numbers greater than that but no luck :(
At least on Windows, GLU_TESS_ERROR_5 means that one of the coordinates was too large. Specifically, GLU requires that the coordinates are small enough to be multiplied together without overflow. The specification says that the limit is defined in the constant GLU_TESS_COORD_TOO_LARGE. If this constant exists, check that the absolute value of every coordinate is less than it. If not, I think it would be safe to check that the coordinates are between - 10^150 and 10^150. If that doesn't work, try progressively smaller ranges.
It may also be that there's a problem with geometry, which triggers another problem in GLU. Try to find the simplest polygon that will trigger this error.
If that doesn't work, see if there is a newer version of GLU available. I don't know about Mesa, but the version of OpenGL shipped with VC++ is notoriously out of date.
If all else fails, you could try using another library to perform the tesselation. After a quick search, Triangle1 appears to be a good candidate.

Strange error with hardware picking in directx

i am trying to get pickigng working in directx 9 and i am having some trouble. it works fine when i am rendering my mesh in software however i do get errors when rendering with a shader.
i can be off of a mesh but it still detects it as a hit (see image for more detail)
i am stopping animation controllers and updating frame matrices but still no joy with the picking.
http://tweetphoto.com/a7vtajzt
any help much apprechiated this has been driving me nuts for two days now.
regards
Mark
not to worry i found out that i was missing a clone function that i was doing in software mode but not hardware