Make skybox a cpp.

This commit is contained in:
2024-01-05 16:00:17 -05:00
parent 8eac45ffe4
commit 837bbbcec8
4 changed files with 33 additions and 25 deletions

View File

@@ -47,7 +47,8 @@ CPMAddPackage(
add_library(Re3D SHARED ${SOURCES})
add_library(Re3D SHARED ${SOURCES}
src/types/skybox.cpp)
# Why god???
set_target_properties(Re3D PROPERTIES LINKER_LANGUAGE CXX)

View File

@@ -1,35 +1,16 @@
#pragma once
#include "entityList.h"
#include "moby.h"
#include "camera.h"
#include "vertex.h"
#include <types/entity.h>
#include <types/vertex.h>
class Skybox : public Entity {
public:
VertexArray geometry;
void pre_render() {
//PLACEHOLDER.
if (engine->frameCount == 1) {
geometry.load("assets/models/cube.obj");
}
}
void pre_render() override;
void render() {
glColor3f(0.75,0.75,0.75);
glPushMatrix();
glTranslatef(position.x + 4,position.y,position.z);
//geometry.draw();
glPopMatrix();
}
void render() override;
};
inline Skybox* getSkybox() {
for (auto& e : entityList)
if (auto* s = dynamic_cast<Skybox*>(e))
return s;
std::cerr << "Attempt to get Skybox pointer while not in scene." << std::endl;
engine->quit();
}
Skybox* getSkybox();

View File

@@ -8,6 +8,7 @@
#include <sstream>
#include <GL/gl.h>
#include <types/vector.h>
#include <engine/engine.h>
struct Vertex {
GLfloat x, y, z;

25
src/types/skybox.cpp Normal file
View File

@@ -0,0 +1,25 @@
#include <types/skybox.h>
#include <types/entityList.h>
#include <engine/engine.h>
void Skybox::pre_render() {
//PLACEHOLDER.
if (engine->frameCount == 1) {
geometry.load("assets/models/cube.obj");
}
}
void Skybox::render() {
glColor3f(0.75,0.75,0.75);
glPushMatrix();
//glTranslatef(position.x + 4,position.y,position.z);
//geometry.draw();
glPopMatrix();
}
Skybox* getSkybox() {
for (auto& e : entityList)
if (auto* s = dynamic_cast<Skybox*>(e))
return s;
std::cerr << "Attempt to get Skybox pointer while not in scene." << std::endl;
engine->quit();
}