[WIP]
This commit is contained in:
parent
373196717f
commit
0b6c282507
48
src/glez.c
48
src/glez.c
@ -53,15 +53,19 @@ void glez_resize(int width, int height)
|
|||||||
void glez_line(float x, float y, float dx, float dy, glez_rgba_t color,
|
void glez_line(float x, float y, float dx, float dy, glez_rgba_t color,
|
||||||
float thickness)
|
float thickness)
|
||||||
{
|
{
|
||||||
/*x += 0.375f;
|
/*x += 0.325f;
|
||||||
y += 0.375f;*/
|
y += 0.325f;
|
||||||
|
|
||||||
GLuint indices[6] = { 0, 1, 3, 3, 2, 0 };
|
dx -= 0.325f;
|
||||||
|
dy -= 0.325f;*/
|
||||||
|
x += 1;
|
||||||
|
|
||||||
|
GLuint indices[6] = { 0, 3, 2, 2, 1, 0 };
|
||||||
|
|
||||||
struct vertex_main vertices[4];
|
struct vertex_main vertices[4];
|
||||||
|
|
||||||
float nx = -dy;
|
float nx = dx;
|
||||||
float ny = dx;
|
float ny = dy;
|
||||||
|
|
||||||
float ex = x + dx;
|
float ex = x + dx;
|
||||||
float ey = y + dy;
|
float ey = y + dy;
|
||||||
@ -71,27 +75,32 @@ void glez_line(float x, float y, float dx, float dy, glez_rgba_t color,
|
|||||||
if (length == 0)
|
if (length == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
length /= thickness;
|
|
||||||
nx /= length;
|
nx /= length;
|
||||||
ny /= length;
|
ny /= length;
|
||||||
|
|
||||||
|
nx *= thickness * 0.5f;
|
||||||
|
ny *= thickness * 0.5f;
|
||||||
|
|
||||||
vertices[0].position.x = x - nx;
|
float px = ny;
|
||||||
vertices[0].position.y = y - ny;
|
float py = -nx;
|
||||||
|
|
||||||
|
vertices[0].position.x = x + -nx + px;
|
||||||
|
vertices[0].position.y = y + -ny + py;
|
||||||
vertices[0].color = color;
|
vertices[0].color = color;
|
||||||
vertices[0].mode = DRAW_MODE_PLAIN;
|
vertices[0].mode = DRAW_MODE_PLAIN;
|
||||||
|
|
||||||
vertices[1].position.x = x + nx;
|
vertices[1].position.x = ex + nx + px;
|
||||||
vertices[1].position.y = y + ny;
|
vertices[1].position.y = ey + ny + py;
|
||||||
vertices[1].color = color;
|
vertices[1].color = color;
|
||||||
vertices[1].mode = DRAW_MODE_PLAIN;
|
vertices[1].mode = DRAW_MODE_PLAIN;
|
||||||
|
|
||||||
vertices[2].position.x = ex - nx;
|
vertices[2].position.x = ex + nx + -px;
|
||||||
vertices[2].position.y = ey - ny;
|
vertices[2].position.y = ey + ny + -py;
|
||||||
vertices[2].color = color;
|
vertices[2].color = color;
|
||||||
vertices[2].mode = DRAW_MODE_PLAIN;
|
vertices[2].mode = DRAW_MODE_PLAIN;
|
||||||
|
|
||||||
vertices[3].position.x = ex + nx;
|
vertices[3].position.x = x + -nx + -px;
|
||||||
vertices[3].position.y = ey + ny;
|
vertices[3].position.y = y + -ny + -py;
|
||||||
vertices[3].color = color;
|
vertices[3].color = color;
|
||||||
vertices[3].mode = DRAW_MODE_PLAIN;
|
vertices[3].mode = DRAW_MODE_PLAIN;
|
||||||
|
|
||||||
@ -100,9 +109,6 @@ void glez_line(float x, float y, float dx, float dy, glez_rgba_t color,
|
|||||||
|
|
||||||
void glez_rect(float x, float y, float w, float h, glez_rgba_t color)
|
void glez_rect(float x, float y, float w, float h, glez_rgba_t color)
|
||||||
{
|
{
|
||||||
/*x += 0.375f;
|
|
||||||
y += 0.375f;*/
|
|
||||||
|
|
||||||
struct vertex_main vertices[4];
|
struct vertex_main vertices[4];
|
||||||
GLuint indices[6] = { 0, 1, 2, 2, 3, 0 };
|
GLuint indices[6] = { 0, 1, 2, 2, 3, 0 };
|
||||||
|
|
||||||
@ -132,10 +138,10 @@ void glez_rect(float x, float y, float w, float h, glez_rgba_t color)
|
|||||||
void glez_rect_outline(float x, float y, float w, float h, glez_rgba_t color,
|
void glez_rect_outline(float x, float y, float w, float h, glez_rgba_t color,
|
||||||
float thickness)
|
float thickness)
|
||||||
{
|
{
|
||||||
glez_line(x, y, w, 0, color, thickness);
|
glez_rect(x, y, w, 1, color);
|
||||||
glez_line(x + w, y, 0, h, color, thickness);
|
glez_rect(x, y, 1, h, color);
|
||||||
glez_line(x + w, y + h, -w, 0, color, thickness);
|
glez_rect(x + w - 1, y, 1, h, color);
|
||||||
glez_line(x, y + h, 0, -h, color, thickness);
|
glez_rect(x, y + h - 1, w, 1, color);
|
||||||
}
|
}
|
||||||
void glez_rect_textured(float x, float y, float w, float h, glez_rgba_t color,
|
void glez_rect_textured(float x, float y, float w, float h, glez_rgba_t color,
|
||||||
glez_texture_t texture, float tx, float ty, float tw,
|
glez_texture_t texture, float tx, float ty, float tw,
|
||||||
|
@ -46,7 +46,7 @@ const char *shader_ultimate_vert =
|
|||||||
"{\n"
|
"{\n"
|
||||||
" frag_TexCoord = tex_coord;\n"
|
" frag_TexCoord = tex_coord;\n"
|
||||||
" frag_Color = color;\n"
|
" frag_Color = color;\n"
|
||||||
" gl_Position = projection*(view*(model*vec4(vertex,0.0,1.0)));\n"
|
" gl_Position = projection*(view*(model*(vec4(vertex,0.0,1.0))));\n"
|
||||||
" frag_DrawMode = drawmode;\n"
|
" frag_DrawMode = drawmode;\n"
|
||||||
"}";
|
"}";
|
||||||
const char *shader_ultimate_frag =
|
const char *shader_ultimate_frag =
|
||||||
@ -111,7 +111,7 @@ void program_init(int width, int height)
|
|||||||
mat4_set_identity(&model);
|
mat4_set_identity(&model);
|
||||||
mat4_set_identity(&view);
|
mat4_set_identity(&view);
|
||||||
mat4_set_identity(&projection);
|
mat4_set_identity(&projection);
|
||||||
mat4_set_orthographic(&projection, 0, width, height, 0, -1, 1);
|
mat4_set_orthographic(&projection, 0, width, height, 0, 0, 1);
|
||||||
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(program.shader, "model"), 1, 0,
|
glUniformMatrix4fv(glGetUniformLocation(program.shader, "model"), 1, 0,
|
||||||
model.data);
|
model.data);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user