Make skybox a cpp.
This commit is contained in:
@@ -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)
|
||||
|
||||
|
@@ -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();
|
@@ -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
25
src/types/skybox.cpp
Normal 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();
|
||||
}
|
Reference in New Issue
Block a user