renderer2d quads work (without textures or pixel coordinates)
This commit is contained in:
parent
5c8abf1a7d
commit
213e530d88
|
@ -87,7 +87,7 @@ add_library(skunkworks STATIC
|
|||
src/types.c
|
||||
src/vec2i.c
|
||||
src/vertex_buffer.c
|
||||
src/window.c include/vec2f.h src/vec2f.c src/vec4f.c include/vec4f.h)
|
||||
src/window.c include/vec2f.h src/vec2f.c src/vec4f.c include/vec4f.h src/renderer2d_frag.glsl src/renderer2d_vert.glsl src/shader_copy_frag.glsl src/shader_copy_vert.glsl src/shader_scale_frag.glsl src/gsa_vert.glsl src/gsa_frag.glsl)
|
||||
|
||||
add_executable(skip
|
||||
tools/skip.c)
|
||||
|
|
|
@ -36,11 +36,18 @@ struct sw_renderer2d *sw_renderer2d_create() {
|
|||
glGenBuffers(1, &ren->vbo);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, ren->vbo);
|
||||
|
||||
/* todo: vertex attrib thingies */
|
||||
glVertexAttribPointer(
|
||||
0, 2, GL_FLOAT, GL_FALSE, sizeof(struct vert), 0
|
||||
);
|
||||
glVertexAttribPointer(
|
||||
2,
|
||||
4,
|
||||
GL_FLOAT,
|
||||
GL_FALSE,
|
||||
sizeof(struct vert),
|
||||
(void *) (2 * sizeof(f32)));
|
||||
glEnableVertexAttribArray(0);
|
||||
glEnableVertexAttribArray(2);
|
||||
|
||||
glBindVertexArray(0);
|
||||
|
||||
|
@ -88,13 +95,7 @@ static void r_enter(struct sw_window *win, void *data) {
|
|||
|
||||
ren = data;
|
||||
sw_vertex_buffer_clear(ren->vertex_buffer);
|
||||
|
||||
sw_renderer2d_draw_quad(
|
||||
ren,
|
||||
sw_vec2f(-0.5f, -0.5f),
|
||||
sw_vec2f(0.5f, -0.5f),
|
||||
sw_vec2f(-0.5f, 0.5f),
|
||||
sw_vec2f(0.5f, 0.5f));
|
||||
ren->color = sw_vec4f(1.f, 1.f, 1.f, 1.f);
|
||||
|
||||
glBindVertexArray(ren->vao);
|
||||
sw_shaderprogram_use(ren->shader);
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#version 460
|
||||
|
||||
in vec4 vcolor;
|
||||
layout(location = 0) out vec4 color;
|
||||
|
||||
void main() {
|
||||
color = vec4(0.1, 0.2, 0.3, 1.0);
|
||||
color = vcolor;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
#version 460
|
||||
|
||||
layout(location = 0) in vec2 pos;
|
||||
layout(location = 2) in vec4 color;
|
||||
|
||||
out vec4 vcolor;
|
||||
|
||||
void main() {
|
||||
gl_Position = vec4(pos, 0.0, 1.0);
|
||||
vcolor = color;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue