Nothing displayed


i was cleaning up my project, but now nothing is displayed anymore. Maybe you can take a look at it and tell me what i miss. I checked everything 3 times, but i don’t find the missing thing.

I uploaded my project to github. I thing it’s much easier for you to browse my code or to simply clone the repo to run it on your system that way instead of posting some code lines.

I’m still not that familiar with OpenGL. So if you see some attributes that belongs somewhere else in your opinion please tell me :smiley: It’s really my first try to organize OGL in classes.

Don’t put OpenGL code in constructors/destructors. You are not guaranteed that they won’t be called multiple times on what you see as a single instance (when using arrays or stl containers). Move their code into custom init()/destroy() methods so you can keep track of what resources are used.

It’s generally a bad idea to wrap OpenGL ‘objects’ with your own classes (except for shader/programs); OpenGL is already a high-level API and simplifying its use would just mean losing control for no discernible benefit.

Use apitrace or renderdoc to debug your code; no amount of reading and focusing on what could go wrong be worth the time.

Also having one shader for each object is really unnecessary; use only one for the whole scene.

i personally put every piece of openGL code in a separate class called “Renderer” or “Graphics”
everything else is outside of this class, it only has 1 member function:
void Render(const Scene& myscene, int& ID_of_the_current_cursor_posiiton);

the application passes each frame just a reference to a “scene” object which has:
– camera
– objects (models)
– light(s)

the (struct) scene has 1 member function:
void AnimateNextFrame(float timestep);
here i do the movement of the objects, response to input etc
it has nothing to do with opengl, just pure c++

all right. maybe i was a bit too fast. So i managed everything in one class now (openglcontroller)
But still nothing is displayed. Maybe you can take a look at it again. And i’ll read about that debug methods :smiley:
Link is still the same i pushed my latest progress


Ok i forgot to bind my vertex array…
Now i need to find out why my move functions do not work

i found the problem, but i do not understand it.
The transformation values are always the same. They do not change. But the callback function is executed and changes the value in the oglcontroller. But at the next loop run, the value is the old again.
i noticed that the projection and view matrix are the identity. And that shouldn’t be the identity since in every frame they are recalculated and if no keys are pressed, the camera should be at 0,0,5 and look to 0,0,-1.

So for some reason the callback function has an reference to an clean init version of an oglcontroller.

When i created the window i used this: glfwSetWindowUserPointer(pWindow, this); and at this state the matrices are the identity. But after the first recalculation they have different values, i checked that.
But the window user pointer still points to the old version. Why isn’t it updated??

Since i’m using singleton pattern, i tried to get an reference to the oglcontroller using the static function getInstance. But that way the whole class will be destroyed after the callback function was exited.

Any ideas, why there are two versions of oglcontroller while runtime??