Commit 118bfc52 authored by Dario Seyb's avatar Dario Seyb

merged linux fixes

parent 9bbb31e2
......@@ -12,7 +12,7 @@ if(MSVC)
endif()
elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
# Update if necessary
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wno-long-long -pedantic")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y -Wall -Wno-long-long -Wno-reorder -pedantic")
endif()
......
#pragma once
#include <unordered_map>
#include <map>
#include <vector>
#include <engine/core/Context.hpp>
......@@ -27,7 +28,7 @@ private:
typedef std::function<void(const void*)> EventCallback;
typedef std::unordered_map< EventSubscriberId, std::shared_ptr<EventCallbackWrapperBase> > EventMap;
typedef std::map< EventSubscriberId, std::shared_ptr<EventCallbackWrapperBase> > EventMap;
std::unordered_map< BaseEvent::EventId, EventMap> m_registeredCallbacks;
......@@ -36,10 +37,10 @@ public:
CONSTRUCT_SYSTEM(EventSystem), m_nextId(0) { }
template<typename E, typename Callback>
inline EventSubscriberId subscribe(Callback callback) {
inline EventSubscriberId subscribe(Callback callback, int priorityOffset = 0) {
auto eventId = Event<E>::id();
auto callbacksIt = m_registeredCallbacks.find(eventId);
EventSubscriberId resultId = m_nextId++;
EventSubscriberId resultId = m_nextId++ + priorityOffset*10;
if (callbacksIt == m_registeredCallbacks.end()) {
m_registeredCallbacks[eventId] = EventMap();
}
......@@ -49,8 +50,8 @@ public:
}
template<StringHash hash, typename Callback>
inline EventSubscriberId subscribe(Callback callback) {
return subscribe<SEvent<hash>>([callback](const SEvent<hash>& /*e*/) { callback(); });
inline EventSubscriberId subscribe(Callback callback, int priorityOffset = 0) {
return subscribe<SEvent<hash>>([callback](const SEvent<hash>& /*e*/) { callback(); }, priorityOffset);
}
template<typename E>
......@@ -88,4 +89,4 @@ public:
bool startup() override;
void shutdown() override;
};
\ No newline at end of file
};
......@@ -22,9 +22,9 @@ using namespace ACGL::Utils;
const glm::vec2 SHADOW_MAP_RESOLUTION = {512, 512};
glm::mat4 interpolate(TransformData a, TransformData b, double t, glm::dvec3 camPos) {
a.pos = a.pos - camPos;
b.pos = b.pos - camPos;
glm::vec3 pos = a.pos + (b.pos - a.pos) * t;
a.pos = a.pos - camPos;
b.pos = b.pos - camPos;
glm::vec3 pos = a.pos + (b.pos - a.pos) * t;
glm::quat rot = glm::slerp(a.rot, b.rot, static_cast<float>(t));
glm::vec3 s = a.scale + (b.scale - a.scale) * t;
......@@ -80,50 +80,50 @@ bool RendererSystem::startup() {
m_txaaHistoryBuffer->validate();
// Create two VABs to store transform feedback vertices. Size is a bit tricky because nobody knows how much
// vertices the tessellation shader creates.
// First Buffer
m_transformFeedbackVAO = SharedVertexArrayObject(new VertexArrayObject(GL_TRIANGLES));
m_transformFeedbackBuffer = SharedArrayBuffer(new ArrayBuffer());
m_transformFeedbackBuffer->defineAttribute("gNormal", GL_FLOAT, 3);
m_transformFeedbackBuffer->defineAttribute("gPosition", GL_FLOAT, 3);
m_transformFeedbackBuffer->defineAttribute("gTexCoord", GL_FLOAT, 2);
m_transformFeedbackVAO->attachAllAttributes(m_transformFeedbackBuffer);
// Create two VABs to store transform feedback vertices. Size is a bit tricky because nobody knows how much
// vertices the tessellation shader creates.
// First Buffer
m_transformFeedbackVAO = SharedVertexArrayObject(new VertexArrayObject(GL_TRIANGLES));
m_transformFeedbackBuffer = SharedArrayBuffer(new ArrayBuffer());
m_transformFeedbackBuffer->defineAttribute("gNormal", GL_FLOAT, 3);
m_transformFeedbackBuffer->defineAttribute("gPosition", GL_FLOAT, 3);
m_transformFeedbackBuffer->defineAttribute("gTexCoord", GL_FLOAT, 2);
m_transformFeedbackVAO->attachAllAttributes(m_transformFeedbackBuffer);
m_transformFeedbackBuffer->bind(GL_TRANSFORM_FEEDBACK_BUFFER);
m_transformFeedbackVAO->bind();
m_transformFeedbackBuffer->setData(GL_TRANSFORM_FEEDBACK_BUFFER, 300000 *3*3*2, NULL, GL_DYNAMIC_COPY);
m_transformFeedbackBuffer->bind(GL_TRANSFORM_FEEDBACK_BUFFER);
m_transformFeedbackVAO->bind();
m_transformFeedbackBuffer->setData(GL_TRANSFORM_FEEDBACK_BUFFER, 300000 *3*3*2, NULL, GL_DYNAMIC_COPY);
// Second buffer
m_transformFeedbackVAO2 = SharedVertexArrayObject(new VertexArrayObject(GL_TRIANGLES));
m_transformFeedbackBuffer2 = SharedArrayBuffer(new ArrayBuffer());
// Second buffer
m_transformFeedbackVAO2 = SharedVertexArrayObject(new VertexArrayObject(GL_TRIANGLES));
m_transformFeedbackBuffer2 = SharedArrayBuffer(new ArrayBuffer());
m_transformFeedbackBuffer2->defineAttribute("gNormal", GL_FLOAT, 3);
m_transformFeedbackBuffer2->defineAttribute("gPosition", GL_FLOAT, 3);
m_transformFeedbackBuffer2->defineAttribute("gTexCoord", GL_FLOAT, 2);
m_transformFeedbackBuffer2->defineAttribute("gNormal", GL_FLOAT, 3);
m_transformFeedbackBuffer2->defineAttribute("gPosition", GL_FLOAT, 3);
m_transformFeedbackBuffer2->defineAttribute("gTexCoord", GL_FLOAT, 2);
m_transformFeedbackVAO2->attachAllAttributes(m_transformFeedbackBuffer2);
m_transformFeedbackVAO2->attachAllAttributes(m_transformFeedbackBuffer2);
m_transformFeedbackBuffer2->bind(GL_TRANSFORM_FEEDBACK_BUFFER);
m_transformFeedbackVAO2->bind();
m_transformFeedbackBuffer2->setData(GL_TRANSFORM_FEEDBACK_BUFFER, 300000 * 3 * 3 * 2, NULL, GL_DYNAMIC_COPY);
m_transformFeedbackBuffer2->bind(GL_TRANSFORM_FEEDBACK_BUFFER);
m_transformFeedbackVAO2->bind();
m_transformFeedbackBuffer2->setData(GL_TRANSFORM_FEEDBACK_BUFFER, 300000 * 3 * 3 * 2, NULL, GL_DYNAMIC_COPY);
// Feedback objects
Feedback = 0;
glGenTransformFeedbacks(1, &Feedback);
glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, Feedback);
m_transformFeedbackBuffer->bindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0);
glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0);
// Feedback objects
Feedback = 0;
glGenTransformFeedbacks(1, &Feedback);
glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, Feedback);
m_transformFeedbackBuffer->bindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0);
glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0);
Feedback2 = 0;
glGenTransformFeedbacks(1, &Feedback2);
glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, Feedback2);
m_transformFeedbackBuffer2->bindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0);
glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0);
Feedback2 = 0;
glGenTransformFeedbacks(1, &Feedback2);
glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, Feedback2);
m_transformFeedbackBuffer2->bindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0);
glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0);
m_deferredCombineProgram = ShaderProgramFileManager::the()->get(ShaderProgramCreator("DeferredCombine"));
......@@ -132,12 +132,12 @@ bool RendererSystem::startup() {
m_shadowMapProg = ShaderProgramFileManager::the()->get(ShaderProgramCreator("ShadowMap"));
m_txaaProg = ShaderProgramFileManager::the()->get(ShaderProgramCreator("TXAA").fragmentDataLocations(m_secondaryCompositingBuffer->getAttachmentLocations()));
m_tfShaderProg = ShaderProgramFileManager::the()->get(ShaderProgramCreator("TerrainTransformFeedback"));
m_tfShaderProg = ShaderProgramFileManager::the()->get(ShaderProgramCreator("TerrainTransformFeedback"));
char * outs[] = { "gNormal", "gPosition", "gTexCoord"};
glTransformFeedbackVaryings(m_tfShaderProg->getObjectName(), 3, outs, GL_INTERLEAVED_ATTRIBS);
m_tfShaderProg->link();
char * outs[] = { "gNormal", "gPosition", "gTexCoord"};
glTransformFeedbackVaryings(m_tfShaderProg->getObjectName(), 3, outs, GL_INTERLEAVED_ATTRIBS);
m_tfShaderProg->link();
m_events->subscribe<ResizeWindowEvent>([this](const ResizeWindowEvent &e) {
glViewport(0, 0, e.newSize.x, e.newSize.y);
......@@ -615,13 +615,13 @@ void RendererSystem::shutdown() {
}
glm::mat4 RendererSystem::getProjectionMatrix() {
return aaProj;
return aaProj;
}
GLfloat RendererSystem::getDepthAtPixel(int x, int y) {
m_gBufferObject->bind();
GLfloat depth;
glReadPixels(x, y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depth);
return depth;
};
\ No newline at end of file
m_gBufferObject->bind();
GLfloat depth;
glReadPixels(x, y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depth);
return depth;
};
......@@ -111,6 +111,21 @@ bool AtmosphereTestScene::startup() {
sunLight->dir = -glm::normalize(m_player->getWorldPosition());
});
m_events->subscribe<KeyboardEvent>([this](const KeyboardEvent& e) {
switch (e.originalEvent.key.keysym.scancode) {
case SDL_SCANCODE_TAB:
if (e.originalEvent.key.type == SDL_KEYDOWN) {
m_player->attachToParent(earth);
float r = earth.component<Transform>()->scale.x;
m_player->setPosition(glm::vec3(0, 0, r * 1.2));
m_player->setRotation(glm::mat4());
}
break;
default:
break;
}
});
// Subscribe to the UI drawing event.
// This is called once per frame
m_events->subscribe<"DrawUI"_sh>([this]() {
......
......@@ -279,4 +279,4 @@ void UISystem::prepareRender() {
renderDrawLists(ImGui::GetDrawData());
}
void UISystem::shutdown() { ImGui::Shutdown(); }
\ No newline at end of file
void UISystem::shutdown() { ImGui::Shutdown(); }
#include <iostream>
#include <memory>
#include <engine/core/Context.hpp>
#include <engine/events/EventSystem.hpp>
#include <engine/core/SettingsSystem.hpp>
#include <engine/core/WindowSystem.hpp>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment