Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renderbackend: Rework Canvas 2D-Rendering #244

Merged
merged 46 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
3362bbf
Renderbackend: Just fix some finidings
kullingk Oct 10, 2024
5381835
Update Component.h
kimkulling Oct 10, 2024
1e4cfff
Canvas: Add docs and improvements
kimkulling Oct 10, 2024
683a8bd
Update CanvasRenderer.h
kimkulling Oct 11, 2024
a0202a0
Update CanvasRenderer.h
kimkulling Oct 11, 2024
1ffb692
Update CanvasRenderer.cpp
kimkulling Oct 11, 2024
ce8090d
Update MaterialBuilder.h
kimkulling Oct 11, 2024
a13930f
Canvas2D: Add prototype for text rendering
kimkulling Oct 14, 2024
883ada3
Canvas:Remove dead code.
kimkulling Oct 14, 2024
29dcb52
Canvas: Add font service
kullingk Oct 15, 2024
4c578ff
Canvas: Add font service
kullingk Oct 15, 2024
3e79c55
vcpkg: latest greatest
kimkulling Oct 16, 2024
037efdd
Canvas: Prepare text rendering
kullingk Oct 17, 2024
8e08167
Canvas: Fix the build
kullingk Oct 21, 2024
617083b
Canvas: Add missing doc
kullingk Oct 22, 2024
ed8f8f3
Merge branch 'master' of https://github.com/kimkulling/osre
kimkulling Oct 22, 2024
6b0bef5
cppcore: latest greatest
kimkulling Oct 23, 2024
aa8725c
Canvas: Adapt new hash
kimkulling Oct 23, 2024
516cdbf
Canvas: Ensure that all font materials are assigned to the used meshes.
kimkulling Oct 23, 2024
e825f62
Refactroings
kullingk Oct 24, 2024
789a398
cppcore: latest greatest
kimkulling Oct 29, 2024
b4c72a8
Canvas: fix overwide when setting color
kimkulling Oct 29, 2024
891c945
Mesh: Remove dead code
kullingk Oct 30, 2024
1a25271
Merge branch 'kimkulling/fix_2d_coords' of https://github.com/kimkull…
kullingk Oct 30, 2024
5d4e316
Canvas: next steps
kullingk Oct 30, 2024
231a3f6
Canvas: Setup canvas renderer
kullingk Oct 30, 2024
bc1f0e8
Canvas: Some small refactorings.
kimkulling Nov 4, 2024
c6f53b1
Canvas: Add text rendering prototype.
kimkulling Nov 5, 2024
a859d0e
Canvas: Fix crashes
kullingk Nov 6, 2024
4ddd758
Canvas: Fix material access.
kullingk Nov 7, 2024
135975c
Add container for text rendering
kullingk Nov 8, 2024
b2fdcdf
Canvas: Separate text rendering from 2d canvas rendering
kullingk Nov 8, 2024
d0f4dbd
Canvas:Fix review findings
kimkulling Nov 8, 2024
5bbcacf
Merge branch 'kimkulling/fix_2d_coords' of https://github.com/kimkull…
kimkulling Nov 8, 2024
7678db4
Canvas: cleanup
kullingk Nov 11, 2024
7023c4e
Merge branch 'kimkulling/fix_2d_coords' of https://github.com/kimkull…
kimkulling Nov 11, 2024
2c756c7
merge
kimkulling Nov 11, 2024
ddfe258
Merge branch 'kimkulling/fix_2d_coords' of https://github.com/kimkull…
kimkulling Nov 11, 2024
3d6de71
CI: Add missing dep
kimkulling Nov 11, 2024
6325e47
Fix build
kimkulling Nov 11, 2024
85e6e67
Merge branch 'kimkulling/fix_2d_coords' of https://github.com/kimkull…
kimkulling Nov 11, 2024
edbde48
Canvas: Fix the build.
kullingk Nov 12, 2024
9bf581d
cppcore: latest master
kimkulling Nov 12, 2024
4f5557d
Remove dead code
kimkulling Nov 12, 2024
f91a4f9
Canvas: fix review findins
kullingk Nov 13, 2024
2e927c1
Canvas: fix review findins
kullingk Nov 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contrib/assimp
Submodule assimp updated 213 files
2 changes: 2 additions & 0 deletions samples/02_Demo2D/Demo2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ class Demo2DApp : public App::AppBase {

mCanvasRenderer->drawRect(100, 1000, 110, 124, true);

mCanvasRenderer->drawText(300, 100, "Test");

kimkulling marked this conversation as resolved.
Show resolved Hide resolved
return true;
}

Expand Down
7 changes: 4 additions & 3 deletions src/Editor/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ int main(int argc, char *argv[]) {
std::cout << "Editor version 0.1\n";

OsreEdApp osreApp(argc, argv);
if (!osreApp.initWindow(100, 100, 1024, 768, "OSRE-Ed",
WindowMode::Windowed,
WindowType::Child,
if (!osreApp.initWindow(100, 100, 1024, 768, "OSRE-Ed",
WindowMode::Windowed,
WindowType::Child,
RenderBackendType::OpenGLRenderBackend)) {
osre_error(Tag, "Cannot open the window.");
return AppError;
}

Expand Down
7 changes: 4 additions & 3 deletions src/Engine/Animation/AnimatorBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,11 @@ using VectorChannelArray = ::cppcore::TArray<VectorChannel>;
template <class T>
struct AnimatorBase {
void operator () ( T &out, const T &a, const T &b, f32 d ) const {
out = a + ( b - a ) * d;
out = a + (b - a) * d;
}
};

/// @brief
enum class TransformCommandType {
Invalid = -1,
RotateXCommandPositive = 0,
Expand Down Expand Up @@ -166,5 +167,5 @@ class OSRE_EXPORT AnimationControllerBase {
AnimationControllerBase() = default;
};

}
}
} // namespace Animation
} // namespace OSRE
2 changes: 1 addition & 1 deletion src/Engine/App/AppBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ void AppBase::update() {
if (mAppState == State::Created) {
mAppState = State::Running;
}

onUpdate();
}

Expand Down
5 changes: 3 additions & 2 deletions src/Engine/App/Component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,9 @@ bool RenderComponent::onRender(RenderBackendService *renderBackendSrv) {
return true;
}

LightComponent::LightComponent(Entity *owner)
: Component(owner, ComponentType::LightComponentType), mLight(nullptr) {}
LightComponent::LightComponent(Entity *owner) : Component(owner, ComponentType::LightComponentType), mLight(nullptr) {
// empty
}

