Hi guys, I'm writing an opengl program which at this stage is pretty basic, and at the moment I'm just working on getting the UI sorted. I open a new window with an opengl scene/screen or whatever its called and ive managed to load a background image. The next thing I want to do is create click regions/buttons. I made a class that enables me to create a new button object using my button class with height and width dimensions as well as x and y coordinates for positioning. How do I go about implementing buttons though? At the moment, the only way that I've managed to get the whole thing to work is by creating a function along side my other opengl standard functions like resize, paintgl etc... i.e. I have a function called clickevent or something along those lines and inside that, I've got the instances of all my buttons, so the buttons appear every time a click happens and they no longer exist once the click function has been processed which includes every button getting checked for clicks... which as you can image can bog down the performance if lots of clicks are necessary. I tried putting the button instantiation inside the opengl class constructor but when I subsequently use those classes, it says that they haven't been defined which I actually understood just as I was writing this to mean that once the constructor function ends, the classes are destroyed - at least I think that's what happens. This to me seems really inefficient but it's the only way that I've managed to structure my program which has allowed it to actually get compiled. Any ideas on how else to implement what I'm trying to do?
Have a look at something like this
It might help you