fix quad element buffer generation
This commit is contained in:
parent
e74cc6bf94
commit
5069104cdb
@ -2,6 +2,8 @@
|
|||||||
#ifndef QUAD_ELEMENT_BUFFER_H
|
#ifndef QUAD_ELEMENT_BUFFER_H
|
||||||
#define QUAD_ELEMENT_BUFFER_H
|
#define QUAD_ELEMENT_BUFFER_H
|
||||||
|
|
||||||
|
#include "townengine/util.h"
|
||||||
|
|
||||||
#include <glad/glad.h>
|
#include <glad/glad.h>
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
@ -16,12 +18,14 @@ static void bind_quad_element_buffer(void) {
|
|||||||
glGenBuffers(1, &buffer);
|
glGenBuffers(1, &buffer);
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffer);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffer);
|
||||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER,
|
glBufferData(GL_ELEMENT_ARRAY_BUFFER,
|
||||||
QUAD_ELEMENT_BUFFER_LENGTH * 6,
|
QUAD_ELEMENT_BUFFER_LENGTH * 6 * sizeof(uint16_t),
|
||||||
NULL,
|
NULL,
|
||||||
GL_STATIC_DRAW);
|
GL_STATIC_DRAW);
|
||||||
|
|
||||||
uint16_t *const indices = glMapBuffer(GL_ELEMENT_ARRAY_BUFFER,
|
uint16_t *const indices = glMapBuffer(GL_ELEMENT_ARRAY_BUFFER,
|
||||||
GL_WRITE_ONLY);
|
GL_WRITE_ONLY);
|
||||||
|
if (!indices)
|
||||||
|
CRY("Quad indices generation", "glMapBuffer() failed");
|
||||||
|
|
||||||
for (uint16_t i = 0; i < QUAD_ELEMENT_BUFFER_LENGTH; ++i) {
|
for (uint16_t i = 0; i < QUAD_ELEMENT_BUFFER_LENGTH; ++i) {
|
||||||
indices[i * 6 + 0] = (uint16_t)(i * 4 + 0);
|
indices[i * 6 + 0] = (uint16_t)(i * 4 + 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user