load different textures

This commit is contained in:
2022-02-06 22:53:29 +01:00
parent 9df12e0fe1
commit 68f28a3294
27 changed files with 335 additions and 165 deletions

49
crosshair/CrossHair.cpp Normal file
View File

@ -0,0 +1,49 @@
//
// Created by lukas on 06.02.22.
//
#define GL_GLEXT_PROTOTYPES
#include <GL/gl.h>
#include "CrossHair.h"
VertexArray *CrossHair::setVertexArray() {
float fade[] = {
// face #1
-0.02, -0.05,
0.02, 0.02,
-0.05, 0.05,
};
// Generate a vertex buffer
auto *vb = new VertexBuffer(fade, sizeof(fade));
auto *va = new VertexArray(*vb);
va->add(0,2,3,0);
return va;
}
Shader CrossHair::setShader() {
const std::string vertsrc =
#include "vertex.shader"
const std::string fragsrc =
#include "fragment.shader"
Shader s;
s.loadShader(vertsrc, "", fragsrc);
s.Bind();
return s;
}
IndexBuffer *CrossHair::setIndexBuffer() {
unsigned indexx[] = {
0,2,1
};
return new IndexBuffer(indexx, 3);
}
void CrossHair::renderr() {
glUniform3f(getUniformhandle("u_color"), 1.0f, 1.0f, 1.0f);
RenderBase::render();
}

23
crosshair/CrossHair.h Normal file
View File

@ -0,0 +1,23 @@
//
// Created by lukas on 06.02.22.
//
#ifndef OPENGLTEST_CROSSHAIR_H
#define OPENGLTEST_CROSSHAIR_H
#include "../blocks/RenderBase.h"
class CrossHair : public RenderBase<CrossHair> {
public:
VertexArray *setVertexArray() override;
Shader setShader() override;
IndexBuffer *setIndexBuffer() override;
void renderr();
};
#endif //OPENGLTEST_CROSSHAIR_H

View File

@ -0,0 +1,8 @@
R"(#version 330 core
out vec4 color;
uniform vec3 u_color;
void main()
{
color = vec4(u_color, 0.5);
})";

9
crosshair/vertex.shader Normal file
View File

@ -0,0 +1,9 @@
R"(#version 330 core
// Input vertex data, different for all executions of this shader.
layout(location = 0) in vec2 vertexPosition_modelspace;
void main(){
// Output position of the vertex, in clip space : MVP * position
vec4 pos = vec4(vertexPosition_modelspace,0.0,1.0);
gl_Position = pos;
})";