Added CopyTo(Image/Texture) to NzRenderWindow

Added several methods to NzRenderer
Optimized NzRenderer::GetMax*();
Nz(Render)Window::GetSize now returns an unsigned vector
Fixed textures being flipped
This commit is contained in:
Lynix
2012-06-05 23:06:47 +02:00
parent a176648265
commit ddd2a2f310
13 changed files with 619 additions and 229 deletions

View File

@@ -74,6 +74,7 @@ NAZARA_API extern PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus;
NAZARA_API extern PFNGLCOLORMASKPROC glColorMask;
NAZARA_API extern PFNGLCULLFACEPROC glCullFace;
NAZARA_API extern PFNGLCOMPILESHADERPROC glCompileShader;
NAZARA_API extern PFNGLCOPYTEXSUBIMAGE2DPROC glCopyTexSubImage2D;
NAZARA_API extern PFNGLDEBUGMESSAGECONTROLARBPROC glDebugMessageControl;
NAZARA_API extern PFNGLDEBUGMESSAGEINSERTARBPROC glDebugMessageInsert;
NAZARA_API extern PFNGLDEBUGMESSAGECALLBACKARBPROC glDebugMessageCallback;
@@ -130,6 +131,7 @@ NAZARA_API extern PFNGLLINKPROGRAMPROC glLinkProgram;
NAZARA_API extern PFNGLMAPBUFFERPROC glMapBuffer;
NAZARA_API extern PFNGLMAPBUFFERRANGEPROC glMapBufferRange;
NAZARA_API extern PFNGLPOLYGONMODEPROC glPolygonMode;
NAZARA_API extern PFNGLREADPIXELSPROC glReadPixels;
NAZARA_API extern PFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage;
NAZARA_API extern PFNGLSCISSORPROC glScissor;
NAZARA_API extern PFNGLSHADERSOURCEPROC glShaderSource;

View File

