Skip to content

Commit

Permalink
Canvas: fix review findins
Browse files Browse the repository at this point in the history
  • Loading branch information
kullingk committed Nov 13, 2024
1 parent 4f5557d commit f91a4f9
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 24 deletions.
2 changes: 1 addition & 1 deletion contrib/vcpkg
Submodule vcpkg updated 5807 files
16 changes: 6 additions & 10 deletions src/Engine/App/AppBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,7 @@ AppBase::AppBase(i32 argc, const c8 *argv[], const String &supportedArgs, const
mStage(nullptr),
mMouseEvListener(nullptr),
mKeyboardEvListener(nullptr),
mIds(nullptr),
mCanvasRenderer(nullptr),
mStageMode(StageMode::Stage3D),
mShutdownRequested(false) {
mIds(nullptr) {
mSettings->setString(Properties::Settings::RenderAPI, "opengl");
mSettings->setBool(Properties::Settings::PollingMode, true);
}
Expand Down Expand Up @@ -257,13 +254,12 @@ bool AppBase::onCreate() {
mEnvironment = new Common::Environment;

// create the asset registry
AssetRegistry *registry = AssetRegistry::create();
if (registry == nullptr) {
if (AssetRegistry::create() == nullptr) {
osre_debug(Tag, "Cannot create asset registry.");
return false;
}

//Create the platform interface instance
// Create the platform interface instance
mPlatformInterface = Platform::PlatformInterface::create(mSettings);
if (mPlatformInterface == nullptr) {
osre_error(Tag, "Pointer to platform interface is nullptr.");
Expand All @@ -275,13 +271,13 @@ bool AppBase::onCreate() {
return false;
}

//Register any available platform-specific log streams
// Register any available platform-specific log streams
Common::AbstractLogStream *stream = Platform::PlatformPluginFactory::createPlatformLogStream();
if (stream != nullptr) {
Logger::getInstance()->registerLogStream(stream);
}

//Create the render back-end
// Create the render back-end
mRbService = new RenderBackendService();
ServiceProvider::setService(ServiceType::RenderService, mRbService);
mRbService->setSettings(mSettings, false);
Expand All @@ -300,7 +296,7 @@ bool AppBase::onCreate() {

mPlatformInterface->getPlatformEventHandler()->setRenderBackendService(mRbService);

// enable render-back-end
// Enable render-back-end
RenderBackend::CreateRendererEventData *data = new CreateRendererEventData(mPlatformInterface->getRootWindow());
data->RequestedPipeline = mRbService->createDefault3DPipeline();
mRbService->sendEvent(&RenderBackend::OnCreateRendererEvent, data);
Expand Down
6 changes: 3 additions & 3 deletions src/Engine/App/AppBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,9 @@ class OSRE_EXPORT AppBase {
MouseEventListener *mMouseEvListener;
KeyboardEventListener *mKeyboardEvListener;
Common::Ids *mIds;
StageMode mStageMode;
bool mShutdownRequested;
RenderBackend::IRenderPath *mCanvasRenderer;
StageMode mStageMode = StageMode::Stage3D;
bool mShutdownRequested = false;
RenderBackend::IRenderPath *mCanvasRenderer = nullptr;
};

inline Stage *AppBase::getStage() const {
Expand Down
11 changes: 5 additions & 6 deletions src/Engine/RenderBackend/2D/CanvasRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ inline void clip(const Rect2i &resolution, i32 x, i32 y, i32 &x_out, i32 &y_out)
}

static void createRectVertices(DrawCmd *drawCmd, const Color4 &penColor, const Rect2i &resolution, i32 x, i32 y, i32 w, i32 h, i32 layer) {
i32 x_clipped, y_clipped;
f32 x_model, y_model;
i32 x_clipped{0}, y_clipped{0};
f32 x_model{0.f}, y_model{0.f};

drawCmd->PrimType = PrimitiveType::TriangleList;
drawCmd->NumVertices = 6;
Expand Down Expand Up @@ -156,8 +156,7 @@ CanvasRenderer::CanvasRenderer(i32 numLayers, i32 x, i32 y, i32 w, i32 h) :
mActiveLayer(0),
mNumLayers(numLayers),
mFont(nullptr),
mMesh(nullptr)
/* mFont2MeshMap()*/ {
mMesh(nullptr) {
setResolution(x, y, w, h);
}

Expand Down Expand Up @@ -298,7 +297,7 @@ void CanvasRenderer::drawline(i32 x1, i32 y1, i32 x2, i32 y2) {
}

void CanvasRenderer::drawline(const Point2Di &p1, const Point2Di &p2) {
drawline(p1.X, p1.Y, p2.X, p2.Y);
drawline(p1.x, p1.y, p2.x, p2.y);
}

void CanvasRenderer::drawTriangle(i32 x1, i32 y1, i32 x2, i32 y2, i32 x3, i32 y3, bool filled) {
Expand Down Expand Up @@ -351,7 +350,7 @@ void CanvasRenderer::drawTriangle(i32 x1, i32 y1, i32 x2, i32 y2, i32 x3, i32 y3
}

void CanvasRenderer::drawTriangle(const Point2Di &p1, const Point2Di &p2, const Point2Di &p3, bool filled) {
drawTriangle(p1.X, p1.Y, p2.X, p2.Y, p3.X, p3.Y, filled);
drawTriangle(p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, filled);
}

void CanvasRenderer::drawRect(i32 x, i32 y, i32 w, i32 h, bool filled) {
Expand Down
6 changes: 3 additions & 3 deletions src/Engine/RenderBackend/RenderCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -1030,12 +1030,12 @@ GLSLVersion getGlslVersionFromeString(const c8 *versionString);

/// @brief The 2D point structure for int32.
struct Point2Di {
i32 X, Y; /// Coordinate components
i32 x, y; /// Coordinate components
};

/// @brief The 2D point structure for floats.
struct Point2Df {
f32 X, Y; /// Coordinate components
f32 x, y; /// Coordinate components
};

/// @brief The font structure.
Expand Down Expand Up @@ -1072,7 +1072,7 @@ template<class T>
inline void renumberIndices(const DrawCmd &dc, T offset) {
if (offset > 0) {
for (size_t j = 0; j < dc.NumIndices; ++j) {
dc.Indices[j] += static_cast<T>(offset);
dc.Indices[j] += static_cast<ui16>(offset);
}
}
}
Expand Down

0 comments on commit f91a4f9

Please sign in to comment.