Further GLES3 implementation

This commit is contained in:
Jack Andersen
2015-10-29 14:00:56 -10:00
parent 5435f01d20
commit 2814da014f
7 changed files with 402 additions and 206 deletions

View File

@@ -14,7 +14,7 @@ class IApplication;
struct IApplicationCallback
{
virtual int appMain(IApplication*) {}
virtual int appMain(IApplication*) {return 0;}
virtual void appQuitting(IApplication*) {}
virtual void appFilesOpen(IApplication*, const std::vector<SystemString>&) {}
};

View File

@@ -47,8 +47,11 @@ public:
virtual void initializeContext()=0;
virtual void makeCurrent()=0;
virtual std::unique_ptr<IGraphicsCommandQueue> createCommandQueue()=0;
virtual std::unique_ptr<IGraphicsDataFactory> createDataFactory()=0;
virtual IGraphicsCommandQueue* getCommandQueue()=0;
virtual IGraphicsDataFactory* getDataFactory()=0;
/* Creates a new context on current thread!! Call from client loading thread */
virtual IGraphicsDataFactory* getLoadContextDataFactory()=0;
};

View File

@@ -3,38 +3,19 @@
#include "IGraphicsDataFactory.hpp"
#include "IGraphicsCommandQueue.hpp"
#include "boo/IGraphicsContext.hpp"
#include <GLES3/gl3.h>
#include <vector>
namespace boo
{
class GLES3VertexArray
{
friend class GLES3DataFactory;
GLuint m_vao = 0;
bool initObjects();
void clearObjects();
GLES3VertexArray() = default;
public:
operator bool() const {return m_vao != 0;}
~GLES3VertexArray() {clearObjects();}
GLES3VertexArray& operator=(const GLES3VertexArray&) = delete;
GLES3VertexArray(const GLES3VertexArray&) = delete;
GLES3VertexArray& operator=(GLES3VertexArray&& other)
{
m_vao = other.m_vao;
other.m_vao = 0;
return *this;
}
GLES3VertexArray(GLES3VertexArray&& other) {*this = std::move(other);}
};
class GLES3DataFactory : public IGraphicsDataFactory
{
IGraphicsContext* m_parent;
std::unique_ptr<IGraphicsData> m_deferredData;
public:
GLES3DataFactory();
GLES3DataFactory(IGraphicsContext* parent);
Platform platform() const {return PlatformOGLES3;}
const char* platformName() const {return "OpenGL ES 3.0";}
@@ -42,19 +23,21 @@ public:
const IGraphicsBufferS* newStaticBuffer(BufferUse use, const void* data, size_t sz);
IGraphicsBufferD* newDynamicBuffer(BufferUse use);
GLES3VertexArray newVertexArray(size_t elementCount, const VertexElementDescriptor* elements);
const ITextureS* newStaticTexture(size_t width, size_t height, size_t mips, TextureFormat fmt,
const void* data, size_t sz);
ITextureD* newDynamicTexture(size_t width, size_t height, TextureFormat fmt);
const IVertexFormat* newVertexFormat(size_t elementCount, const VertexElementDescriptor* elements);
const IShaderPipeline* newShaderPipeline(const char* vertSource, const char* fragSource,
BlendFactor srcFac, BlendFactor dstFac,
bool depthTest, bool depthWrite, bool backfaceCulling);
const IShaderDataBinding*
newShaderDataBinding(const IShaderPipeline* pipeline,
size_t bufCount, const IGraphicsBuffer** bufs,
const IVertexFormat* vtxFormat,
const IGraphicsBuffer* vbo, const IGraphicsBuffer* ebo,
size_t ubufCount, const IGraphicsBuffer** ubufs,
size_t texCount, const ITexture** texs);
void reset();

View File

@@ -10,6 +10,9 @@ namespace boo
struct IGraphicsBuffer
{
bool dynamic() const {return m_dynamic;}
virtual void bindVertex() const=0;
virtual void bindIndex() const=0;
virtual void bindUniform(size_t idx) const=0;
protected:
bool m_dynamic;
IGraphicsBuffer(bool dynamic) : m_dynamic(dynamic) {}
@@ -35,6 +38,7 @@ protected:
struct ITexture
{
bool dynamic() const {return m_dynamic;}
virtual void bind(size_t idx) const=0;
protected:
bool m_dynamic;
ITexture(bool dynamic) : m_dynamic(dynamic) {}
@@ -57,6 +61,11 @@ protected:
ITextureD() : ITexture(true) {}
};
/** Opaque token for representing the data layout of a vertex
* in a VBO. Also able to reference buffers for platforms like
* OpenGL that cache object refs */
struct IVertexFormat {};
/** Opaque token for referencing a complete graphics pipeline state necessary
* to rasterize geometry (shaders and blending modes mainly) */
struct IShaderPipeline {};
@@ -104,6 +113,18 @@ struct IGraphicsDataFactory
virtual IGraphicsBufferD*
newDynamicBuffer(BufferUse use)=0;
enum TextureFormat
{
TextureFormatRGBA8,
TextureFormatDXT1,
TextureFormatPVRTC4
};
virtual const ITextureS*
newStaticTexture(size_t width, size_t height, size_t mips, TextureFormat fmt,
const void* data, size_t sz)=0;
virtual ITextureD*
newDynamicTexture(size_t width, size_t height, TextureFormat fmt)=0;
struct VertexElementDescriptor
{
const IGraphicsBuffer* vertBuffer = nullptr;
@@ -117,18 +138,8 @@ struct IGraphicsDataFactory
VertexSemanticWeight
} semantic;
};
enum TextureFormat
{
TextureFormatRGBA8,
TextureFormatDXT1,
TextureFormatPVRTC4
};
virtual const ITextureS*
newStaticTexture(size_t width, size_t height, size_t mips, TextureFormat fmt,
const void* data, size_t sz)=0;
virtual ITextureD*
newDynamicTexture(size_t width, size_t height, TextureFormat fmt)=0;
virtual const IVertexFormat*
newVertexFormat(size_t elementCount, const VertexElementDescriptor* elements)=0;
enum BlendFactor
{
@@ -146,7 +157,9 @@ struct IGraphicsDataFactory
virtual const IShaderDataBinding*
newShaderDataBinding(const IShaderPipeline* pipeline,
size_t bufCount, const IGraphicsBuffer** bufs,
const IVertexFormat* vtxFormat,
const IGraphicsBuffer* vbo, const IGraphicsBuffer* ebo,
size_t ubufCount, const IGraphicsBuffer** ubufs,
size_t texCount, const ITexture** texs)=0;
virtual void reset()=0;