bunch of test things

also new camera class
This commit is contained in:
Claire Schwarzer 2026-02-02 03:12:29 +01:00
parent b47c5e27d8
commit 89e47fa56c
10 changed files with 496 additions and 54 deletions

12
engine/camera.h Normal file
View file

@ -0,0 +1,12 @@
#ifndef ENGINE2026_CAMERA_H
#define ENGINE2026_CAMERA_H
class Camera
{
public:
Camera();
};
#endif

View file

@ -1,5 +1,4 @@
#pragma once

#include <exception>
#include <vector>
#include <glad/glad.h>
@ -59,8 +58,9 @@ public:
void Draw() const
{
glBindVertexArray(VAO);
glDrawElements(GL_TRIANGLES, static_cast<GLsizei>(indexCount),
GL_UNSIGNED_INT, nullptr);
glDrawArrays(GL_TRIANGLES, 0, 36);
//glBindVertexArray(VAO);
//glDrawElements(GL_TRIANGLES, static_cast<GLsizei>(indexCount),
// GL_UNSIGNED_INT, nullptr);
}
};

View file

@ -79,30 +79,62 @@ public:
};
// Setters
void setBool(const std::string &name, bool value) const
{
glUniform1i(glGetUniformLocation(ID, name.c_str()), (int)value);
}
void setInt(const std::string &name, int value) const
{
glUniform1i(glGetUniformLocation(ID, name.c_str()), value);
}
void setFloat(const std::string &name, float value) const
{
glUniform1f(glGetUniformLocation(ID, name.c_str()), value);
}
void setVec2(const std::string &name, float v0, float v1) const
{
glUniform2f(glGetUniformLocation(ID, name.c_str()), v0, v1);
}
void setVec3(const std::string &name, float v0, float v1, float v2) const
{
glUniform3f(glGetUniformLocation(ID, name.c_str()), v0, v1, v2);
}
void setVec4(const std::string &name, float v0, float v1, float v2, float v3) const
{
glUniform4f(glGetUniformLocation(ID, name.c_str()), v0, v1, v2, v3);
}
void setBool(const std::string &name, bool value) const
{
glUniform1i(glGetUniformLocation(ID, name.c_str()), (int)value);
}
// ------------------------------------------------------------------------
void setInt(const std::string &name, int value) const
{
glUniform1i(glGetUniformLocation(ID, name.c_str()), value);
}
// ------------------------------------------------------------------------
void setFloat(const std::string &name, float value) const
{
glUniform1f(glGetUniformLocation(ID, name.c_str()), value);
}
// ------------------------------------------------------------------------
void setVec2(const std::string &name, const glm::vec2 &value) const
{
glUniform2fv(glGetUniformLocation(ID, name.c_str()), 1, &value[0]);
}
void setVec2(const std::string &name, float x, float y) const
{
glUniform2f(glGetUniformLocation(ID, name.c_str()), x, y);
}
// ------------------------------------------------------------------------
void setVec3(const std::string &name, const glm::vec3 &value) const
{
glUniform3fv(glGetUniformLocation(ID, name.c_str()), 1, &value[0]);
}
void setVec3(const std::string &name, float x, float y, float z) const
{
glUniform3f(glGetUniformLocation(ID, name.c_str()), x, y, z);
}
// ------------------------------------------------------------------------
void setVec4(const std::string &name, const glm::vec4 &value) const
{
glUniform4fv(glGetUniformLocation(ID, name.c_str()), 1, &value[0]);
}
void setVec4(const std::string &name, float x, float y, float z, float w) const
{
glUniform4f(glGetUniformLocation(ID, name.c_str()), x, y, z, w);
}
// ------------------------------------------------------------------------
void setMat2(const std::string &name, const glm::mat2 &mat) const
{
glUniformMatrix2fv(glGetUniformLocation(ID, name.c_str()), 1, GL_FALSE, &mat[0][0]);
}
// ------------------------------------------------------------------------
void setMat3(const std::string &name, const glm::mat3 &mat) const
{
glUniformMatrix3fv(glGetUniformLocation(ID, name.c_str()), 1, GL_FALSE, &mat[0][0]);
}
// ------------------------------------------------------------------------
void setMat4(const std::string &name, const glm::mat4 &mat) const
{
glUniformMatrix4fv(glGetUniformLocation(ID, name.c_str()), 1, GL_FALSE, &mat[0][0]);
}
private:
void checkCompileErrors(unsigned int shader, std::string type)

View file

@ -1,10 +1,9 @@
#pragma once

#include <iostream>
#include <glad/glad.h>
#define STB_IMAGE_IMPLEMENTATION
#include <stb_image/stb_image.h>
#include <stb/stb_image.h>
class Texture
{
@ -48,7 +47,7 @@ public:
void Draw() const
{
glActiveTexture(GL_TEXTURE);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, ID);
}
};