1#include "RenderFunctions.h"
4#include "DebugFunctions.h"
6#include "ViewContext.h"
8#include "Services/DPIService.h"
9#include "Services/Time.h"
11#include "Renderer/IRenderer.h"
13#include "Systems/Core/CameraSystem.h"
15#include "Components/Core/CameraComponent.h"
17#include "Foundation/Platform/Mouse.h"
21CogsBool render(BridgeContext* ctx) {
24 CHECKED(context, context->
engine->update());
25 return context->
engine->needsUpdate();
28void resize(BridgeContext* ctx,
int x,
int y) {
32 resizeView(view, x, y);
36void resizeView(BridgeView* bv,
int x,
int y) {
40void setDPI(BridgeContext* ctx,
int dpi,
float scaleFactor) {
44 setViewDPI(view, dpi, scaleFactor);
48void setViewDPI(BridgeView* bv,
int dpi,
float scaleFactor) {
52void setRenderMode(BridgeContext * ctx,
int mode)
54 auto context =
static_cast<Context *
>(ctx);
57 context->
engine->setDirty();
60void setBackgroundColor(BridgeContext * ctx,
float * color)
62 auto context =
static_cast<Context *
>(ctx);
65 context->
engine->setDirty();
68void * renderScreenshot(BridgeContext * ctx,
const void * settingsPtr, uint32_t * stride)
70 auto context =
static_cast<Context *
>(ctx);
75 resize(ctx, settings->width, settings->height);
79 context->
time->update();
80 context->
engine->updateSystems();
81 context->
engine->preRender();
83 static std::vector<uint8_t> bytes;
88 resize(ctx,
static_cast<int>(oldSize.x),
static_cast<int>(oldSize.y));
93int getEnginePermutationId(BridgeContext * ctx,
const char * name)
95 auto context =
static_cast<Context *
>(ctx);
99void setEnginePermutationProperty(BridgeContext * ctx,
int id,
const char * key,
const void * value,
int valueSize)
101 auto context =
static_cast<Context *
>(ctx);
A Context instance contains all the services, systems and runtime components needed to use Cogs.
class IRenderer * renderer
Renderer.
std::unique_ptr< class Time > time
Time service instance.
std::unique_ptr< class Engine > engine
Engine instance.
virtual void endFrame(uint32_t syncInterval=0, uint32_t presentFlags=Cogs::PresentFlags::None)=0
Signals the end of the current frame.
virtual void renderScreenshot(const ScreenshotSettings &settings, std::vector< uint8_t > &bytes, uint32_t *stride)=0
Render screenshot.
virtual void setMode(RenderMode mode)=0
Set the rendering mode the renderer should use.
virtual void beginFrame()=0
Signals the beginning of a new frame.
virtual EnginePermutations & getEnginePermutations()=0
Get the reference to the EnginePermutations structure.
virtual glm::vec2 getSize() const =0
Get the output surface size of the renderer.
virtual void setBackgroundColor(const glm::vec4 &color)=0
Set the background color applied to the output surface before rendering.
Contains the Engine, Renderer, resource managers and other systems needed to run Cogs....
RenderMode
Defines global rendering modes that can be supported by the renderer.
Screenshot render settings.
@ NoSwap
Disables frame buffer swapping. This will leave the currently presented buffer as is.