-
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add string-based renderer backend configuration
Rather than using integer-indices, just use plaintext case-insensitive names and leave the actual enum indexes as an implementation detail.
- Loading branch information
Showing
4 changed files
with
38 additions
and
3 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
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 |
---|---|---|
@@ -1,4 +1,24 @@ | ||
#include "renderer.hpp" | ||
|
||
std::optional<RendererType> fromString(std::string inString) { | ||
// case-insensitive | ||
std::transform(inString.begin(), inString.end(), inString.begin(), [](unsigned char c) { return std::tolower(c); }); | ||
|
||
if (inString == "null") | ||
return RendererType::Null; | ||
else if (inString == "opengl") | ||
return RendererType::OpenGL; | ||
|
||
return std::nullopt; | ||
} | ||
|
||
const char* toString(RendererType rendererType) { | ||
switch (rendererType) { | ||
case RendererType::Null: return "null"; | ||
case RendererType::OpenGL: return "opengl"; | ||
default: return "Invalid"; | ||
} | ||
} | ||
|
||
Renderer::Renderer(GPU& gpu, const std::array<u32, regNum>& internalRegs) : gpu(gpu), regs(internalRegs) {} | ||
Renderer::~Renderer() {} |