Skip to content

Commit

Permalink
Merge branch 'master' into kimkulling/prepare_animations
Browse files Browse the repository at this point in the history
  • Loading branch information
kimkulling authored Sep 18, 2024
2 parents 946e394 + 4e8b6dc commit ab7eedd
Show file tree
Hide file tree
Showing 24 changed files with 208 additions and 170 deletions.
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,3 @@ OSRE_MAIN(QuickStartdApp)
![ESRE-Ed](assets/Images/sponza.png)
The engine provdes an 3D-Editor called OSRE-Ed. It is still experimental:
# Get involved
If you want to contribute just use the github project page or reach us via Gitter:
[![Join the chat at https://gitter.im/kimkulling/osre](https://badges.gitter.im/kimkulling/osre.svg)](https://gitter.im/kimkulling/osre?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4 changes: 3 additions & 1 deletion samples/00_HelloWorld/HelloWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ class HelloWorldApp : public App::AppBase {

void onUpdate() override {
Platform::Key key = AppBase::getKeyboardEventListener()->getLastKey();
mKeyboardTransCtrl->update(mKeyboardTransCtrl->getKeyBinding(key));
if (key != Platform::KEY_UNKNOWN) {
mKeyboardTransCtrl->update(mKeyboardTransCtrl->getKeyBinding(key));
}

RenderBackendService *rbSrv = ServiceProvider::getService<RenderBackendService>(ServiceType::RenderService);

Expand Down
2 changes: 1 addition & 1 deletion samples/01_ModelLoading/ModelLoading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ class ModelLoadingApp : public App::AppBase {

int main(int argc, char *argv[]) {
ModelLoadingApp myApp(argc, argv);
if (!myApp.initWindow(10, 10, 1024, 768, "ModelLoader sample! Press o to import an Asset", false, false, App::RenderBackendType::OpenGLRenderBackend)) {
if (!myApp.initWindow(10, 10, 1024, 768, "ModelLoader sample! Press o to import an Asset", WindowMode::Windowed, WindowType::Root, App::RenderBackendType::OpenGLRenderBackend)) {
return 1;
}

Expand Down
2 changes: 1 addition & 1 deletion samples/03_Instancing/Instancing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class InstancingApp : public App::AppBase {

int main(int argc, char *argv[]) {
InstancingApp myApp(argc, argv);
if (!myApp.initWindow(10, 10, 1024, 768, "Instancing-Sample", false, false, RenderBackendType::OpenGLRenderBackend)) {
if (!myApp.initWindow(10, 10, 1024, 768, "Instancing-Sample", WindowMode::Windowed, WindowType::Root, RenderBackendType::OpenGLRenderBackend)) {
return 1;
}

Expand Down
3 changes: 1 addition & 2 deletions samples/04_terrain/TerrainRendering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ class TerrainRenderingApp : public App::AppBase {

int main(int argc, char *argv[]) {
TerrainRenderingApp myApp(argc, argv);
if (!myApp.initWindow(10, 10, 1024, 768, "Instancing-Sample", false, false, RenderBackendType::OpenGLRenderBackend)) {
if (!myApp.initWindow(10, 10, 1024, 768, "Instancing-Sample", WindowMode::Windowed, WindowType::Root, RenderBackendType::OpenGLRenderBackend)) {
return 1;
}

Expand All @@ -218,4 +218,3 @@ int main(int argc, char *argv[]) {

return 0;
}

12 changes: 10 additions & 2 deletions src/Editor/src/OsreEdApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "OSREEdApp.h"
#include "ProgressReporter.h"
#include "Actions/ImportAction.h"

#include "Platform/PlatformOperations.h"
#include "RenderBackend/MeshBuilder.h"
#include "App/Stage.h"
#include "App/TransformController.h"
Expand Down Expand Up @@ -154,8 +154,16 @@ bool OsreEdApp::onCreate() {
}

void OsreEdApp::onUpdate() {
if (AppBase::isKeyPressed(Platform::KEY_O) || AppBase::isKeyPressed(Platform::KEY_o)) {
IO::Uri modelLoc;
Platform::PlatformOperations::getFileOpenDialog("Choose asset for import", "*", modelLoc);
if (modelLoc.isValid()) {
loadAsset(modelLoc);
}
}

Platform::Key key = AppBase::getKeyboardEventListener()->getLastKey();
if (mKeyboardTransCtrl != nullptr) {
if (key != Platform::KEY_UNKNOWN && mKeyboardTransCtrl != nullptr) {
mKeyboardTransCtrl->update(mKeyboardTransCtrl->getKeyBinding(key));
}

Expand Down
10 changes: 2 additions & 8 deletions src/Editor/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "App/Entity.h"
#include "Platform/AbstractWindow.h"
#include "Common/glm_common.h"
#include "Platform/PlatformOperations.h"
//#include "Platform/PlatformOperations.h"
#include "Platform/PlatformInterface.h"
#include "Platform/win32/Win32Window.h"

Expand All @@ -48,7 +48,6 @@ using namespace OSRE::Editor;

static constexpr c8 Tag[] = "HelloWorldApp";


int main(int argc, char *argv[]) {
std::cout << "Editor version 0.1\n";

Expand All @@ -57,17 +56,12 @@ int main(int argc, char *argv[]) {
return -1;
}

IO::Uri modelLoc;
PlatformOperations::getFileOpenDialog("Select asset for import", "*", modelLoc);
if (modelLoc.isValid()) {
osreApp.loadAsset(modelLoc);
}

// Main loop
bool done = false;
while (!done) {
static int counter = 0;
osreApp.handleEvents();
done = osreApp.handleEvents();
App::Stage *stage = osreApp.getStage();
if (stage != nullptr) {
World *world = stage->getActiveWorld(0);
Expand Down
6 changes: 3 additions & 3 deletions src/Engine/App/AppBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,16 @@ AppBase::~AppBase() {
delete mSettings;
}

bool AppBase::initWindow(ui32 x, ui32 y, ui32 width, ui32 height, const String &title, bool fullscreen, bool childWindow,
bool AppBase::initWindow(ui32 x, ui32 y, ui32 width, ui32 height, const String &title, WindowMode mode, WindowType type,
RenderBackendType renderer) {
osre_assert(nullptr != mSettings);

mSettings->setInt(Settings::WinX, x);
mSettings->setInt(Settings::WinY, y);
mSettings->setInt(Settings::WinWidth, width);
mSettings->setInt(Settings::WinHeight, height);
mSettings->setBool(Settings::FullScreen, fullscreen);
mSettings->setBool(Settings::ChildWindow, childWindow);
mSettings->setBool(Settings::FullScreen, mode == WindowMode::Fullscreen);
mSettings->setBool(Settings::ChildWindow, type == WindowType::Child);
mSettings->setString(Settings::WindowsTitle, title);
if (renderer == RenderBackendType::OpenGLRenderBackend) {
mSettings->setString(Settings::RenderAPI, "opengl");
Expand Down
16 changes: 15 additions & 1 deletion src/Engine/App/AppBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,20 @@ class OSRE_EXPORT KeyboardEventListener : public Platform::OSEventListener {
char mKeymap[Platform::KEY_LAST];
};

enum class WindowMode {
Invalid,
Windowed,
Fullscreen,
Count
};

enum class WindowType {
Invalid,
Root,
Child,
Count
};

//-------------------------------------------------------------------------------------------------
/// @ingroup Engine
///
Expand Down Expand Up @@ -143,7 +157,7 @@ class OSRE_EXPORT AppBase {
/// @param[in] renderer The requested render mode.
/// @return true, if the window was generated.
virtual bool initWindow( ui32 x, ui32 y, ui32 width, ui32 height, const String &title,
bool fullscreen, bool childWindow, RenderBackendType renderer);
WindowMode mode, WindowType type, RenderBackendType renderer);

/// @brief Creates the application.
/// @param settings [in] The user-defined settings.
Expand Down
2 changes: 1 addition & 1 deletion src/Engine/App/Component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void RenderComponent::addStaticMeshArray(const RenderBackend::MeshArray &array)
}
}

size_t RenderComponent::getNumGeometry() const {
size_t RenderComponent::getNumMeshes() const {
return m_newGeo.size();
}

Expand Down
22 changes: 11 additions & 11 deletions src/Engine/App/Component.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,24 +124,24 @@ inline size_t Component::getIndex( ComponentType type ) {
//-------------------------------------------------------------------------------------------------
class OSRE_EXPORT RenderComponent : public Component {
public:
/// @brief
/// @param owner
/// @brief The class constructor.
/// @param owner The owning entity.
RenderComponent(Entity *owner);

/// @brief
/// @brief The class destructor.
~RenderComponent() override = default;

/// @brief
/// @return
size_t getNumGeometry() const;
/// @brief Returns the number of meshes
/// @return The number of stored meshes.
size_t getNumMeshes() const;

/// @brief
/// @param idx
/// @return
/// @brief Returns the mesh at a given index.
/// @param[in] idx The requested index.
/// @return The mesh os a nullptr if the index in invalid.
RenderBackend::Mesh *getMeshAt(size_t idx) const;

/// @brief
/// @param array
/// @brief Returns the mesh array.
/// @param[inout] array
void getMeshArray(RenderBackend::MeshArray &array);

/// @brief
Expand Down
2 changes: 1 addition & 1 deletion src/Engine/App/Project.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ static void storeEntities(const cppcore::TArray<Entity *> &entities, WorldData &
}

auto *rc = (RenderComponent *)entity->getComponent(ComponentType::RenderComponentType);
numMeshes += rc->getNumGeometry();
numMeshes += rc->getNumMeshes();
}

MeshData *md = new MeshData[numMeshes];
Expand Down
2 changes: 1 addition & 1 deletion src/Engine/App/World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ void World::updateBoundingTrees() {
}
MeshProcessor processor;
RenderComponent *rc = (RenderComponent *)entity->getComponent(ComponentType::RenderComponentType);
for (ui32 j = 0; j < rc->getNumGeometry(); ++j) {
for (ui32 j = 0; j < rc->getNumMeshes(); ++j) {
processor.addMesh(rc->getMeshAt(j));
}
if (processor.execute()) {
Expand Down
6 changes: 3 additions & 3 deletions src/Engine/RenderBackend/OGLRenderer/OGLCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ void checkOGLErrorState(const c8 *file, ui32 line);
/// @brief This macro will check the OpenGL-error state and write a message into the log.
//-------------------------------------------------------------------------------------------------
#ifdef _DEBUG
#define CHECKOGLERRORSTATE() checkOGLErrorState(__FILE__, __LINE__)
# define CHECKOGLERRORSTATE() checkOGLErrorState(__FILE__, __LINE__)
#else
#define CHECKOGLERRORSTATE()
# define CHECKOGLERRORSTATE()
#endif // _DEBUG

static constexpr GLuint OGLNotSetId = 999999; ///< Indicates a not inited opengl id.
Expand All @@ -67,7 +67,7 @@ struct OGLBuffer {

/// @brief The default class constructor.
OGLBuffer() : m_handle(0), m_type(BufferType::InvalidType), m_oglId(OGLNotSetId), m_geoId(0), m_size(0){}

/// @brief The class destructor, default implementation.
~OGLBuffer() = default;
};
Expand Down
26 changes: 19 additions & 7 deletions src/Engine/RenderBackend/OGLRenderer/OGLRenderBackend.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,32 @@ class OGLRenderBackend {
public:
using VertAttribArray = cppcore::TArray<OGLVertexAttribute *>;

/// The default class constructor.
/// @brief The default class constructor.
OGLRenderBackend();
/// The class destructor.

/// @brief The class destructor.
~OGLRenderBackend();
///

/// @brief Will enumerate the GPU capabilities.
void enumerateGPUCaps();
///
void setClearColor(const Color4 &clearColor);
/// Will set the requested global matrix for the frame.

/// @brief Will set the clear color.
/// @param[in] clearColor The new clear color.
void setClearColor(const Color4 &clearColor);

/// @brief Will set the requested global matrix for the frame.
void setMatrix(MatrixType type, const glm::mat4 &mat);
/// All matrix values will be applied to the current frame.

/// @brief All matrix values will be applied to the current frame.
void applyMatrix();

/// @brief
const glm::mat4 &getMatrix(MatrixType type) const;

/// @brief
bool create(Platform::AbstractOGLRenderContext *renderCtx);

/// @brief
bool destroy();
void setTimer(Platform::AbstractTimer *timer);
void setRenderContext(Platform::AbstractOGLRenderContext *renderCtx);
Expand Down
13 changes: 13 additions & 0 deletions src/Engine/RenderBackend/OGLRenderer/OGLRenderCommands.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,27 @@ struct OGLParameter;
struct UniformVar;
struct SetMaterialStageCmdData;

/// @brief Setup for screenshots
bool makeScreenShot(const c8 *filename, ui32 w, ui32 h);

/// @brief Setup for textures.
bool setupTextures(Material* mat, OGLRenderBackend* rb, OGLTextureArray& textures);

/// @brief Setup for materials.
SetMaterialStageCmdData* setupMaterial(Material* material, OGLRenderBackend* rb, OGLRenderEventHandler* eh);

/// @brief Setup for shader parameters.
void setupParameter(UniformVar* param, OGLRenderBackend* rb, OGLRenderEventHandler* ev);

/// @brief Setup for opengl buffers.
OGLVertexArray* setupBuffers(Mesh* mesh, OGLRenderBackend* rb, OGLShader* oglShader);

/// @brief Setup for render calls.
void setupPrimDrawCmd(const char* id, bool useLocalMatrix, const glm::mat4& model,
const cppcore::TArray<size_t>& primGroups, OGLRenderBackend* rb,
OGLRenderEventHandler* eh, OGLVertexArray* va);

/// @brief Setup for instanced render calls.
void setupInstancedDrawCmd(const char* id, const cppcore::TArray<size_t>& ids, OGLRenderBackend* rb,
OGLRenderEventHandler* eh, OGLVertexArray* va, size_t numInstances);

Expand Down
10 changes: 5 additions & 5 deletions src/Engine/RenderBackend/OGLRenderer/OGLRenderEventHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ struct OGLBuffer;
/// @brief This class is used to handle all incoming events for the render back-end, which
/// implements the OpenGL renderer.
//-------------------------------------------------------------------------------------------------
class OGLRenderEventHandler : public Common::AbstractEventHandler {
class OGLRenderEventHandler final : public Common::AbstractEventHandler {
public:
/// @brief The default class constructor.
OGLRenderEventHandler();
Expand Down Expand Up @@ -142,22 +142,22 @@ class OGLRenderEventHandler : public Common::AbstractEventHandler {
/// @param[in] eventData The event state data
/// @return true if successful, false if not.
bool onRenderFrame( const Common::EventData *eventData );

/// @brief Callback to init the passes.
/// @param[in] eventData The event state data
/// @return true if successful, false if not.
bool onInitRenderPasses(const Common::EventData *eventData);

/// @brief Callback to commit the next frame.
/// @param[in] eventData The event state data
/// @return true if successful, false if not.
bool onCommitNexFrame( const Common::EventData *eventData );

/// @brief Callback for dealing with a shutdown request.
/// @param[in] eventData The event state data
/// @return true if successful, false if not.
bool onShutdownRequest( const Common::EventData *eventData );

/// @brief Callback for dealing with resize events.
/// @param[in] eventData The event state data
/// @return true if successful, false if not.
Expand Down
Loading

0 comments on commit ab7eedd

Please sign in to comment.