void LightComponent::setLight(RenderBackend::Light *light) {
mLight = light;
Expand Down
44 changes: 23 additions & 21 deletions src/Engine/App/Component.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ enum class ComponentType {
TransformComponentType, ///< For all transformation types.
LightComponentType, ///< For light types.
CameraComponentType, ///< For camera components.
AnimationComponentType, ///<
AnimationComponentType, ///< For animation support.
Count ///< The number of components.
};

Expand Down Expand Up @@ -127,33 +127,35 @@ class OSRE_EXPORT RenderComponent : public Component {
/// @brief The class constructor.
/// @param owner The owning entity.
RenderComponent(Entity *owner);

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

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

/// @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 Returns the mesh array.
/// @param[inout] array
/// @param[inout] array The mesh array managed by the component.
void getMeshArray(RenderBackend::MeshArray &array);
/// @brief
/// @param geo
void addStaticMesh(RenderBackend::Mesh *geo);
/// @brief
/// @param array

/// @brief Will add a new mesh.
/// @param mesh Thew mesh to add.
void addStaticMesh(RenderBackend::Mesh *mesh);

/// @brief Will add an array of new meshes.
/// @param array The array with enw meshes.
void addStaticMeshArray(const RenderBackend::MeshArray &array);

protected:
/// The update callback.
bool onUpdate(Time dt) override;
/// The render callback.
bool onRender(RenderBackend::RenderBackendService *rbSrv) override;

private:
Expand All @@ -163,19 +165,19 @@ class OSRE_EXPORT RenderComponent : public Component {
//-------------------------------------------------------------------------------------------------
/// @ingroup Engine
///
/// @brief
/// @brief This component class implements a light.
//-------------------------------------------------------------------------------------------------
class LightComponent final : public Component {
public:
/// @brief
/// @param owner
/// @brief The class constructor.
/// @param owner The owning entity.
LightComponent(Entity *owner);
/// @brief

/// @brief The class destructor.
~LightComponent() override = default;
/// @brief
/// @param light

/// @brief Will set a new light instance.
/// @param light Thew new light.
void setLight(RenderBackend::Light *light);

protected:
Expand Down
2 changes: 1 addition & 1 deletion src/Engine/App/MouseEventListener.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class MouseEventListener : public Platform::OSEventListener {
/// @brief Will return true, if the middle mouse-button was pressed,
/// @return true if the middle mouse button was pressed.
bool middleButttonPressed() const;

/// @brief Will return true, if the right mouse-button was pressed,
/// @return true if the right mouse button was pressed.
bool rightButttonPressed() const;
Expand Down
5 changes: 5 additions & 0 deletions src/Engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,9 @@ SET( renderbackend_src
RenderBackend/Shader.cpp
)

SET( renderbackend_mesh_src
RenderBackend/Mesh/MeshUtilities.h
)
SET( renderbackend_2d_src
RenderBackend/2D/RenderPass2D.h
RenderBackend/2D/CanvasRenderer.h
Expand Down Expand Up @@ -400,6 +403,7 @@ SOURCE_GROUP( Profiling FILES ${profiling_src} )
SOURCE_GROUP( Properties FILES ${properties_src} )
SOURCE_GROUP( RenderBackend FILES ${renderbackend_src} )
SOURCE_GROUP( RenderBackend\\2D FILES ${renderbackend_2d_src})
SOURCE_GROUP( RenderBackend\\Mesh FILES ${renderbackend_mesh_src} )
SOURCE_GROUP( RenderBackend\\OGLRenderer FILES ${renderbackend_oglrenderer_src} )
SOURCE_GROUP( RenderBackend\\Vulkan FILES ${renderbackend_vulkanrenderer_src} )
SOURCE_GROUP( RenderBackend\\Shader FILES ${renderbackend_shader_src})
Expand Down Expand Up @@ -441,6 +445,7 @@ ADD_LIBRARY( osre SHARED
${renderbackend_oglrenderer_src}
${renderbackend_volkanrenderer_src}
${renderbackend_2d_src}
${renderbackend_mesh_src}
${renderbackend_shader_src}
${scene_src}
${scene_shader_src}
Expand Down
2 changes: 1 addition & 1 deletion src/Engine/Common/Logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void Logger::trace(const String &domain, const String &msg) {
logMsg += msg;
appendDomain(domain, logMsg);

print(logMsg);
print(logMsg);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/Engine/Common/Logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class OSRE_EXPORT Logger final {
/// @param[in] sev The new severity of the logger.
/// @see Severity
void setVerboseMode(VerboseMode sev);

/// @brief Returns the current severity of the logger.
/// @return The current severity.
VerboseMode getVerboseMode() const;
Expand All @@ -136,7 +136,7 @@ class OSRE_EXPORT Logger final {
/// @brief Logs a print message.
/// @param[in] message The message to log.
/// @param[in] mode Logging mode
void print( const String &message, PrintMode mode = PrintMode::WithDateTime );
void print( const String &message, PrintMode mode = PrintMode::WhithoutDateTime );
kimkulling marked this conversation as resolved.
Show resolved Hide resolved

/// @brief Logs a warn message.
/// @param[in] domain The domain.
Expand Down
5 changes: 5 additions & 0 deletions src/Engine/Common/glm_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <glm/gtx/quaternion.hpp>
#include <glm/common.hpp>

#include <cppcore/Container/TArray.h>

using Vec3Array = cppcore::TArray<glm::vec3>;
using Vec2Array = cppcore::TArray<glm::vec2>;

#ifdef _MSC_VER
#pragma warning(pop)
#endif // _MSC_VER
12 changes: 9 additions & 3 deletions src/Engine/Platform/AbstractWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ struct OSRE_EXPORT Resolution {
Res1920x1080
};

ui32 m_width; ///< The resolution in x.
ui32 m_height; ///< The resolution in y.
ui32 m_width; ///< The resolution in x.
ui32 m_height; ///< The resolution in y.

explicit Resolution(ResRequest req);
Resolution();
Expand All @@ -73,7 +73,7 @@ struct WindowsProperties {
/// @param[out] rect The window rect.
void getDimension(Rect2ui &rect);

/// @brief WIll set the new rectangle geometry.
/// @brief Will set the new rectangle geometry.
/// @param[in] rect The new rectangle.
void setRect(const Rect2ui &rect);
};
Expand Down Expand Up @@ -129,8 +129,14 @@ class OSRE_EXPORT AbstractWindow {
/// @brief The class destructor, virtual.
virtual ~AbstractWindow();

/// @brief Will set the parent window. Use nullptr for beeing the root window.
/// @param parent Pointer ot the paretn window.
virtual void setParent(AbstractWindow *parent);

/// @brief Will return the parent window or nullptr, if this windows is the root window.
/// @return Pointer to the parent window, nullptr for none.
virtual AbstractWindow *getParent() const;

/// @brief Will create the surface.
/// @return true will be returned, when creation was successful.
virtual bool create();
Expand Down
4 changes: 2 additions & 2 deletions src/Engine/Platform/win32/Win32Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void Win32Window::showWindow(ShowState showState) {
int ws = SW_HIDE;
if (showState == ShowState::Visible) {
ws = SW_SHOW;
}
}
::ShowWindow(mWnd, ws);
}
}
Expand Down Expand Up @@ -356,7 +356,7 @@ void Win32Window::onResize(ui32 x, ui32 y, ui32 w, ui32 h) {

::MoveWindow(mWnd, x, y, w, h, NULL);
WindowsProperties *props = AbstractWindow::getProperties();
if (nullptr != props) {
if (props != nullptr) {
props->mRect.x1 = x;
props->mRect.y1 = y;
props->mRect.width = w;
Expand Down
Loading
Loading