Basic UI drawing working
This commit is contained in:
parent
37661c61a6
commit
64e2a5bd47
@ -49,6 +49,8 @@ void Editor_guiUpdate()
|
||||
RocketGui_textLabel("Test2");
|
||||
RocketGui_textLabel("Test");
|
||||
|
||||
RocketGui_fill(0xff0203ff, 10, 10, 100, 100);
|
||||
|
||||
RocketGui_end();
|
||||
}
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
#include "Core/Types.h"
|
||||
#include "../GFXBackend.h"
|
||||
#include "../MicroknightFont.h"
|
||||
#include <OpenGL/OpenGL.h>
|
||||
#include <OpenGL/gl.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#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();
|
||||
}
|
||||
|
||||
|
||||
@ -490,8 +490,6 @@ void RocketGui_end()
|
||||
g_rocketGuiState.activeItem = -1;
|
||||
}
|
||||
|
||||
GFXBackend_draw();
|
||||
|
||||
//RocketWindow_refresh();
|
||||
GFXBackend_drawControls(&g_controls, s_controlId);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user