leocad/common/lc_context.h

101 lines
2.6 KiB
C
Raw Normal View History

2014-04-14 05:20:16 +02:00
#ifndef _LC_CONTEXT_H_
#define _LC_CONTEXT_H_
2014-04-20 03:50:41 +02:00
#include "lc_array.h"
#include "lc_math.h"
2014-04-20 03:50:41 +02:00
2015-02-08 19:54:51 +01:00
class lcScene
2014-11-24 00:48:56 +01:00
{
2015-02-08 19:54:51 +01:00
public:
lcScene();
void Begin(const lcMatrix44& ViewMatrix);
void End();
lcMatrix44 mViewMatrix;
lcArray<lcRenderMesh> mOpaqueMeshes;
lcArray<lcRenderMesh> mTranslucentMeshes;
lcArray<lcObject*> mInterfaceObjects;
2014-11-24 00:48:56 +01:00
};
typedef quintptr lcVertexBuffer;
typedef quintptr lcIndexBuffer;
#define LC_INVALID_VERTEX_BUFFER 0
#define LC_INVALID_INDEX_BUFFER 0
2014-04-14 05:20:16 +02:00
class lcContext
{
public:
lcContext();
~lcContext();
int GetViewportWidth() const
{
return mViewportWidth;
}
int GetViewportHeight() const
{
return mViewportHeight;
}
2014-04-16 02:29:54 +02:00
void SetDefaultState();
void SetViewport(int x, int y, int Width, int Height);
2014-04-14 05:20:16 +02:00
void SetWorldViewMatrix(const lcMatrix44& WorldViewMatrix);
void SetProjectionMatrix(const lcMatrix44& ProjectionMatrix);
// void SetColor(const lcVector4& Color);
void SetLineWidth(float LineWidth);
2014-10-12 01:26:23 +02:00
bool BeginRenderToTexture(int Width, int Height);
void EndRenderToTexture();
bool SaveRenderToTextureImage(const QString& FileName, int Width, int Height);
2014-10-12 01:26:23 +02:00
lcVertexBuffer CreateVertexBuffer(int Size, void* Data);
void DestroyVertexBuffer(lcVertexBuffer& VertexBuffer);
lcIndexBuffer CreateIndexBuffer(int Size, void* Data);
void DestroyIndexBuffer(lcIndexBuffer& IndexBuffer);
2015-04-14 06:14:10 +02:00
void ClearVertexBuffer();
void SetVertexBuffer(lcVertexBuffer VertexBuffer);
2015-04-14 06:14:10 +02:00
void SetVertexBufferPointer(const void* VertexBuffer);
void SetVertexFormat(int BufferOffset, int PositionSize, int TexCoordSize, int ColorSize);
void DrawPrimitives(GLenum Mode, GLint First, GLsizei Count);
2014-04-14 05:20:16 +02:00
void UnbindMesh();
void DrawMeshSection(lcMesh* Mesh, lcMeshSection* Section);
2014-04-20 03:50:41 +02:00
void DrawOpaqueMeshes(const lcMatrix44& ViewMatrix, const lcArray<lcRenderMesh>& OpaqueMeshes);
void DrawTranslucentMeshes(const lcMatrix44& ViewMatrix, const lcArray<lcRenderMesh>& TranslucentMeshes);
2014-11-24 00:48:56 +01:00
void DrawInterfaceObjects(const lcMatrix44& ViewMatrix, const lcArray<lcObject*>& InterfaceObjects);
2014-04-14 05:20:16 +02:00
protected:
void BindMesh(lcMesh* Mesh);
2014-04-14 05:20:16 +02:00
GLuint mVertexBufferObject;
GLuint mIndexBufferObject;
char* mVertexBufferPointer;
char* mIndexBufferPointer;
char* mVertexBufferOffset;
2015-04-14 06:14:10 +02:00
bool mTexCoordEnabled;
bool mColorEnabled;
2014-04-14 05:20:16 +02:00
lcTexture* mTexture;
float mLineWidth;
int mMatrixMode;
2014-10-12 01:26:23 +02:00
int mViewportX;
int mViewportY;
int mViewportWidth;
int mViewportHeight;
2014-10-12 01:26:23 +02:00
GLuint mFramebufferObject;
GLuint mFramebufferTexture;
GLuint mDepthRenderbufferObject;
Q_DECLARE_TR_FUNCTIONS(lcContext);
2014-04-14 05:20:16 +02:00
};
#endif // _LC_CONTEXT_H_