add crosshair
blockgen with sin
This commit is contained in:
18
blocks/AirBlock.h
Normal file
18
blocks/AirBlock.h
Normal file
@ -0,0 +1,18 @@
|
||||
//
|
||||
// Created by lukas on 08.02.22.
|
||||
//
|
||||
|
||||
#ifndef OPENGLTEST_AIRBLOCK_H
|
||||
#define OPENGLTEST_AIRBLOCK_H
|
||||
|
||||
#include "BaseBlock.h"
|
||||
|
||||
class AirBlock : public BaseBlock{
|
||||
public:
|
||||
AirBlock(uint xpos, uint ypos, uint zpos) : BaseBlock(xpos, ypos, zpos, nullptr) {}
|
||||
|
||||
void render() override {
|
||||
}
|
||||
};
|
||||
|
||||
#endif //OPENGLTEST_AIRBLOCK_H
|
@ -2,9 +2,6 @@
|
||||
// Created by lukas on 04.02.22.
|
||||
//
|
||||
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
|
||||
#include <GL/gl.h>
|
||||
#include <cstdlib>
|
||||
#include <glm/ext/matrix_float4x4.hpp>
|
||||
#include <glm/ext/matrix_transform.hpp>
|
||||
@ -12,6 +9,8 @@
|
||||
#include "BlockRenderer.h"
|
||||
|
||||
void BaseBlock::render() {
|
||||
BlockRenderer::getInstance()->s.Bind();
|
||||
|
||||
glm::mat4 position = glm::translate(glm::mat4(1.0f), glm::vec3((float) xpos * 2, (float) ypos * 2, (float) zpos * 2));
|
||||
glUniformMatrix4fv(BlockRenderer::getInstance()->getUniformhandle("translation"), 1, GL_FALSE, &position[0][0]);
|
||||
|
||||
|
@ -8,6 +8,8 @@
|
||||
|
||||
#include "BlockRenderer.h"
|
||||
#include "../gl/Texture.h"
|
||||
#include <glm/ext/matrix_float4x4.hpp>
|
||||
#include <glm/ext/matrix_transform.hpp>
|
||||
|
||||
class BaseBlock {
|
||||
private:
|
||||
@ -17,7 +19,7 @@ private:
|
||||
public:
|
||||
BaseBlock(uint xpos, uint ypos, uint zpos, Texture *texture);
|
||||
|
||||
void render();
|
||||
virtual void render();
|
||||
};
|
||||
|
||||
|
||||
|
@ -14,6 +14,12 @@ template<class T>
|
||||
class RenderBase {
|
||||
private:
|
||||
static RenderBase *instance;
|
||||
protected:
|
||||
RenderBase() {
|
||||
if (instance) throw std::logic_error("Instance already exists");
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public:
|
||||
virtual VertexArray *setVertexArray() = 0;
|
||||
|
||||
@ -23,11 +29,10 @@ public:
|
||||
|
||||
static RenderBase *getInstance() {
|
||||
if (instance == nullptr) {
|
||||
instance = new T();
|
||||
new T();
|
||||
instance->init();
|
||||
}
|
||||
return instance;
|
||||
|
||||
}
|
||||
|
||||
public:
|
||||
@ -37,9 +42,9 @@ public:
|
||||
Shader s;
|
||||
|
||||
public:
|
||||
RenderBase() {};
|
||||
|
||||
void render() {
|
||||
|
||||
virtual void render() {
|
||||
r.render(*va, *ib, s);
|
||||
}
|
||||
|
||||
@ -49,7 +54,9 @@ public:
|
||||
ib = setIndexBuffer();
|
||||
}
|
||||
|
||||
void deinit() {}
|
||||
void deinit() {
|
||||
glDeleteProgram(s.getHandle());
|
||||
}
|
||||
|
||||
unsigned getMVPhandle() {
|
||||
return s.getUniformHandle("MVP");
|
||||
|
Reference in New Issue
Block a user