SemiBrokend
This commit is contained in:
@@ -4,12 +4,14 @@
|
||||
#include <JGL/JGL.h>
|
||||
#include <GL/glut.h>
|
||||
#include "J3ML/LinearAlgebra/Transform2D.h"
|
||||
|
||||
#include <rewindow/types/window.h>
|
||||
namespace JGL
|
||||
{
|
||||
Vector2 ScreenToViewport(const Vector2 &v) {
|
||||
// TODO: Implement (CORRECT!!!) matrix transformation
|
||||
|
||||
Vector2 windowSize = ReWindow::RWindow::CurrentWindow()->getSize();
|
||||
|
||||
//Transform2D transform;
|
||||
|
||||
//transform = transform.Translate(1.f, 1.f); // Center
|
||||
@@ -18,11 +20,11 @@ namespace JGL
|
||||
|
||||
//return transform.Transform(v);
|
||||
|
||||
float x = v.x / 600.f;
|
||||
float y = v.y / 600.f;
|
||||
float x = (v.x) / windowSize.x;
|
||||
float y = (v.y) / windowSize.y;
|
||||
|
||||
return {
|
||||
x - .5f, y - .5f
|
||||
x, y
|
||||
};
|
||||
}
|
||||
|
||||
@@ -32,7 +34,7 @@ namespace JGL
|
||||
auto vp_pos = ScreenToViewport(pos);
|
||||
auto vp_size = ScreenToViewport(size);
|
||||
glBegin(GL_QUADS);
|
||||
glColor3f(color.r, color.g, color.b);
|
||||
glColor3f(color.r/255.f, color.g/255.f, color.b/255.f);
|
||||
glVertex2f(vp_pos.x, vp_pos.y);
|
||||
glVertex2f(vp_pos.x, vp_pos.y + vp_size.y);
|
||||
glVertex2f(vp_pos.x + vp_size.x, vp_pos.y + vp_size.y);
|
||||
|
@@ -129,6 +129,15 @@ namespace LearnOpenGL
|
||||
glUseProgram(ID);
|
||||
}
|
||||
|
||||
GLint Shader::getAttribute(const std::string& name) const
|
||||
{
|
||||
return glGetAttribLocation(ID, name.c_str());
|
||||
}
|
||||
|
||||
GLint Shader::getUniform(const std::string &name) const {
|
||||
return glGetUniformLocation(ID, name.c_str());
|
||||
}
|
||||
|
||||
void Shader::setBool(const std::string &name, bool value) const {
|
||||
glUniform1i(glGetUniformLocation(ID, name.c_str()), (int)value);
|
||||
}
|
||||
|
Reference in New Issue
Block a user