void RendererOpenGL::test() { glClearColor(0.2f, 0.3f, 0.3f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); Texture* debugt = Locator::getLibraryTexture()->get("debug"); Texture* errort = Locator::getLibraryTexture()->get("error"); Shader* debugs = Locator::getLibraryShader()->get("basic-new"); debugt->bind(); debugs->Use(); drawQuadFull(500, 200, 1, 100, 100, debugs, debugt); drawQuadFull(550, 250, 2, 100, 100, debugs, debugt); drawQuadFull(200, 200, 2, 100, 100, debugs, debugt); drawQuadFull(250, 250, 1, 100, 100, debugs, debugt); //Still draws them in order of calling } //Just passes the correct texture coordinates so it will draw the whole texture void RendererOpenGL::drawQuadFull(int x, int y, int z, int width, int height, Shader* shader, Texture* texture, float rotation) { drawQuad(x, y, z, width, height, shader, texture, fullQuadDraw_, rotation); } void RendererOpenGL::drawQuad(int x, int y, int z, int width, int height, Shader* shader, Texture* texture, float tc[8], float rotation) { glm::mat4 model; // Translate into place model = glm::translate(model, glm::vec3(x, y, z)); // Fix non square rotation float diff = 0.0f; float rot = rotation; model = glm::translate(model, glm::vec3(width / 2, height / 2, 0.0f)); model = glm::rotate(model, glm::radians(rot), glm::vec3(0.0f, 0.0f, 1.0f)); model = glm::translate(model, glm::vec3(((-width / 2)), (-height / 2), 0.0f)); model = glm::scale(model, glm::vec3(width, height, 1.0f)); glUniformMatrix4fv(glGetUniformLocation(shader->Program, "model"), 1, GL_FALSE, glm::value_ptr(model)); glUniformMatrix4fv(glGetUniformLocation(shader->Program, "projection"), 1, GL_FALSE, glm::value_ptr(projection_)); glUniform2fv(glGetUniformLocation(shader->Program, "textureCoordinates"), 4, tc); glUniform4f(glGetUniformLocation(shader->Program, "color"), 1.0f, 1.0f, 1.0f, 1.0f); glUniform1i(glGetUniformLocation(shader->Program, "fragTexture"), 0); glBindBuffer(GL_ARRAY_BUFFER, quadVBO_); glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * 12, vertices_, GL_STATIC_DRAW); // Position attribute glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(GLfloat), (GLvoid*)0); glEnableVertexAttribArray(0); glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0); } ///////////////////////// Vertex Shader #version 330 core layout (location = 0) in vec3 position; out vec4 fColor; out vec2 fCoord; uniform mat4 model; uniform mat4 projection; uniform vec4 color; uniform vec2 textureCoordinates[4]; void main() { gl_Position = projection * model * vec4(position, 1.0f); fColor = color; fCoord = vec2(1 - textureCoordinates[gl_VertexID].x, 1 - textureCoordinates[gl_VertexID].y); }