Working on RenderTarget example

This commit is contained in:
2022-10-19 00:43:16 -07:00
parent a86574128d
commit f0cbae4cf8
17 changed files with 235 additions and 26 deletions

View File

@ -0,0 +1,24 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "dawnlibs.hpp"
namespace Dawn {
struct Color {
float_t r, g, b, a;
};
#define COLOR_WHITE { 1, 1, 1, 1 }
#define COLOR_RED { 1, 0, 0, 1 }
#define COLOR_GREEN { 0, 255, 0, 1 }
#define COLOR_BLUE { 0, 0, 255, 1 }
#define COLOR_BLACK { 0, 0, 0, 1 }
#define COLOR_MAGENTA { 1, 0, 1, 1 }
#define COLOR_CORNFLOWER_BLUE { 0.39215686274f, 0.58431372549f, 0.9294117647f, 1.0f }
#define COLOR_WHITE_TRANSPARENT { 1, 1, 1, 0 }
#define COLOR_BLACK_TRANSPARENT { 0, 0, 0, 0 }
#define COLOR_TRANSPARENT COLOR_BLACK_TRANSPARENT
}

View File

@ -0,0 +1,22 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "util/flag.hpp"
#include "display/Color.hpp"
#define RENDER_TARGET_CLEAR_FLAG_COLOR FLAG_DEFINE(0)
#define RENDER_TARGET_CLEAR_FLAG_DEPTH FLAG_DEFINE(1)
namespace Dawn {
class RenderTarget {
public:
virtual float_t getWidth() = 0;
virtual float_t getHeight() = 0;
virtual void setClearColor(struct Color color) = 0;
virtual void clear(flag8_t clearFlags) = 0;
virtual void bind() = 0;
};
}

View File

@ -4,35 +4,31 @@
// https://opensource.org/licenses/MIT
#pragma once
#include "dawnlibs.hpp"
#include "RenderTarget.hpp"
namespace Dawn {
class DawnGame;
class RenderManager {
class IRenderManager {
public:
std::weak_ptr<DawnGame> game;
/**
* Construct a new RenderManager for a game instance.
* Returns the primary render target (the backbuffer) that draws directly
* to the screen.
*
* @param game Game instance this render manager belongs to.
* @return Shared pointer to the backbuffer render target.
*/
RenderManager(std::weak_ptr<DawnGame> game);
virtual std::shared_ptr<RenderTarget> getBackBuffer() = 0;
/**
* Initialize this render manager.
*/
void init();
virtual void init() = 0;
/**
* Perform a synchronous frame update on the render manager.
*/
void update();
/**
* Destroy a previously initialized RenderManager.
*/
~RenderManager();
virtual void update() = 0;
};
}