gcmgl is a C++ graphics library targeting PlayStation 3 (GCM) and Linux (x86_64, OpenGL). gcmgl provides a platform-abstracted renderer interface covering viewports, buffers, shader programs, textures, blend states, draw calls, and batch rendering. Mathematics support is provided by mathsfury.
BufferHandleShaderProgramHandleTextureHandleSamplerHandleRenderTargetHandleUniformBlockLayoutHandle
void* m_pWindowuint32 m_Widthuint32 m_Heightbool m_IsFullscreenbool m_IsVSync
ClearNoneClearColorClearDepthClearStencilClearAll
float32 m_Xfloat32 m_Yfloat32 m_Widthfloat32 m_Heightfloat32 m_MinDepthfloat32 m_MaxDepth
int32 m_Xint32 m_Yuint32 m_Widthuint32 m_Height
StaticDynamicImmutable
UInt16UInt32
R8RG8RGB8RGBA8R16FRG16FRGB16FRGBA16FR32FRG32FRGB32FRGBA32FDepth16Depth24Depth32FDepth24Stencil8
RepeatMirroredRepeatClampToEdge
NoneRefToTexture
ShaderStageVertexShaderStageFragmentShaderStageAll
UnspecifiedFloatFloat2Float3Float4UByte4_Norm
UnspecifiedPositionWeightNormalColor0Color1FogPointSizeEdgeFlagTexCoord0TexCoord1TexCoord2TexCoord3TexCoord4TexCoord5TexCoord6TangentTexCoord7Binormal
CFixedString m_NameVertexFormat_t::Enum m_Formatuint32 m_Offsetuint32 m_LocationVertexSemantic_t::Enum m_VertexSemantic
void AddAttribute(const CFixedString& name, uint32 format, uint32 offset, uint32 location = 0)void AddAttribute(const CFixedString& name, uint32 format, uint32 offset, VertexSemantic_t::Enum vertexSemantic, uint32 location = 0)void SetStride(uint32 vertexStride)uint32 GetStride() constconst CUtlVector<VertexAttribute_t>& GetAttributes() const
bool m_IsEnabledbool m_IsAdditive
bool m_IsDepthTestbool m_IsDepthWrite
uint64 m_IndexOffsetconst CVertexLayout* m_pVertexLayoutShaderProgramHandle m_hShaderProgramBufferHandle m_hVertexBufferBufferHandle m_hIndexBufferuint32 m_VertexStrideuint32 m_VertexOffsetDepthStencilState_t m_DepthStencilStateBlendState_t m_BlendState
CUtlVector<CFixedString> m_UniformNamesuint32 m_Bindinguint32 m_Size
CQuaternion m_RotationCVector3 m_PositionCVector3 m_ScaleCMatrix4 ToMatrix() const
CUtlVector<BatchChunkTransform_t> m_BatchChunkTransformsCVector3 m_CenterCVector3 m_Extent
CUtlVector<BatchChunk_t> m_BatchChunksconst CVector3* m_pCameraPosvoid Add(const CVector3& position, const CQuaternion& rotation = CQuaternion(), const CVector3& scale = CVector3(1.0f, 1.0f, 1.0f))void Build(float32 chunkSize = 500.0f)void Clear()uint32 GetCount() const
CVector3 m_Normalfloat32 m_Distance
OutsidePartialInside
bool Init(const RendererDesc_t& rendererDesc)void Shutdown()void SetEnvironment()void BeginFrame()void EndFrame()void Clear(uint32 clearFlags, const CColor& color = CColor::Black, float32 depth = 1.0f, uint32 stencil = 0)void GetFramebufferSize(uint32& width, uint32& height) constfloat32 GetAspectRatio() constvoid SetFullViewport()void SetViewport(const Viewport_t& viewport)Viewport_t GetViewport()void SetScissor(const Rect_t& rect)void SetStencilRef(uint32 stencilRef)RenderTargetHandle CreateRenderTarget(uint32 width, uint32 height, TextureFormat_t::Enum colorFormat, TextureFormat_t::Enum depthFormat)RenderTargetHandle CreateRenderTargetCube(uint32 size, TextureFormat_t::Enum colorFormat, TextureFormat_t::Enum depthFormat)void DestroyRenderTarget(RenderTargetHandle hRenderTarget)void SetRenderTarget(RenderTargetHandle hRenderTarget, uint32 faceIndex = 0)TextureHandle GetRenderTargetColorTexture(RenderTargetHandle hRenderTarget) constTextureHandle GetRenderTargetDepthTexture(RenderTargetHandle hRenderTarget) constBufferHandle CreateVertexBuffer(const void* pData, uint64 size, BufferUsage_t::Enum usage)BufferHandle CreateIndexBuffer(const void* pData, uint64 size, IndexFormat_t::Enum format, BufferUsage_t::Enum usage)BufferHandle CreateConstantBuffer(uint64 size, BufferUsage_t::Enum usage)void UpdateBuffer(BufferHandle hBuffer, const void* pData, uint64 size, uint64 offset = 0)void DestroyBuffer(BufferHandle hBuffer)void* MapBuffer(BufferHandle hBuffer)void UnmapBuffer(BufferHandle hBuffer)BufferHandle CreateStagingBuffer(uint64 size)ShaderProgramHandle CreateShaderProgram(const CFixedString& shaderName)ShaderProgramHandle GetOrCreateShaderProgram(const CFixedString& shaderName)void DestroyShaderProgram(ShaderProgramHandle hProgram)void ClearShaderCache()TextureHandle CreateTexture2D(uint32 width, uint32 height, TextureFormat_t::Enum format, const void* pData = GCMGL_NULL)TextureHandle CreateTextureCube(uint32 size, TextureFormat_t::Enum format, const void** ppFaces = GCMGL_NULL)void SetTexture(TextureHandle hTexture, uint32 slot, ShaderStage_t stage, TextureWrapMode_t::Enum wrapMode = TextureWrapMode_t::Repeat)void SetTextureCompareMode(TextureHandle hTexture, TextureCompareMode_t::Enum compareMode)void SetSampler(SamplerHandle hSampler, uint32 slot, ShaderStage_t stage)void UpdateTexture(TextureHandle hTexture, const void* pData, uint32 mipLevel = 0)void DestroyTexture(TextureHandle hTexture)void SetShaderProgram(ShaderProgramHandle hProgram)void SetVertexBuffer(BufferHandle hBuffer, uint32 slot = 0, uint32 vertexStride = 0, uint32 offset = 0, const CVertexLayout* pLayout = GCMGL_NULL)void SetIndexBuffer(BufferHandle hBuffer, uint64 offset = 0)UniformBlockLayoutHandle CreateUniformBlockLayout(const UniformBlockLayout_t& layout)UniformBlockLayoutHandle GetOrCreateUniformBlockLayout(ShaderProgramHandle hProgram, const UniformBlockLayout_t& layout)void SetConstantBuffer(BufferHandle hBuffer, UniformBlockLayoutHandle hLayout, uint32 slot, ShaderStage_t stage)int32 GetUniformBlockBinding(ShaderProgramHandle hProgram, const char* pBlockName)void SetBlendState(const BlendState_t& state)void SetDepthStencilState(const DepthStencilState_t& state)void ExtractFrustumPlanes(const CMatrix4& mvp, Plane_t* pPlanes)bool TestAABBFrustum(const CVector3& center, const CVector3& extent, const Plane_t* pPlanes)void Draw(uint32 vertexCount, uint32 startVertex = 0, const CMatrix4* pViewProjection = GCMGL_NULL, const CVector3* pAABBCenter = GCMGL_NULL, const CVector3* pAABBExtent = GCMGL_NULL)void DrawIndexed(uint32 indexCount, uint32 startIndex = 0, int32 baseVertex = 0, const CMatrix4* pViewProjection = GCMGL_NULL, const CVector3* pAABBCenter = GCMGL_NULL, const CVector3* pAABBExtent = GCMGL_NULL)void DrawBatched(uint32 vertexCount, const CBatch& batch, const CMatrix4& viewProjection, uint32 startVertex = 0)void DrawIndexedBatched(uint32 indexCount, uint32 vertexCount, const CBatch& batch, const CMatrix4& viewProjection, uint32 startIndex = 0, int32 baseVertex = 0, bool isPerInstanceCull = true)void DrawInstanced(uint32 vertexCount, uint32 instanceCount, const CMatrix4* pMatrices, const CVertexLayout* pInstanceLayout = GCMGL_NULL)void DrawIndexedInstanced(uint32 indexCount, uint32 instanceCount, const CMatrix4* pMatrices, uint32 startIndex = 0, const CVertexLayout* pInstanceLayout = GCMGL_NULL)void SetPipelineState(const PipelineState_t& state)void FlushPipelineState()
float32 GetAspectRatio() constFrustumVisibility_t::Enum GetAABBFrustumVisibility(const CVector3& center, const CVector3& extent, const Plane_t* pPlanes)
Install required build dependencies:
- Fedora:
sudo dnf install cmake gcc-c++ glfw-devel mesa-libGL-devel pkgconf-pkg-config ImageMagickBuild using the provided scripts:
- Linux (x86_64):
./scripts/build_linux_x86_64.sh- PlayStation 3:
./scripts/build_ps3.shBuild scripts prompt for an example to build: Triangle, Cube, Shader, Textured, Lit, TexturedLit, Batch, or BatchInstanced.
gcmgl is licensed under the MIT License.