@@ -19,10 +19,14 @@
#endif
class NzContext;
class NzImage;
class NzTexture;
struct NzContextParameters;
class NAZARA_API NzRenderWindow : public NzRenderTarget, public NzWindow
{
friend class NzTexture;
public:
NzRenderWindow();
NzRenderWindow(NzVideoMode mode, const NzString& title, nzUInt32 style = NzWindow::Default, const NzContextParameters& parameters = NzContextParameters());
@@ -31,6 +35,9 @@ class NAZARA_API NzRenderWindow : public NzRenderTarget, public NzWindow
bool CanActivate() const;
bool CopyToImage(NzImage* image); ///TODO: Const
bool CopyToTexture(NzTexture* texture); ///TODO: Const
bool Create(NzVideoMode mode, const NzString& title, nzUInt32 style = NzWindow::Default, const NzContextParameters& parameters = NzContextParameters());
bool Create(NzWindowHandle handle, const NzContextParameters& parameters = NzContextParameters());

View File

@@ -13,6 +13,34 @@
#define NazaraRenderer NzRenderer::Instance()
enum nzBlendFunc
{
nzBlendFunc_DestAlpha,
nzBlendFunc_DestColor,
nzBlendFunc_SrcAlpha,
nzBlendFunc_SrcColor,
nzBlendFunc_InvDestAlpha,
nzBlendFunc_InvDestColor,
nzBlendFunc_InvSrcAlpha,
nzBlendFunc_InvSrcColor,
nzBlendFunc_One,
nzBlendFunc_Zero
};
enum nzFaceCulling
{
nzFaceCulling_Back,
nzFaceCulling_Front,
nzFaceCulling_FrontAndBack
};
enum nzFaceFilling
{
nzFaceFilling_Point,
nzFaceFilling_Line,
nzFaceFilling_Fill
};
enum nzPrimitiveType
{
nzPrimitiveType_LineList,
@@ -46,6 +74,40 @@ enum nzRendererClear
nzRendererClear_Stencil = 0x04
};
enum nzRendererComparison
{
nzRendererComparison_Always,
nzRendererComparison_Equal,
nzRendererComparison_Greater,
nzRendererComparison_GreaterOrEqual,
nzRendererComparison_Less,
nzRendererComparison_LessOrEqual,
nzRendererComparison_Never
};
enum nzRendererParameter
{
nzRendererParameter_AlphaTest,
nzRendererParameter_Blend,
nzRendererParameter_ColorWrite,
nzRendererParameter_DepthTest,
nzRendererParameter_DepthWrite,
nzRendererParameter_FaceCulling,
nzRendererParameter_Stencil
};
enum nzStencilOperation
{
nzStencilOperation_Decrement,
nzStencilOperation_DecrementToSaturation,
nzStencilOperation_Increment,
nzStencilOperation_IncrementToSaturation,
nzStencilOperation_Invert,
nzStencilOperation_Keep,
nzStencilOperation_Replace,
nzStencilOperation_Zero
};
class NzColor;
class NzContext;
class NzIndexBuffer;
@@ -66,6 +128,10 @@ class NAZARA_API NzRenderer
void DrawIndexedPrimitives(nzPrimitiveType primitive, unsigned int firstIndex, unsigned int indexCount);
void DrawPrimitives(nzPrimitiveType primitive, unsigned int firstVertex, unsigned int vertexCount);
void Enable(nzRendererParameter parameter, bool enable);
unsigned int GetMaxAnisotropyLevel() const;
unsigned int GetMaxRenderTargets() const;
unsigned int GetMaxTextureUnits() const;
NzShader* GetShader() const;
NzRenderTarget* GetTarget() const;
@@ -77,8 +143,16 @@ class NAZARA_API NzRenderer
void SetClearColor(nzUInt8 r, nzUInt8 g, nzUInt8 b, nzUInt8 a = 255);
void SetClearDepth(double depth);
void SetClearStencil(unsigned int value);
void SetFaceCulling(nzFaceCulling cullingMode);
void SetFaceFilling(nzFaceFilling fillingMode);
bool SetIndexBuffer(const NzIndexBuffer* indexBuffer);
bool SetShader(NzShader* shader);
void SetStencilCompareFunction(nzRendererComparison compareFunc);
void SetStencilFailOperation(nzStencilOperation failOperation);
void SetStencilMask(nzUInt32 mask);
void SetStencilPassOperation(nzStencilOperation passOperation);
void SetStencilReferenceValue(unsigned int refValue);
void SetStencilZFailOperation(nzStencilOperation zfailOperation);
bool SetTarget(NzRenderTarget* target);
bool SetVertexBuffer(const NzVertexBuffer* vertexBuffer);
bool SetVertexDeclaration(const NzVertexDeclaration* vertexDeclaration);
@@ -89,19 +163,30 @@ class NAZARA_API NzRenderer
static bool IsInitialized();
private:
bool UpdateStates();
bool EnsureStateUpdate();
typedef std::tuple<const NzContext*, const NzIndexBuffer*, const NzVertexBuffer*, const NzVertexDeclaration*> VAO_Key;
std::map<VAO_Key, unsigned int> m_vaos;
nzRendererComparison m_stencilCompare;
nzStencilOperation m_stencilFail;
nzStencilOperation m_stencilPass;
nzStencilOperation m_stencilZFail;
nzUInt32 m_stencilMask;
const NzIndexBuffer* m_indexBuffer;
NzRenderTarget* m_target;
NzShader* m_shader;
NzUtility* m_utilityModule;
const NzVertexBuffer* m_vertexBuffer;
const NzVertexDeclaration* m_vertexDeclaration;
bool m_vaoUpdated;
bool m_capabilities[nzRendererCap_Count];
bool m_statesUpdated;
bool m_stencilFuncUpdated;
bool m_stencilOpUpdated;
unsigned int m_maxAnisotropyLevel;
unsigned int m_maxRenderTarget;
unsigned int m_maxTextureUnit;
unsigned int m_stencilReference;
static NzRenderer* s_instance;
static bool s_initialized;

View File

@@ -27,7 +27,7 @@ enum nzTextureWrap
nzTextureWrap_Unknown
};
class NzRenderWindow; ///TODO: Screenshot
class NzShader;
struct NzTextureImpl;
class NAZARA_API NzTexture : public NzResource, NzNonCopyable

View File

@@ -61,7 +61,7 @@ class NAZARA_API NzWindow : NzNonCopyable
NzWindowHandle GetHandle() const;
unsigned int GetHeight() const;
NzVector2i GetPosition() const;
NzVector2i GetSize() const;
NzVector2ui GetSize() const;
NzString GetTitle() const;
unsigned int GetWidth() const;