Remove GLU
This commit is contained in:
@@ -29,17 +29,6 @@ SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
|
||||
#Copy the assets to the build directory.
|
||||
file(COPY "assets" DESTINATION "${PROJECT_BINARY_DIR}")
|
||||
file(COPY "cfg" DESTINATION "${PROJECT_BINARY_DIR}")
|
||||
set(gluURL "https://git.redacted.cc/Redacted/glu.git")
|
||||
if(UNIX AND NOT APPLE)
|
||||
find_program(MESON_EXECUTABLE meson)
|
||||
if(NOT MESON_EXECUTABLE)
|
||||
message(FATAL_ERROR "Meson not found. Please install Meson before proceeding.")
|
||||
endif()
|
||||
execute_process(
|
||||
COMMAND bash -c "rm -rf glu && mkdir lib && git clone ${gluURL} && cd glu && meson setup builddir && cd builddir && meson compile && cd src && mv libGLU.so.1.3.1 ../../../lib/libGLU.so"
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
#TODO: Publish release
|
||||
CPMAddPackage(
|
||||
@@ -101,7 +90,6 @@ include_directories(
|
||||
${glad_SOURCE_DIR}/include
|
||||
${uuid_v4_SOURCE_DIR}
|
||||
${archive_SOURCE_DIR}/include
|
||||
${PROJECT_BINARY_DIR}/glu/include
|
||||
${Collage_SOURCE_DIR}/include
|
||||
${Event_SOURCE_DIR}/include
|
||||
${JGL_SOURCE_DIR}/include
|
||||
|
@@ -62,10 +62,10 @@ public:
|
||||
void quit() const;
|
||||
void quit (ENGINE_ERROR_CODE code);
|
||||
static float getGLVersion();
|
||||
void initGL();
|
||||
void initGL() const;
|
||||
void loadConfig();
|
||||
|
||||
void init();
|
||||
static void init();
|
||||
void preRender();
|
||||
void render();
|
||||
void postRender();
|
||||
|
@@ -6,9 +6,9 @@ set_target_properties(Re3D-RuntimeTest PROPERTIES LINK_FLAGS "-Wl,-rpath,./lib")
|
||||
|
||||
# TODO: Link all applicable dependencies to Re3D directly
|
||||
if(UNIX AND NOT APPLE)
|
||||
target_link_libraries(Re3D-RuntimeTest PUBLIC Re3D ReWindowLibrary ReHardwareID J3ML soil uuid_v4 GL glad Collage JGL archive ${PROJECT_BINARY_DIR}/lib/libGLU.so)
|
||||
target_link_libraries(Re3D-RuntimeTest PUBLIC Re3D ReWindowLibrary ReHardwareID J3ML soil uuid_v4 GL glad Collage JGL archive)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
target_link_libraries(Re3D-RuntimeTest PUBLIC Re3D ReWindowLibrary ReHardwareID J3ML soil uuid_v4 GL GLU Collage glad archive)
|
||||
target_link_libraries(Re3D-RuntimeTest PUBLIC Re3D ReWindowLibrary ReHardwareID J3ML soil uuid_v4 GL Collage glad archive)
|
||||
endif()
|
||||
|
@@ -6,13 +6,22 @@
|
||||
#include <types/entity/camera.h>
|
||||
#include <types/entity/skybox.h>
|
||||
|
||||
#include <GL/glu.h>
|
||||
|
||||
#include <JGL/JGL.h>
|
||||
#include <JGL/Colors.h>
|
||||
|
||||
using namespace J3ML;
|
||||
|
||||
std::array<float, 16> perspective(float fov, float aspect, float nearPlane, float farPlane) {
|
||||
std::array<float, 16> result{};
|
||||
float f = 1.0f / tan(fov * 0.5f * M_PI / 180.0f);
|
||||
result[0] = f / aspect;
|
||||
result[5] = f;
|
||||
result[10] = (farPlane + nearPlane) / (nearPlane - farPlane);
|
||||
result[11] = -1.0f;
|
||||
result[14] = (2.0f * farPlane * nearPlane) / (nearPlane - farPlane);
|
||||
return result;
|
||||
}
|
||||
|
||||
void Engine::quit() const {
|
||||
window->destroyWindow();
|
||||
exit(0);
|
||||
@@ -52,29 +61,19 @@ void outputErrorCode() {
|
||||
}
|
||||
}
|
||||
|
||||
float Engine::getGLVersion()
|
||||
{
|
||||
float Engine::getGLVersion() {
|
||||
const std::string full_gl_ver = (const char*) (glGetString(GL_VERSION));
|
||||
const std::string gl_major = full_gl_ver.substr(0, 3);
|
||||
return std::stof(gl_major);
|
||||
}
|
||||
|
||||
void Engine::initGL()
|
||||
{
|
||||
void Engine::initGL() const {
|
||||
gladLoadGL();
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
//glOrtho(-1.0f, 1.0f, -1.0f, 1.0f, -0.5f, 0.5f);
|
||||
auto window_size = window->getSize();
|
||||
auto width_over_height = (float) window_size[0] / (float) window_size[1];
|
||||
auto aspect = width_over_height;
|
||||
gluPerspective(this->fov, aspect, this->nearPlane, this->farPlane);
|
||||
this->glError = glGetError();
|
||||
if (glError != GL_NO_ERROR) {
|
||||
std::cerr << "OpenGL: " << gluErrorString(glError);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
auto aspect = (float) window_size[0] / (float) window_size[1];
|
||||
glMultMatrixf(perspective(this->fov, aspect, nearPlane, farPlane).data());
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||
@@ -83,13 +82,11 @@ void Engine::initGL()
|
||||
glDepthFunc(GL_LESS);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glDepthMask(GL_TRUE);
|
||||
//glClearDepth(1.0f);
|
||||
glEnable(GL_CULL_FACE);
|
||||
glEnable(GL_VERTEX_ARRAY);
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_LIGHT0);
|
||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
|
||||
|
||||
}
|
||||
|
||||
void Engine::init()
|
||||
@@ -130,7 +127,7 @@ void Engine::initGL()
|
||||
}
|
||||
engine->glError = glGetError();
|
||||
if (engine->glError != GL_NO_ERROR) {
|
||||
std::cerr << "OpenGL: " << gluErrorString(engine->glError) << std::endl;
|
||||
std::cerr << "OpenGL: " << glError << std::endl;
|
||||
exit(0);
|
||||
}
|
||||
glColor4f(0.f, 0.f, 0.f, 0.f);
|
||||
@@ -249,7 +246,6 @@ void Engine::loadConfig() {
|
||||
//int x, y;
|
||||
//stream >> x >> y;
|
||||
//window->setSize(x,y);
|
||||
//gluPerspective(this->fov, x / y, this->nearPlane, this->farPlane);
|
||||
//glViewport(0,0,x,y);
|
||||
//}
|
||||
if (prefix == "Fullscreen:")
|
||||
|
@@ -1,17 +1,27 @@
|
||||
#include <array>
|
||||
#include <types/entity/camera.h>
|
||||
#include <engine/occlusion.h>
|
||||
#include <GL/glu.h>
|
||||
|
||||
std::array<GLfloat, 16> lookAt(const Vector3& eye, const Vector3& center, const Vector3& up) {
|
||||
Vector3 f = (center - eye).Normalize();
|
||||
Vector3 upN = up.Normalize();
|
||||
Vector3 s = f.Cross(upN).Normalize();
|
||||
Vector3 u = s.Cross(f);
|
||||
|
||||
std::array<GLfloat, 16> result = {
|
||||
s.x, u.x, -f.x, 0.0f,
|
||||
s.y, u.y, -f.y, 0.0f,
|
||||
s.z, u.z, -f.z, 0.0f,
|
||||
-s.Dot(eye), -u.Dot(eye), f.Dot(eye), 1.0f
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
void Camera::render() {
|
||||
glRotatef(angle.x,1.0f, 0.0f, 0.0f);
|
||||
glRotatef(angle.y,0.0f, 1.0f, 0.0f);
|
||||
glRotatef(angle.z,0.0f, 0.0f, 1.0f);
|
||||
|
||||
glTranslatef(0.0f, 0.0f, 0.0f);
|
||||
|
||||
gluLookAt(position.x, position.y, position.z, // camera position
|
||||
position.x, position.y, engine->farPlane+position.z, // target position, We're always *looking at* the far plane straight ahead so the camera never turns around.
|
||||
upVector.x,upVector.y,upVector.z);
|
||||
glMultMatrixf(lookAt({position.x, position.y, position.z}, {position.x, position.y, engine->farPlane+position.z}, upVector).data());
|
||||
}
|
||||
|
||||
void Camera::post_render() {
|
||||
|
Reference in New Issue
Block a user