diff options
Diffstat (limited to 'src/graphics')
-rw-r--r-- | src/graphics/shader.c | 4 | ||||
-rw-r--r-- | src/graphics/texture.c | 2 | ||||
-rw-r--r-- | src/graphics/vertex_buffer.c | 8 |
3 files changed, 7 insertions, 7 deletions
diff --git a/src/graphics/shader.c b/src/graphics/shader.c index 3d8a204..4aedb87 100644 --- a/src/graphics/shader.c +++ b/src/graphics/shader.c @@ -40,7 +40,7 @@ static void print_compile_log(mgl_context *context, unsigned int shader_id, cons static void mgl_shader_unload(mgl_shader *self); -static int mgl_shader_load_from_memory(mgl_shader *self, unsigned char *shader_data, int shader_size, mgl_shader_type shader_type) { +static int mgl_shader_load_from_memory(mgl_shader *self, const unsigned char *shader_data, int shader_size, mgl_shader_type shader_type) { self->id = 0; self->shader_type = shader_type; @@ -127,7 +127,7 @@ int mgl_shader_program_add_shader_from_file(mgl_shader_program *self, const char return 0; } -int mgl_shader_program_add_shader_from_memory(mgl_shader_program *self, unsigned char *shader_data, int shader_size, mgl_shader_type shader_type){ +int mgl_shader_program_add_shader_from_memory(mgl_shader_program *self, const unsigned char *shader_data, int shader_size, mgl_shader_type shader_type){ mgl_shader shader; if(mgl_shader_load_from_memory(&shader, shader_data, shader_size, shader_type) != 0) return -1; diff --git a/src/graphics/texture.c b/src/graphics/texture.c index 1427e6b..c70c0f9 100644 --- a/src/graphics/texture.c +++ b/src/graphics/texture.c @@ -63,7 +63,7 @@ int mgl_texture_load_from_file(mgl_texture *self, const char *filepath, mgl_text return result; } -int mgl_texture_load_from_image(mgl_texture *self, mgl_image *image, mgl_texture_load_options *load_options) { +int mgl_texture_load_from_image(mgl_texture *self, const mgl_image *image, mgl_texture_load_options *load_options) { return mgl_texture_load_from_memory(self, image->data, image->width, image->height, image->format, load_options); } diff --git a/src/graphics/vertex_buffer.c b/src/graphics/vertex_buffer.c index df2c139..746cfeb 100644 --- a/src/graphics/vertex_buffer.c +++ b/src/graphics/vertex_buffer.c @@ -60,12 +60,12 @@ void mgl_vertex_buffer_deinit(mgl_vertex_buffer *self) { static void mgl_vertex_buffer_set_gl_buffer_pointers(mgl_context *context) { context->gl.glVertexPointer(2, GL_FLOAT, sizeof(mgl_vertex), (void*)offsetof(mgl_vertex, position)); - context->gl.glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(mgl_vertex), (void*)offsetof(mgl_vertex, color)); context->gl.glTexCoordPointer(2, GL_FLOAT, sizeof(mgl_vertex), (void*)offsetof(mgl_vertex, texcoords)); + context->gl.glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(mgl_vertex), (void*)offsetof(mgl_vertex, color)); } /* TODO: Check for glBufferData error */ -static int mgl_vertex_buffer_resize(mgl_vertex_buffer *self, mgl_vertex *vertices, size_t vertex_count) { +static int mgl_vertex_buffer_resize(mgl_vertex_buffer *self, const mgl_vertex *vertices, size_t vertex_count) { mgl_context *context = mgl_get_context(); context->gl.glBindBuffer(GL_ARRAY_BUFFER, self->id); context->gl.glBufferData(GL_ARRAY_BUFFER, sizeof(mgl_vertex) * vertex_count, vertices, mgl_vertex_buffer_usage_to_gl_usage(self->usage)); @@ -80,7 +80,7 @@ void mgl_vertex_buffer_set_position(mgl_vertex_buffer *self, mgl_vec2f position) } /* TODO: Check for glBufferSubData error */ -int mgl_vertex_buffer_update(mgl_vertex_buffer *self, mgl_vertex *vertices, size_t vertex_count) { +int mgl_vertex_buffer_update(mgl_vertex_buffer *self, const mgl_vertex *vertices, size_t vertex_count) { if(vertex_count != self->vertex_count) return mgl_vertex_buffer_resize(self, vertices, vertex_count); @@ -93,7 +93,7 @@ int mgl_vertex_buffer_update(mgl_vertex_buffer *self, mgl_vertex *vertices, size } /* TODO: Optimize bind texture */ -void mgl_vertex_buffer_draw(mgl_context *context, mgl_vertex_buffer *self, mgl_texture *texture) { +void mgl_vertex_buffer_draw(mgl_context *context, mgl_vertex_buffer *self, const mgl_texture *texture) { if(self->vertex_count == 0 || self->id == 0) return; |