SIGILL
This commit is contained in:
@@ -54,6 +54,6 @@ find_package(OpenGL REQUIRED)
|
||||
include_directories({$OPENGL_INCLUDE_DIRS})
|
||||
find_package(glm REQUIRED)
|
||||
find_package(ReWindowLibrary REQUIRED)
|
||||
target_link_libraries(SDL3D PUBLIC glm::glm ReWindowLibrary X11 ${OPENGL_LIBRARIES})
|
||||
target_link_libraries(SDL3D PUBLIC glm::glm X11 ReWindowLibrary ${ReWindowLibrary_LIBRARIES} ${OPENGL_LIBRARIES})
|
||||
add_executable(SDL3D_Demo "include/demo/main.cpp")
|
||||
target_link_libraries(SDL3D_Demo PUBLIC SDL3D X11 ReWindowLibrary)
|
||||
target_link_libraries(SDL3D_Demo PUBLIC SDL3D X11 ${ReWindowLibrary_LIBRARIES})
|
@@ -2,6 +2,7 @@
|
||||
#include "engine/tick.h"
|
||||
#include "engine/render.h"
|
||||
|
||||
|
||||
class App
|
||||
{
|
||||
public:
|
||||
@@ -17,19 +18,23 @@ class GameApp : public App
|
||||
|
||||
};
|
||||
void test() {
|
||||
std::cout << "test" << std::endl;
|
||||
std::cout << "ran" << std::endl;
|
||||
}
|
||||
|
||||
class glDemoGameApp : public GameApp
|
||||
{
|
||||
public:
|
||||
void Run() override
|
||||
{
|
||||
//engine->loadConfig();
|
||||
//engine->initVideo();
|
||||
engine->window->render = render_loop();
|
||||
std::thread game_tick(gameTick);
|
||||
//engine->loadConfig();
|
||||
//engine->window = new(RWindow);
|
||||
engine->window.init(RenderingAPI::OPENGL,"title", 1024,768);
|
||||
engine->window.render = render_loop();
|
||||
if (engine->window.render == nullptr)
|
||||
exit(0);
|
||||
game_tick.join();
|
||||
engine->window->pollEvents();
|
||||
engine->window.pollEvents();
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -16,7 +16,7 @@ enum class GAMESTATE: uint8_t {
|
||||
|
||||
class Engine {
|
||||
public:
|
||||
RWindow* window;
|
||||
RWindow window;
|
||||
GAMESTATE gameState = GAMESTATE::NORMAL;
|
||||
bool debug = true;
|
||||
bool fullscreen;
|
||||
@@ -31,7 +31,7 @@ public:
|
||||
float fov;
|
||||
[[nodiscard]] float framerate() const;
|
||||
void takeScreenshot() const;
|
||||
void quit() const;
|
||||
void quit();
|
||||
static float getGLVersion();
|
||||
void initGL();
|
||||
void initVideo();
|
||||
|
@@ -42,19 +42,19 @@ void render() {
|
||||
|
||||
void post_render() {
|
||||
//I need to wrap this.
|
||||
RWindow::glSwapBuffers();
|
||||
getCamera()->post_render();
|
||||
|
||||
RWindow::glSwapBuffers();
|
||||
//Resets all of the transformations for the next frame.
|
||||
glPopMatrix();
|
||||
glPushMatrix();
|
||||
}
|
||||
|
||||
void* render_loop() {
|
||||
void * render_loop() {
|
||||
std::cout << "ran" << std::endl;
|
||||
auto start = std::chrono::high_resolution_clock::now();
|
||||
pre_render();
|
||||
render();
|
||||
post_render();
|
||||
//pre_render();
|
||||
//render();
|
||||
//post_render();
|
||||
auto stop = std::chrono::high_resolution_clock::now();
|
||||
float dT = (std::chrono::duration_cast<std::chrono::microseconds>(stop - start).count());
|
||||
|
||||
@@ -64,5 +64,5 @@ void post_render() {
|
||||
std::this_thread::sleep_for(std::chrono::microseconds(remaining));
|
||||
dT = 1000;
|
||||
}
|
||||
engine->frameDelta = dT / 1000000;
|
||||
engine->frameDelta = (dT / 1000000);
|
||||
}
|
@@ -45,17 +45,18 @@ public:
|
||||
void update();
|
||||
|
||||
void pre_render() {
|
||||
if (engine->window->keyDown(SCANCODE::ZERO)) {
|
||||
this->takingScreenshot = true;
|
||||
if (engine->window.keyDown(SCANCODE::ZERO)) {
|
||||
std::cout << "test" << std::endl;
|
||||
//this->takingScreenshot = true;
|
||||
}
|
||||
|
||||
if (engine->window->keyDown(SCANCODE::ONE))
|
||||
if (engine->window.keyDown(SCANCODE::ONE))
|
||||
this->cameraMode = CameraMode::FREECAM;
|
||||
|
||||
if (engine->window->keyDown(SCANCODE::TWO))
|
||||
if (engine->window.keyDown(SCANCODE::TWO))
|
||||
this->cameraMode = CameraMode::THIRD_PERSON;
|
||||
|
||||
if (engine->window->keyDown(SCANCODE::THREE))
|
||||
if (engine->window.keyDown(SCANCODE::THREE))
|
||||
this->cameraMode = CameraMode::SCRIPTED_MOVE;
|
||||
|
||||
if (cameraMode == CameraMode::SCRIPTED_MOVE) {
|
||||
@@ -76,37 +77,37 @@ public:
|
||||
//getPlayer()->thirdPersonCameraPoints();
|
||||
|
||||
if (cameraMode == CameraMode::FREECAM) {
|
||||
if (engine->window->keyDown(SCANCODE::S)) {
|
||||
if (engine->window.keyDown(SCANCODE::S)) {
|
||||
move(bAngle(),2);
|
||||
}
|
||||
if (engine->window->keyDown(SCANCODE::W)) {
|
||||
if (engine->window.keyDown(SCANCODE::W)) {
|
||||
move(fAngle(),2);
|
||||
}
|
||||
if (engine->window->keyDown(SCANCODE::A)) {
|
||||
if (engine->window.keyDown(SCANCODE::A)) {
|
||||
move(lAngle(), 2);
|
||||
}
|
||||
if (engine->window->keyDown(SCANCODE::D)) {
|
||||
if (engine->window.keyDown(SCANCODE::D)) {
|
||||
move(rAngle(),2);
|
||||
}
|
||||
|
||||
if (engine->window->keyDown(SCANCODE::SPACE)) {
|
||||
if (engine->window.keyDown(SCANCODE::SPACE)) {
|
||||
this->position.y += 5*engine->frameDelta;
|
||||
}
|
||||
|
||||
if (engine->window->keyDown(SCANCODE::LEFT_SHIFT)) {
|
||||
if (engine->window.keyDown(SCANCODE::LEFT_SHIFT)) {
|
||||
this->position.y -= 5*engine->frameDelta;
|
||||
}
|
||||
|
||||
if (engine->window->keyDown(SCANCODE::LEFT)) {
|
||||
if (engine->window.keyDown(SCANCODE::LEFT)) {
|
||||
this->angle.yaw +=75.0f*engine->frameDelta;
|
||||
}
|
||||
if (engine->window->keyDown(SCANCODE::RIGHT)) {
|
||||
if (engine->window.keyDown(SCANCODE::RIGHT)) {
|
||||
this->angle.yaw -=75.0f*engine->frameDelta;
|
||||
}
|
||||
if (engine->window->keyDown(SCANCODE::UP)) {
|
||||
if (engine->window.keyDown(SCANCODE::UP)) {
|
||||
this->angle.pitch -=75.0f*engine->frameDelta;
|
||||
}
|
||||
if (engine->window->keyDown(SCANCODE::DOWN)) {
|
||||
if (engine->window.keyDown(SCANCODE::DOWN)) {
|
||||
this->angle.pitch +=75.0f*engine->frameDelta;
|
||||
}
|
||||
}
|
||||
|
@@ -5,8 +5,8 @@
|
||||
#include <sstream>
|
||||
#include <thread>
|
||||
|
||||
void Engine::quit() const {
|
||||
window->destroyWindow();
|
||||
void Engine::quit() {
|
||||
window.destroyWindow();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ void Engine::initGL()
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
//glOrtho(-1.0f, 1.0f, -1.0f, 1.0f, -0.5f, 0.5f);
|
||||
gluPerspective(this->fov, window->getSize()[0] / window->getSize()[1], this->nearPlane, this->farPlane);
|
||||
gluPerspective(this->fov, window.getSize()[0] / window.getSize()[1], this->nearPlane, this->farPlane);
|
||||
this->glError = glGetError();
|
||||
|
||||
if (glError != GL_NO_ERROR) {
|
||||
@@ -37,7 +37,7 @@ void Engine::initGL()
|
||||
exit (1);
|
||||
}
|
||||
glClearColor(0.f, 0.f, 0.f, 1.f);
|
||||
glViewport(0,0,window->getSize()[0],window->getSize()[1]);
|
||||
glViewport(0,0,window.getSize()[0],window.getSize()[1]);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthFunc(GL_LESS);
|
||||
glDepthMask(GL_TRUE);
|
||||
@@ -48,8 +48,8 @@ void Engine::initGL()
|
||||
|
||||
void Engine::initVideo()
|
||||
{
|
||||
window->init(RenderingAPI::OPENGL,"title",144,144);
|
||||
//window->setFlag(RWindowFlags::RESIZABLE, false);
|
||||
//window->init(RenderingAPI::OPENGL,"title",1152,864);
|
||||
window.setFlag(RWindowFlags::RESIZABLE, false);
|
||||
//window->pollEvents();
|
||||
// Create the window, set resizable, check for errors
|
||||
//SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION, 1);
|
||||
@@ -127,15 +127,15 @@ void Engine::loadConfig() {
|
||||
stream >> fov;
|
||||
}
|
||||
//If we have a window already.
|
||||
if (window != nullptr) {
|
||||
//if (window != NULL) {
|
||||
//window->destroyWindow();
|
||||
//Some window managers won't handle destroying and remaking the window with zero delay very well.
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
initVideo();
|
||||
initGL();
|
||||
}
|
||||
//std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
//initVideo();
|
||||
//initGL();
|
||||
//}
|
||||
std::cout << "Fullscreen: " << fullscreen << std::endl;
|
||||
std::cout << "Resolution: " << window->getSize()[0] << "x" << window->getSize()[1] << std::endl;
|
||||
std::cout << "Resolution: " << window.getSize()[0] << "x" << window.getSize()[1] << std::endl;
|
||||
std::cout << "Camera FOV: " << fov << std::endl;
|
||||
std::cout << "Debug: " << debug << std::endl;
|
||||
}
|
||||
|
Reference in New Issue
Block a user