-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Raylib graphics backend and use it in main
Finally bring the newer abstract graphics systems into the main part of the engine. Create backends for raylib and use them in the LeonaTestState so we can finally render Leona again. Text rendering and adjustments to Renderers in GracilisGame are still pending.
- Loading branch information
1 parent
126e673
commit c5c2458
Showing
21 changed files
with
151 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include "RaylibGraphicsDevice.h" | ||
|
||
void RaylibGraphicsDevice::begin() { | ||
ClearBackground({clearColor.r, clearColor.g, clearColor.b, clearColor.a}); | ||
BeginDrawing(); | ||
} | ||
|
||
void RaylibGraphicsDevice::end() { | ||
EndDrawing(); | ||
} | ||
|
||
void RaylibGraphicsDevice::setClearColor(const Adagio::Color &color) { | ||
clearColor = color; | ||
} | ||
|
||
static Rectangle AdagioRectToRaylibRect(const Adagio::RectF &rect) { | ||
return {rect.x(), rect.y(), rect.width(), rect.height()}; | ||
} | ||
|
||
void | ||
RaylibGraphicsDevice::drawTexture(Adagio::Texture2D &texture, const Adagio::RectF &source, const Adagio::RectF &dest, | ||
const Adagio::Vector2d &origin, float rotation, const Adagio::Color &tint) { | ||
RaylibTexture raylibTex = textureManager.useTexture(texture); | ||
DrawTexturePro(raylibTex, AdagioRectToRaylibRect(source), AdagioRectToRaylibRect(dest), | ||
{static_cast<float>(origin.x), static_cast<float>(origin.y)}, rotation, | ||
{tint.r, tint.g, tint.b, tint.a}); | ||
} | ||
|
||
Adagio::AbstractTextureManager *RaylibGraphicsDevice::getTextureManager() { | ||
return &textureManager; | ||
} | ||
|
||
void RaylibGraphicsDevice::drawText(Font &font, const char *text, const Adagio::Vector2d &position, float fontSize, | ||
float spacing, const Adagio::Color &tint) { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#ifndef GL_ADAGIO_RAYLIBGRAPHICSDEVICE_H | ||
#define GL_ADAGIO_RAYLIBGRAPHICSDEVICE_H | ||
|
||
#include "raylib.h" | ||
#include "RaylibTextureLoader.h" | ||
#include "../../graphics/GraphicsDevice.h" | ||
|
||
typedef Texture2D RaylibTexture; | ||
|
||
class RaylibGraphicsDevice : public Adagio::GraphicsDevice { | ||
private: | ||
RaylibTextureLoader loader; | ||
Adagio::TextureManager<RaylibTexture> textureManager{&loader}; | ||
Adagio::Color clearColor{0, 0, 0, 255}; | ||
public: | ||
void begin() override; | ||
|
||
void end() override; | ||
|
||
void setClearColor(const Adagio::Color &color) override; | ||
|
||
Adagio::AbstractTextureManager *getTextureManager() override; | ||
|
||
void drawTexture(Adagio::Texture2D &texture, const Adagio::RectF &source, const Adagio::RectF &dest, | ||
const Adagio::Vector2d &origin, float rotation, const Adagio::Color &tint) override; | ||
|
||
void drawText(Font &font, const char *text, const Adagio::Vector2d &position, float fontSize, float spacing, | ||
const Adagio::Color &tint) override; | ||
|
||
}; | ||
|
||
|
||
#endif //GL_ADAGIO_RAYLIBGRAPHICSDEVICE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#ifndef GL_ADAGIO_RAYLIBTEXTURE_H | ||
#define GL_ADAGIO_RAYLIBTEXTURE_H | ||
|
||
#include "raylib.h" | ||
|
||
typedef Texture2D RaylibTexture; | ||
|
||
#endif //GL_ADAGIO_RAYLIBTEXTURE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include "RaylibTextureLoader.h" | ||
#include <utility> | ||
|
||
std::pair<RaylibTexture, Adagio::TextureDimensions> RaylibTextureLoader::load(const char *resource) { | ||
RaylibTexture tex = LoadTexture(resource); | ||
Adagio::TextureDimensions dims{static_cast<unsigned int>(tex.width), static_cast<unsigned int>(tex.height)}; | ||
return std::make_pair(tex, dims); | ||
} | ||
|
||
void RaylibTextureLoader::unload(RaylibTexture texture) { | ||
UnloadTexture(texture); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#ifndef GL_ADAGIO_RAYLIBTEXTURELOADER_H | ||
#define GL_ADAGIO_RAYLIBTEXTURELOADER_H | ||
|
||
#include "RaylibTexture.h" | ||
#include "../../graphics/TextureLoader.h" | ||
|
||
class RaylibTextureLoader : public Adagio::TextureLoader<RaylibTexture> { | ||
public: | ||
std::pair<RaylibTexture, Adagio::TextureDimensions> load(const char *resource) override; | ||
|
||
void unload(RaylibTexture texture) override; | ||
}; | ||
|
||
|
||
#endif //GL_ADAGIO_RAYLIBTEXTURELOADER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters