Skip to content

Commit

Permalink
Add screenshot for 2d-rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
kimkulling committed Jan 14, 2025
1 parent fb7129c commit dd3f365
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 30 deletions.
Binary file added assets/Images/02_demo2d.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 1 addition & 6 deletions samples/00_HelloWorld/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
# Hello World
![HelloWorld](../../assets/Images/HelloWorld.png)
This sample just shows how to render a simple Triangle. The creation of the render window and the base setup is included.
You can rotate the triangle with your keyboard.

## The main application
At first we are including all needed dependecies, use the OSRE namespace and the Renderbackend-namespace.
The we will generate our simple model-, view- and projection-matrix.
This sample shows how to render a simple cube. You can rotate the triangle with your keyboard.

```cpp
#include "App/App.h"
Expand Down
58 changes: 34 additions & 24 deletions samples/02_Demo2D/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,40 @@
## The User-Interface-Demo
## The 2D Demo

This example shows how to use the simple engine-intern User-Interface-Framework.
## Screenshot
![Demo2D](../../assets/Images/02_demo2d.png)

So lets start with the basic application:
## Introduction
This sample shows how to render a simple 2D scene. There is a cube in the background.

## Code Overview
```cpp

#include "App/AppBase.h"
#include "App/Entity.h"
#include "App/ServiceProvider.h"
#include "App/Component.h"
#include "App/CameraComponent.h"
#include "Properties/Settings.h"
#include "Common/Logger.h"
#include "RenderBackend/RenderCommon.h"
#include "RenderBackend/RenderBackendService.h"
#include "RenderBackend/TransformMatrixBlock.h"
#include "RenderBackend/MeshBuilder.h"
#include "RenderBackend/2D/CanvasRenderer.h"
#include "RenderBackend/2D/RenderPass2D.h"

using namespace ::OSRE;
using namespace ::OSRE::RenderBackend;
using namespace ::OSRE::App;

// To identify local log entries
static constexpr c8 Tag[] = "ModelLoadingApp";

//-------------------------------------------------------------------------------------------------
/// @ingroup Editor
///
/// @brief
//-------------------------------------------------------------------------------------------------
class Demo2DApp : public App::AppBase {
/// The transform matrices
TransformMatrixBlock mTransformMatrix;
/// The 2D renderer for the ui overlay
CanvasRenderer *mCanvasRenderer;
Expand All @@ -23,9 +50,7 @@ public:
// empty
}

~Demo2DApp() override {
delete mCanvasRenderer;
}
~Demo2DApp() override = default;

void quitCallback(ui32, void *) {
AppBase::requestShutdown();
Expand Down Expand Up @@ -116,7 +141,7 @@ protected:
return true;
}

void onUpdate() {
void onUpdate() override {
RenderBackendService *rbSerive = ServiceProvider::getService<RenderBackendService>(ServiceType::RenderService);
rbSerive->beginPass(RenderPass::getPassNameById(RenderPassId));
Expand Down Expand Up @@ -150,19 +175,4 @@ int main(int argc, char *argv[]) {

return 0;
}

```
At first you have to create your application window with your render-window.
To be able to render any UI-Elements you have to create a screen first. A screen represents a 2D-rect
on you screen.
The next step is to create your dialog: defining a panel, add two buttons and assign callbacks to them
In this case the button on the left will open a FileOpen-dialog and the second button will destroy your
application.
# Todo
- Optimize UI-elements styling
- Add button texts
- Add button images
- Add onClicked animation
- Implement OpenFile-dialog for other platforms

0 comments on commit dd3f365

Please sign in to comment.