diff --git a/ogl_editor/src/Editor.c b/ogl_editor/src/Editor.c index ca3415b..5f8790a 100644 --- a/ogl_editor/src/Editor.c +++ b/ogl_editor/src/Editor.c @@ -49,6 +49,8 @@ void Editor_guiUpdate() RocketGui_textLabel("Test2"); RocketGui_textLabel("Test"); + RocketGui_fill(0xff0203ff, 10, 10, 100, 100); + RocketGui_end(); } diff --git a/ogl_editor/src/GFXBackend.h b/ogl_editor/src/GFXBackend.h index eb783c8..e9231e4 100644 --- a/ogl_editor/src/GFXBackend.h +++ b/ogl_editor/src/GFXBackend.h @@ -2,7 +2,7 @@ void GFXBackend_create(); void GFXBackend_destroy(); -void GFXBackend_draw(); void GFXBackend_updateViewPort(int width, int height); void GFXBackend_setFont(void* data, int width, int height); +void GFXBackend_drawControls(void* data, int count); diff --git a/ogl_editor/src/OpenGLBackend/OpenGLBackend.c b/ogl_editor/src/OpenGLBackend/OpenGLBackend.c index 28dc46c..a110266 100644 --- a/ogl_editor/src/OpenGLBackend/OpenGLBackend.c +++ b/ogl_editor/src/OpenGLBackend/OpenGLBackend.c @@ -1,11 +1,12 @@ -#include "Core/Types.h" -#include "../GFXBackend.h" -#include "../MicroknightFont.h" #include #include #include #include #include +#include "Core/Types.h" +#include "../RocketGui.h" +#include "../GFXBackend.h" +#include "../MicroknightFont.h" unsigned int s_fontTexture; @@ -45,16 +46,6 @@ void GFXBackend_updateViewPort(int width, int height) /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void GFXBackend_draw() -{ - glClear(GL_COLOR_BUFFER_BIT); - - // prepare for primitive drawing - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - - glFlush(); -} /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -64,7 +55,7 @@ void GFXBackend_destroy() /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void GFXBackend_drawTextHorizontal(int x, int y, const char* text) +static void drawTextHorizontal(int x, int y, const char* text) { const int charOffset = 32; char c = *text++; @@ -98,6 +89,7 @@ void GFXBackend_drawTextHorizontal(int x, int y, const char* text) } glEnd(); + glDisable(GL_TEXTURE_2D); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -191,15 +183,55 @@ static void quad(int x, int y, int width, int height) /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void drawRow(int x, int rowOffset) +void GFXBackend_drawControls(void* data, int controlCount) { - glBegin(GL_QUADS); - quad(x, rowOffset, 8, 1); - quad(x + 10, rowOffset, 8, 1); - quad(x + 20, rowOffset, 8, 1); - glEnd(); + RocketControlInfo* controls = (RocketControlInfo*)data; + + glClear(GL_COLOR_BUFFER_BIT); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + for (uint i = 0; i < controlCount; ++i) + { + const RocketControlInfo* control = &controls[i]; + + switch (controls[i].type) + { + case DRAWTYPE_NONE : + break; + + case DRAWTYPE_SLIDER : + { + break; + } + + case DRAWTYPE_FILL : + { + uint32_t color = control->color; + glBegin(GL_QUADS); + glColor4f(((color >> 16) & 0xff) * 1.0f / 255.0f, + ((color >> 8) & 0xff) * 1.0f / 255.0f, + ((color >> 0) & 0xff) * 1.0f / 255.0f, + ((color >> 24) & 0xff) * 1.0f / 255.0f); + quad(control->x, control->y, control->width, control->height); + glEnd(); + break; + } + + case DRAWTYPE_TEXT : + { + drawTextHorizontal(control->x, control->y, control->text); + break; + } + + case DRAWTYPE_IMAGE : + { + break; + } + } + } + + glFlush(); } - - - diff --git a/ogl_editor/src/RocketGui.c b/ogl_editor/src/RocketGui.c index 1e92ffb..3562ad1 100644 --- a/ogl_editor/src/RocketGui.c +++ b/ogl_editor/src/RocketGui.c @@ -490,8 +490,6 @@ void RocketGui_end() g_rocketGuiState.activeItem = -1; } - GFXBackend_draw(); - - //RocketWindow_refresh(); + GFXBackend_drawControls(&g_controls, s_controlId); }