Desde ayer estoy trabajando en llevar a C++ algunas pruebas que hice para hacerme mi propio interfaz de usuario en C.
Así se veía antes:
No se ve de maravilla, pero espero que mejore un poco. Además del cambio de lenguaje estoy cambiando a Open GL como backend de renderizado en lugar de SDL.
Looks good for the start.ResponderEliminar
I didn't get the translation right. Are you using C++ and OpenGL right now ? Anyway good luck :)
I started using C and SDL, now I changed to C++ and Open GL. By the way, I wanted to ask you if you have implemented drag and drop.ResponderEliminar
Nope I haven't made drag and drop. Maybe because it wasn't needed for my game engine, maybe I will add something with my future editors.ResponderEliminar
Anyway the GUI with C++ is so fun thing to code. Especially if the classes are derived, it is just a matter of changing some lines.
Well, was fun for me during the first hour. Now Im dealing with rendering in 2d using open gl and nothing is going as I thought.ResponderEliminar
Well It was hard for me to write my first GUI, but then I stopped it and remade it again, learning previous lessons.ResponderEliminar
I am not actually rendering in plain 2d, I am just using the same Perspective, but for ease of development I changed few things.
1. The coordinate system. As it is going to be hard as hell to calculate some points where component is going to be located, especially if using standard OpenGL coordinate system. I changed it.
From now on the top left corner is ( 0.0f , 0.0f ) and top right is ( 1.0f , 1.0f ).
I did it with this :
//we need to retranslate to origin
glScalef(1.53, -1.15f, -1.0);// This is the aspect correction.
//DRAW HERE WINDOWS
//DRAW FOCUS OVER FOCUSED WINDOW
This is exactly the same code from my current GUI system.
2. I made a few classes , and made another ones derived from it
[base] -> [component] -> [button]
Now the hole trick is this base class that has all the standart properties such as :
position , dimensions, style to draw, events.
Now when I am going to derive it, Il add additional properties. For example the window has list of component classes - which are actually components I am going to put in this window.
Once the classes are ready I made a list. which stores all the windows.
This probably everything I made so far, still I am probably going to improve it some time later on.
Well, Im using the 2d approach, via orthographic projection. It is still not working, I have to spend some time asking around in gamedev forums to see whats the proble, when it is done Ill post about it. And I have some ideas about drag and drop, just minimal ideas. It involves timing between press and release and button state flags.ResponderEliminar