12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- #include "rendering/Renderer.h"
- #include "rendering/wrapper/GLWrapper.h"
- Renderer::Renderer(const WindowSize& size, Shader& shader) : size(size), shader(shader), texture(true), color(true) {
- shader.use();
- GLWrapper::enableBlending();
- setTextureMode(false);
- setColorMode(false);
- }
- void Renderer::pop() {
- stack.pop();
- }
- void Renderer::push() {
- stack.push();
- }
- void Renderer::update() {
- shader.setMatrix("model", stack.get().getValues());
- }
- Renderer& Renderer::scale(float sx, float sy) {
- stack.get().scale(sx, sy);
- return *this;
- }
- Renderer& Renderer::scale(float s) {
- stack.get().scale(s);
- return *this;
- }
- Renderer& Renderer::translate(float tx, float ty) {
- stack.get().translate(tx, ty);
- return *this;
- }
- Renderer& Renderer::translateX(float tx) {
- stack.get().translateX(tx);
- return *this;
- }
- Renderer& Renderer::translateY(float ty) {
- stack.get().translateY(ty);
- return *this;
- }
- Renderer& Renderer::translateTo(float tx, float ty) {
- stack.get().translateTo(tx, ty);
- return *this;
- }
- Renderer& Renderer::rotate(float degrees) {
- stack.get().rotate(degrees);
- return *this;
- }
- void Renderer::setTextureMode(bool b) {
- if(b != texture) {
- texture = b;
- shader.setInt("useTexture", b);
- }
- }
- void Renderer::setColorMode(bool b) {
- if(b != color) {
- color = b;
- shader.setInt("useColor", b);
- }
- }
- void Renderer::drawString(float x, float y, const char* text) {
- setTextureMode(true);
- setColorMode(true);
- fontRenderer.drawString(x, y, text);
- }
|