WIP: hwr2 renderer stuff

This commit is contained in:
Eidolon 2022-07-24 20:45:23 -05:00
parent c61fef0e0d
commit 0baa2c2843
10 changed files with 157 additions and 0 deletions

View file

@ -96,3 +96,5 @@ lua_polyobjlib.c
lua_blockmaplib.c
lua_hudlib.c
lua_inputlib.c
hwr2/gles2/renderer.cpp

View file

@ -164,7 +164,11 @@ size_t strlcpy(char *dst, const char *src, size_t siz);
#define true TRUE
#define boolean BOOL
#else
#ifndef __cplusplus
typedef enum {false, true} boolean;
#else
typedef int32_t boolean;
#endif
#endif
#endif // __BYTEBOOL__

View file

@ -0,0 +1,32 @@
#include "renderer.hpp"
Gles2Renderer::~Gles2Renderer()
{
}
IGraphicsContext* Gles2Renderer::BeginGraphics()
{
return nullptr;
}
void Gles2Renderer::EndGraphics(IGraphicsContext* context)
{
}
ITransferContext* Gles2Renderer::BeginTransfer()
{
return nullptr;
}
void Gles2Renderer::EndTransfer(ITransferContext* context)
{
}
GraphicsPipeline* Gles2Renderer::CreateGraphicsPipeline(const GraphicsPipelineInfo& info)
{
return nullptr;
}
void Gles2Renderer::DestroyGraphicsPipeline(GraphicsPipeline* pipeline)
{
}

View file

@ -0,0 +1,21 @@
#ifndef __HWR2_GLES2_RENDERER_HPP__
#define __HWR2_GLES2_RENDERER_HPP__
#include "../renderer.h"
class Gles2Renderer : public IRenderer {
public:
~Gles2Renderer();
virtual IGraphicsContext* BeginGraphics();
virtual void EndGraphics(IGraphicsContext* context);
virtual ITransferContext* BeginTransfer();
virtual void EndTransfer(ITransferContext* context);
virtual GraphicsPipeline* CreateGraphicsPipeline(const GraphicsPipelineInfo& info);
virtual void DestroyGraphicsPipeline(GraphicsPipeline* pipeline);
virtual void Present() = 0;
};
#endif

View file

@ -0,0 +1,13 @@
#ifndef __HWR2_GRAPHICS_CONTEXT_HPP__
#define __HWR2_GRAPHICS_CONTEXT_HPP__
#include <cstdint>
class IGraphicsContext {
protected:
~IGraphicsContext() {}
public:
virtual void Draw(int32_t vertices) = 0;
};
#endif // __HWR2_GRAPHICS_CONTEXT_HPP__

51
src/hwr2/renderer.h Normal file
View file

@ -0,0 +1,51 @@
#ifndef __HWR2_RENDERER_H__
#define __HWR2_RENDERER_H__
#ifdef __cplusplus
#include <cstdint>
#include "graphics_context.hpp"
#include "transfer_context.hpp"
extern "C" {
#endif
/// A C-side handle to a HWR2 rendere instance.
typedef void* hwr2renderer_h;
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
struct GraphicsPipeline {
uint32_t foo;
};
struct GraphicsPipelineInfo {
uint32_t foo;
};
/// A class which implements functionality for rendering.
class IRenderer {
protected:
~IRenderer() {}
public:
virtual IGraphicsContext* BeginGraphics() = 0;
virtual void EndGraphics(IGraphicsContext* context) = 0;
virtual ITransferContext* BeginTransfer() = 0;
virtual void EndTransfer(ITransferContext* context) = 0;
virtual GraphicsPipeline* CreateGraphicsPipeline(const GraphicsPipelineInfo& info) = 0;
virtual void DestroyGraphicsPipeline(GraphicsPipeline* pipeline) = 0;
virtual void Present() = 0;
};
#else
#endif // __cplusplus
#endif // __HWR2_RENDERER_H__

View file

@ -0,0 +1,9 @@
#ifndef __HWR2_TRANSFER_CONTEXT_HPP__
#define __HWR2_TRANSFER_CONTEXT_HPP__
class ITransferContext {
protected:
~ITransferContext() {}
};
#endif // __HWR2_TRANSFER_CONTEXT_HPP__

View file

@ -16,6 +16,8 @@
#include "doomtype.h"
#include "hwr2/renderer.h"
#ifdef __GNUG__
#pragma interface
#endif
@ -154,4 +156,9 @@ void I_BeginRead(void);
*/
void I_EndRead(void);
/** \brief Get the current Hardware Renderer instance handle.
* \return NULL if HWR2 is not active or failed to initialize.
*/
hwr2renderer_h I_GetHwr2Renderer(void);
#endif

View file

@ -5,3 +5,4 @@ i_video.c
dosstr.c
endtxt.c
hwsym_sdl.c
i_video_hwr2.cpp

17
src/sdl/i_video_hwr2.cpp Normal file
View file

@ -0,0 +1,17 @@
extern "C" {
#include "../i_video.h"
}
#include "../hwr2/gles2/renderer.hpp"
class Sdl2Gles2Renderer : public Gles2Renderer
{
public:
virtual void Present()
{}
};
hwr2renderer_h I_GetHwr2Renderer()
{
return reinterpret_cast<hwr2renderer_h>(new Sdl2Gles2Renderer());
}