Added RenderTextures (And many others things)

-Added Forward, left and up vector (Vector3)
-Added Matrix4::ConcatenateAffine shortcut
-Added Quaternion::GetInverse() and Quaternion::Inverse()
-Added Resource listeners
-Added Depth and stencil pixel formats
-All enums now have an ending "max" entry
-Animation/Mesh::Add[Sequence/Skin/SubMesh] now returns a boolean
-Contexts are now resources
-Enhanced AnimatedMesh demo
-Fixed MD2 facing
-Fixed Vector3::CrossProduct
-Made Resource thread-safe
-Made OpenGL translation table global
-Many bugfixes
-MLT will now write malloc failure to the log
-Most of the strcpy were replaced with faster memcpy
-Occlusion queries availability is now always tested
-OpenGL-related includes now requires NAZARA_RENDERER_OPENGL to be
defined to have any effect
-Pixel formats now have a type
-Renamed RenderTarget::IsValid to IsRenderable
-Renamed Quaternion::GetNormalized() to GetNormal()
-Renamed Texture::Bind() to Prepare()
-Renamed VectorX::Make[Ceil|Floor] to Maximize/Minimize
-Removed MATH_MATRIX_COLUMN_MAJOR option (all matrices are column-major)
-Removed RENDERER_ACTIVATE_RENDERWINDOW_ON_CREATION option (Render
windows are active upon their creation)


Former-commit-id: 0d1da1e32c156a958221edf04a5315c75b354450
This commit is contained in:
Jérôme Leclercq
2012-09-20 22:07:30 +02:00
parent a6ed70123b
commit cd5a1b7a5e
65 changed files with 24385 additions and 22703 deletions

View File

@@ -1,44 +1,41 @@
/*
Nazara Engine - Renderer module
Copyright (C) 2012 Jérôme "Lynix" Leclercq (Lynix680@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#ifndef NAZARA_CONFIG_RENDERER_HPP
#define NAZARA_CONFIG_RENDERER_HPP
/// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci
// Active une fenêtre de rendu (NzRenderWindow) lors de sa création
#define NAZARA_RENDERER_ACTIVATE_RENDERWINDOW_ON_CREATION 1
// Utilise un tracker pour repérer les éventuels leaks (Ralentit l'exécution)
#define NAZARA_RENDERER_MEMORYLEAKTRACKER 0
// Active le paramère debug des paramètres des contextes par défaut (Perte de performances mais capable de recevoir des messages d'OpenGL)
#define NAZARA_RENDERER_OPENGL_DEBUG 0
// Active les tests de sécurité basés sur le code (Conseillé pour le développement)
#define NAZARA_RENDERER_SAFE 1
#endif // NAZARA_CONFIG_MODULENAME_HPP
/*
Nazara Engine - Renderer module
Copyright (C) 2012 Jérôme "Lynix" Leclercq (Lynix680@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#ifndef NAZARA_CONFIG_RENDERER_HPP
#define NAZARA_CONFIG_RENDERER_HPP
/// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci
// Utilise un tracker pour repérer les éventuels leaks (Ralentit l'exécution)
#define NAZARA_RENDERER_MEMORYLEAKTRACKER 0
// Active le paramère debug des paramètres des contextes par défaut (Perte de performances mais capable de recevoir des messages d'OpenGL)
#define NAZARA_RENDERER_OPENGL_DEBUG 0
// Active les tests de sécurité basés sur le code (Conseillé pour le développement)
#define NAZARA_RENDERER_SAFE 1
#endif // NAZARA_CONFIG_MODULENAME_HPP

View File

@@ -1,47 +1,49 @@
// Copyright (C) 2012 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#ifdef NAZARA_RENDERER_COMMON
#error This file is not part of the common renderer interface, you must undefine NAZARA_RENDERER_COMMON to use it
#endif
#pragma once
#ifndef NAZARA_CONTEXT_HPP
#define NAZARA_CONTEXT_HPP
#include <Nazara/Renderer/ContextParameters.hpp>
class NzContextImpl;
class NAZARA_API NzContext
{
friend NzContextImpl;
public:
NzContext();
~NzContext();
bool Create(const NzContextParameters& parameters = NzContextParameters());
void Destroy();
const NzContextParameters& GetParameters() const;
bool IsActive() const;
bool SetActive(bool active);
void SwapBuffers();
static bool EnsureContext();
static NzContext* GetCurrent();
static const NzContext* GetReference();
static NzContext* GetThreadContext();
static bool Initialize();
static void Uninitialize();
private:
NzContextParameters m_parameters;
NzContextImpl* m_impl;
static NzContext* s_reference;
};
#endif // NAZARA_CONTEXT_HPP
// Copyright (C) 2012 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_CONTEXT_HPP
#define NAZARA_CONTEXT_HPP
#ifdef NAZARA_RENDERER_OPENGL
#include <Nazara/Core/Resource.hpp>
#include <Nazara/Renderer/ContextParameters.hpp>
class NzContextImpl;
class NAZARA_API NzContext : public NzResource
{
friend NzContextImpl;
public:
NzContext();
~NzContext();
bool Create(const NzContextParameters& parameters = NzContextParameters());
void Destroy();
const NzContextParameters& GetParameters() const;
bool IsActive() const;
bool SetActive(bool active);
void SwapBuffers();
static bool EnsureContext();
static NzContext* GetCurrent();
static const NzContext* GetReference();
static NzContext* GetThreadContext();
static bool Initialize();
static void Uninitialize();
private:
NzContextParameters m_parameters;
NzContextImpl* m_impl;
static NzContext* s_reference;
};
#endif // NAZARA_RENDERER_OPENGL
#endif // NAZARA_CONTEXT_HPP

View File

@@ -1,141 +1,174 @@
// Copyright (C) 2012 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_ENUMS_RENDERER_HPP
#define NAZARA_ENUMS_RENDERER_HPP
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 nzMatrixType
{
nzMatrixType_Projection,
nzMatrixType_View,
nzMatrixType_World,
nzMatrixType_Max = nzMatrixType_World
};
enum nzPixelBufferType
{
nzPixelBufferType_Pack,
nzPixelBufferType_Unpack
};
enum nzRendererCap
{
nzRendererCap_AnisotropicFilter,
nzRendererCap_FP64,
nzRendererCap_HardwareBuffer,
nzRendererCap_MultipleRenderTargets,
nzRendererCap_OcclusionQuery,
nzRendererCap_PixelBufferObject,
nzRendererCap_Texture3D,
nzRendererCap_TextureCubemap,
nzRendererCap_TextureMulti,
nzRendererCap_TextureNPOT,
nzRendererCap_Max = nzRendererCap_TextureNPOT
};
enum nzRendererClear
{
nzRendererClear_Color = 0x01,
nzRendererClear_Depth = 0x02,
nzRendererClear_Stencil = 0x04
};
enum nzRendererComparison
{
nzRendererComparison_Always,
nzRendererComparison_Equal,
nzRendererComparison_Greater,
nzRendererComparison_GreaterOrEqual,
nzRendererComparison_Less,
nzRendererComparison_LessOrEqual,
nzRendererComparison_Never
};
enum nzRendererParameter
{
nzRendererParameter_Blend,
nzRendererParameter_ColorWrite,
nzRendererParameter_DepthTest,
nzRendererParameter_DepthWrite,
nzRendererParameter_FaceCulling,
nzRendererParameter_Stencil
};
enum nzShaderLanguage
{
nzShaderLanguage_Unknown,
nzShaderLanguage_Cg,
nzShaderLanguage_GLSL
};
enum nzShaderType
{
nzShaderType_Fragment,
nzShaderType_Geometry,
nzShaderType_Vertex,
nzShaderType_Max = nzShaderType_Vertex
};
enum nzStencilOperation
{
nzStencilOperation_Decrement,
nzStencilOperation_DecrementToSaturation,
nzStencilOperation_Increment,
nzStencilOperation_IncrementToSaturation,
nzStencilOperation_Invert,
nzStencilOperation_Keep,
nzStencilOperation_Replace,
nzStencilOperation_Zero
};
enum nzTextureFilter
{
nzTextureFilter_Bilinear,
nzTextureFilter_Nearest,
nzTextureFilter_Trilinear,
nzTextureFilter_Unknown
};
enum nzTextureWrap
{
nzTextureWrap_Clamp,
nzTextureWrap_Repeat,
nzTextureWrap_Unknown
};
#endif // NAZARA_ENUMS_RENDERER_HPP
// Copyright (C) 2012 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_ENUMS_RENDERER_HPP
#define NAZARA_ENUMS_RENDERER_HPP
enum nzAttachmentPoint
{
nzAttachmentPoint_Color,
nzAttachmentPoint_Depth,
nzAttachmentPoint_DepthStencil,
nzAttachmentPoint_Stencil,
nzAttachmentPoint_Max = nzAttachmentPoint_Stencil
};
enum nzBlendFunc
{
nzBlendFunc_DestAlpha,
nzBlendFunc_DestColor,
nzBlendFunc_SrcAlpha,
nzBlendFunc_SrcColor,
nzBlendFunc_InvDestAlpha,
nzBlendFunc_InvDestColor,
nzBlendFunc_InvSrcAlpha,
nzBlendFunc_InvSrcColor,
nzBlendFunc_One,
nzBlendFunc_Zero,
nzBlendFunc_Max = nzBlendFunc_Zero
};
enum nzFaceCulling
{
nzFaceCulling_Back,
nzFaceCulling_Front,
nzFaceCulling_FrontAndBack,
nzFaceCulling_Max = nzFaceCulling_FrontAndBack
};
enum nzFaceFilling
{
nzFaceFilling_Point,
nzFaceFilling_Line,
nzFaceFilling_Fill,
nzFaceFilling_Max = nzFaceFilling_Fill
};
enum nzMatrixType
{
nzMatrixType_Projection,
nzMatrixType_View,
nzMatrixType_World,
nzMatrixType_Max = nzMatrixType_World
};
enum nzPixelBufferType
{
nzPixelBufferType_Pack,
nzPixelBufferType_Unpack,
nzPixelBufferType_Max = nzPixelBufferType_Unpack
};
enum nzRendererCap
{
nzRendererCap_AnisotropicFilter,
nzRendererCap_FP64,
nzRendererCap_HardwareBuffer,
nzRendererCap_MultipleRenderTargets,
nzRendererCap_OcclusionQuery,
nzRendererCap_PixelBufferObject,
nzRendererCap_RenderTexture,
nzRendererCap_Texture3D,
nzRendererCap_TextureCubemap,
nzRendererCap_TextureMulti,
nzRendererCap_TextureNPOT,
nzRendererCap_Max = nzRendererCap_TextureNPOT
};
enum nzRendererClearFlags
{
nzRendererClear_Color = 0x01,
nzRendererClear_Depth = 0x02,
nzRendererClear_Stencil = 0x04
};
enum nzRendererComparison
{
nzRendererComparison_Always,
nzRendererComparison_Equal,
nzRendererComparison_Greater,
nzRendererComparison_GreaterOrEqual,
nzRendererComparison_Less,
nzRendererComparison_LessOrEqual,
nzRendererComparison_Never,
nzRendererComparison_Max = nzRendererComparison_Never
};
enum nzRendererParameter
{
nzRendererParameter_Blend,
nzRendererParameter_ColorWrite,
nzRendererParameter_DepthTest,
nzRendererParameter_DepthWrite,
nzRendererParameter_FaceCulling,
nzRendererParameter_Stencil,
nzRendererParameter_Max = nzRendererParameter_Stencil
};
enum nzShaderLanguage
{
nzShaderLanguage_Unknown = -1,
nzShaderLanguage_Cg,
nzShaderLanguage_GLSL,
nzShaderLanguage_Max = nzShaderLanguage_GLSL
};
enum nzShaderType
{
nzShaderType_Fragment,
nzShaderType_Geometry,
nzShaderType_Vertex,
nzShaderType_Max = nzShaderType_Vertex
};
enum nzStencilOperation
{
nzStencilOperation_Decrement,
nzStencilOperation_DecrementToSaturation,
nzStencilOperation_Increment,
nzStencilOperation_IncrementToSaturation,
nzStencilOperation_Invert,
nzStencilOperation_Keep,
nzStencilOperation_Replace,
nzStencilOperation_Zero,
nzStencilOperation_Max = nzStencilOperation_Zero
};
enum nzTextureFilter
{
nzTextureFilter_Unknown = -1,
nzTextureFilter_Bilinear,
nzTextureFilter_Nearest,
nzTextureFilter_Trilinear,
nzTextureFilter_Max = nzTextureFilter_Trilinear
};
enum nzTextureWrap
{
nzTextureWrap_Unknown = -1,
nzTextureWrap_Clamp,
nzTextureWrap_Repeat,
nzTextureWrap_Max = nzTextureWrap_Repeat
};
#endif // NAZARA_ENUMS_RENDERER_HPP

View File

@@ -1,192 +1,233 @@
// Copyright (C) 2012 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#ifdef NAZARA_RENDERER_COMMON
#error This file is not part of the common renderer interface, you must undefine NAZARA_RENDERER_COMMON to use it
#endif
#pragma once
#ifndef NAZARA_OPENGL_HPP
#define NAZARA_OPENGL_HPP
// gl3.h définit WIN32_LEAN_AND_MEAN qui entre en conflit avec la définition de Nazara et doit donc être inclut en premier
#include <GL3/glcorearb.h>
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/String.hpp>
// Inclusion des extensions
#include <GL3/glext.h>
#if defined(NAZARA_PLATFORM_WINDOWS)
#include <GL3/wglext.h>
#elif defined(NAZARA_PLATFORM_LINUX)
#include <GL3/glxext.h>
#endif
using NzOpenGLFunc = void (*)();
class NAZARA_API NzOpenGL
{
public:
enum Extension
{
AnisotropicFilter,
DebugOutput,
FP64,
FrameBufferObject,
PixelBufferObject,
SeparateShaderObjects,
Texture3D,
TextureArray,
TextureCompression_s3tc,
TextureStorage,
VertexArrayObject,
Max = VertexArrayObject
};
static NzOpenGLFunc GetEntry(const NzString& entryPoint);
static unsigned int GetVersion();
static bool Initialize();
static bool IsSupported(Extension extension);
static bool IsSupported(const NzString& string);
static void Uninitialize();
};
NAZARA_API extern PFNGLACTIVETEXTUREPROC glActiveTexture;
NAZARA_API extern PFNGLATTACHSHADERPROC glAttachShader;
NAZARA_API extern PFNGLBEGINQUERYPROC glBeginQuery;
NAZARA_API extern PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation;
NAZARA_API extern PFNGLBINDBUFFERPROC glBindBuffer;
NAZARA_API extern PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer;
NAZARA_API extern PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer;
NAZARA_API extern PFNGLBINDTEXTUREPROC glBindTexture;
NAZARA_API extern PFNGLBINDVERTEXARRAYPROC glBindVertexArray;
NAZARA_API extern PFNGLBLENDFUNCPROC glBlendFunc;
NAZARA_API extern PFNGLBUFFERDATAPROC glBufferData;
NAZARA_API extern PFNGLBUFFERSUBDATAPROC glBufferSubData;
NAZARA_API extern PFNGLCLEARPROC glClear;
NAZARA_API extern PFNGLCLEARCOLORPROC glClearColor;
NAZARA_API extern PFNGLCLEARDEPTHPROC glClearDepth;
NAZARA_API extern PFNGLCLEARSTENCILPROC glClearStencil;
NAZARA_API extern PFNGLCREATEPROGRAMPROC glCreateProgram;
NAZARA_API extern PFNGLCREATESHADERPROC glCreateShader;
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 PFNGLDEBUGMESSAGECALLBACKPROC glDebugMessageCallback;
NAZARA_API extern PFNGLDEBUGMESSAGECONTROLPROC glDebugMessageControl;
NAZARA_API extern PFNGLDEBUGMESSAGEINSERTPROC glDebugMessageInsert;
NAZARA_API extern PFNGLDELETEBUFFERSPROC glDeleteBuffers;
NAZARA_API extern PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers;
NAZARA_API extern PFNGLDELETEPROGRAMPROC glDeleteProgram;
NAZARA_API extern PFNGLDELETEQUERIESPROC glDeleteQueries;
NAZARA_API extern PFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers;
NAZARA_API extern PFNGLDELETESHADERPROC glDeleteShader;
NAZARA_API extern PFNGLDELETETEXTURESPROC glDeleteTextures;
NAZARA_API extern PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays;
NAZARA_API extern PFNGLDEPTHFUNCPROC glDepthFunc;
NAZARA_API extern PFNGLDEPTHMASKPROC glDepthMask;
NAZARA_API extern PFNGLDISABLEPROC glDisable;
NAZARA_API extern PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray;
NAZARA_API extern PFNGLDRAWARRAYSPROC glDrawArrays;
NAZARA_API extern PFNGLDRAWBUFFERPROC glDrawBuffer;
NAZARA_API extern PFNGLDRAWBUFFERSPROC glDrawBuffers;
NAZARA_API extern PFNGLDRAWELEMENTSPROC glDrawElements;
NAZARA_API extern PFNGLENDQUERYPROC glEndQuery;
NAZARA_API extern PFNGLFLUSHPROC glFlush;
NAZARA_API extern PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer;
NAZARA_API extern PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D;
NAZARA_API extern PFNGLENABLEPROC glEnable;
NAZARA_API extern PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray;
NAZARA_API extern PFNGLGENERATEMIPMAPPROC glGenerateMipmap;
NAZARA_API extern PFNGLGENBUFFERSPROC glGenBuffers;
NAZARA_API extern PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers;
NAZARA_API extern PFNGLGENQUERIESPROC glGenQueries;
NAZARA_API extern PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers;
NAZARA_API extern PFNGLGENTEXTURESPROC glGenTextures;
NAZARA_API extern PFNGLGENVERTEXARRAYSPROC glGenVertexArrays;
NAZARA_API extern PFNGLGETBUFFERPARAMETERIVPROC glGetBufferParameteriv;
NAZARA_API extern PFNGLGETDEBUGMESSAGELOGPROC glGetDebugMessageLog;
NAZARA_API extern PFNGLGETERRORPROC glGetError;
NAZARA_API extern PFNGLGETINTEGERVPROC glGetIntegerv;
NAZARA_API extern PFNGLGETPROGRAMIVPROC glGetProgramiv;
NAZARA_API extern PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog;
NAZARA_API extern PFNGLGETQUERYIVPROC glGetQueryiv;
NAZARA_API extern PFNGLGETQUERYOBJECTIVPROC glGetQueryObjectiv;
NAZARA_API extern PFNGLGETQUERYOBJECTUIVPROC glGetQueryObjectuiv;
NAZARA_API extern PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog;
NAZARA_API extern PFNGLGETSHADERIVPROC glGetShaderiv;
NAZARA_API extern PFNGLGETSHADERSOURCEPROC glGetShaderSource;
NAZARA_API extern PFNGLGETSTRINGPROC glGetString;
NAZARA_API extern PFNGLGETSTRINGIPROC glGetStringi;
NAZARA_API extern PFNGLGETTEXIMAGEPROC glGetTexImage;
NAZARA_API extern PFNGLGETTEXLEVELPARAMETERFVPROC glGetTexLevelParameterfv;
NAZARA_API extern PFNGLGETTEXLEVELPARAMETERIVPROC glGetTexLevelParameteriv;
NAZARA_API extern PFNGLGETTEXPARAMETERFVPROC glGetTexParameterfv;
NAZARA_API extern PFNGLGETTEXPARAMETERIVPROC glGetTexParameteriv;
NAZARA_API extern PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation;
NAZARA_API extern PFNGLLINKPROGRAMPROC glLinkProgram;
NAZARA_API extern PFNGLMAPBUFFERPROC glMapBuffer;
NAZARA_API extern PFNGLMAPBUFFERRANGEPROC glMapBufferRange;
NAZARA_API extern PFNGLPIXELSTOREIPROC glPixelStorei;
NAZARA_API extern PFNGLPOLYGONMODEPROC glPolygonMode;
NAZARA_API extern PFNGLPROGRAMUNIFORM1DPROC glProgramUniform1d;
NAZARA_API extern PFNGLPROGRAMUNIFORM1FPROC glProgramUniform1f;
NAZARA_API extern PFNGLPROGRAMUNIFORM1IPROC glProgramUniform1i;
NAZARA_API extern PFNGLPROGRAMUNIFORM2DVPROC glProgramUniform2dv;
NAZARA_API extern PFNGLPROGRAMUNIFORM2FVPROC glProgramUniform2fv;
NAZARA_API extern PFNGLPROGRAMUNIFORM3DVPROC glProgramUniform3dv;
NAZARA_API extern PFNGLPROGRAMUNIFORM3FVPROC glProgramUniform3fv;
NAZARA_API extern PFNGLPROGRAMUNIFORM4DVPROC glProgramUniform4dv;
NAZARA_API extern PFNGLPROGRAMUNIFORM4FVPROC glProgramUniform4fv;
NAZARA_API extern PFNGLPROGRAMUNIFORMMATRIX4DVPROC glProgramUniformMatrix4dv;
NAZARA_API extern PFNGLPROGRAMUNIFORMMATRIX4FVPROC glProgramUniformMatrix4fv;
NAZARA_API extern PFNGLREADPIXELSPROC glReadPixels;
NAZARA_API extern PFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage;
NAZARA_API extern PFNGLSCISSORPROC glScissor;
NAZARA_API extern PFNGLSHADERSOURCEPROC glShaderSource;
NAZARA_API extern PFNGLSTENCILFUNCPROC glStencilFunc;
NAZARA_API extern PFNGLSTENCILOPPROC glStencilOp;
NAZARA_API extern PFNGLTEXIMAGE1DPROC glTexImage1D;
NAZARA_API extern PFNGLTEXIMAGE2DPROC glTexImage2D;
NAZARA_API extern PFNGLTEXIMAGE3DPROC glTexImage3D;
NAZARA_API extern PFNGLTEXPARAMETERFPROC glTexParameterf;
NAZARA_API extern PFNGLTEXPARAMETERIPROC glTexParameteri;
NAZARA_API extern PFNGLTEXSTORAGE1DPROC glTexStorage1D;
NAZARA_API extern PFNGLTEXSTORAGE2DPROC glTexStorage2D;
NAZARA_API extern PFNGLTEXSTORAGE3DPROC glTexStorage3D;
NAZARA_API extern PFNGLTEXSUBIMAGE1DPROC glTexSubImage1D;
NAZARA_API extern PFNGLTEXSUBIMAGE2DPROC glTexSubImage2D;
NAZARA_API extern PFNGLTEXSUBIMAGE3DPROC glTexSubImage3D;
NAZARA_API extern PFNGLUNIFORM1DPROC glUniform1d;
NAZARA_API extern PFNGLUNIFORM1FPROC glUniform1f;
NAZARA_API extern PFNGLUNIFORM1IPROC glUniform1i;
NAZARA_API extern PFNGLUNIFORM2DVPROC glUniform2dv;
NAZARA_API extern PFNGLUNIFORM2FVPROC glUniform2fv;
NAZARA_API extern PFNGLUNIFORM3DVPROC glUniform3dv;
NAZARA_API extern PFNGLUNIFORM3FVPROC glUniform3fv;
NAZARA_API extern PFNGLUNIFORM4DVPROC glUniform4dv;
NAZARA_API extern PFNGLUNIFORM4FVPROC glUniform4fv;
NAZARA_API extern PFNGLUNIFORMMATRIX4DVPROC glUniformMatrix4dv;
NAZARA_API extern PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv;
NAZARA_API extern PFNGLUNMAPBUFFERPROC glUnmapBuffer;
NAZARA_API extern PFNGLUSEPROGRAMPROC glUseProgram;
NAZARA_API extern PFNGLVERTEXATTRIB4FPROC glVertexAttrib4f;
NAZARA_API extern PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer;
NAZARA_API extern PFNGLVIEWPORTPROC glViewport;
#if defined(NAZARA_PLATFORM_WINDOWS)
NAZARA_API extern PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormat;
NAZARA_API extern PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribs;
NAZARA_API extern PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB;
NAZARA_API extern PFNWGLGETEXTENSIONSSTRINGEXTPROC wglGetExtensionsStringEXT;
NAZARA_API extern PFNWGLSWAPINTERVALEXTPROC wglSwapInterval;
#elif defined(NAZARA_PLATFORM_LINUX)
NAZARA_API extern PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribs;
NAZARA_API extern PFNGLXSWAPINTERVALSGIPROC glXSwapInterval;
#endif
#endif // NAZARA_OPENGL_HPP
// Copyright (C) 2012 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_OPENGL_HPP
#define NAZARA_OPENGL_HPP
#ifdef NAZARA_RENDERER_OPENGL
// gl3.h définit WIN32_LEAN_AND_MEAN qui entre en conflit avec la définition de Nazara et doit donc être inclut en premier
#include <GL3/glcorearb.h>
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/String.hpp>
#include <Nazara/Utility/Enums.hpp>
#include <Nazara/Renderer/Enums.hpp>
// Inclusion des extensions
#include <GL3/glext.h>
#if defined(NAZARA_PLATFORM_WINDOWS)
#include <GL3/wglext.h>
#elif defined(NAZARA_PLATFORM_LINUX)
#include <GL3/glxext.h>
#endif
enum nzOpenGLExtension
{
nzOpenGLExtension_AnisotropicFilter,
nzOpenGLExtension_DebugOutput,
nzOpenGLExtension_FP64,
nzOpenGLExtension_FrameBufferObject,
nzOpenGLExtension_PixelBufferObject,
nzOpenGLExtension_SeparateShaderObjects,
nzOpenGLExtension_TextureArray,
nzOpenGLExtension_TextureCompression_s3tc,
nzOpenGLExtension_TextureStorage,
nzOpenGLExtension_VertexArrayObject,
nzOpenGLExtension_Max = nzOpenGLExtension_VertexArrayObject
};
using NzOpenGLFunc = void (*)();
namespace NzOpenGL
{
enum FormatType
{
FormatType_RenderBuffer,
// FormatType_MultisampleTexture,
FormatType_Texture
};
struct Format
{
GLenum dataFormat;
GLenum dataType;
GLint internalFormat;
};
NzOpenGLFunc GetEntry(const NzString& entryPoint);
unsigned int GetVersion();
bool Initialize();
bool IsSupported(nzOpenGLExtension extension);
bool IsSupported(const NzString& string);
bool TranslateFormat(nzPixelFormat pixelFormat, Format* format, FormatType target);
void Uninitialize();
extern GLenum Attachment[nzAttachmentPoint_Max+1];
extern nzUInt8 AttributeIndex[nzElementUsage_Max+1];
extern GLenum BlendFunc[nzBlendFunc_Max+1];
extern GLenum BufferLock[nzBufferAccess_Max+1];
extern GLenum BufferLockRange[nzBufferAccess_Max+1];
extern GLenum BufferTarget[nzBufferType_Max+1];
extern GLenum BufferTargetBinding[nzBufferType_Max+1];
extern GLenum BufferUsage[nzBufferUsage_Max+1];
extern GLenum CubemapFace[6]; // Un cube possède six faces et ça n'est pas prêt de changer
extern GLenum ElementType[nzElementType_Max+1];
extern GLenum FaceCulling[nzFaceCulling_Max+1];
extern GLenum FaceFilling[nzFaceFilling_Max+1];
extern GLenum PrimitiveType[nzPrimitiveType_Max+1];
extern GLenum RendererComparison[nzRendererComparison_Max+1];
extern GLenum RendererParameter[nzRendererParameter_Max+1];
extern GLenum ShaderType[nzShaderType_Max+1];
extern GLenum StencilOperation[nzStencilOperation_Max+1];
extern GLenum TextureTarget[nzImageType_Max+1];
extern GLenum TextureTargetBinding[nzImageType_Max+1];
extern GLenum TextureTargetProxy[nzImageType_Max+1];
}
NAZARA_API extern PFNGLACTIVETEXTUREPROC glActiveTexture;
NAZARA_API extern PFNGLATTACHSHADERPROC glAttachShader;
NAZARA_API extern PFNGLBEGINQUERYPROC glBeginQuery;
NAZARA_API extern PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation;
NAZARA_API extern PFNGLBINDBUFFERPROC glBindBuffer;
NAZARA_API extern PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer;
NAZARA_API extern PFNGLBINDFRAGDATALOCATIONPROC glBindFragDataLocation;
NAZARA_API extern PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer;
NAZARA_API extern PFNGLBINDTEXTUREPROC glBindTexture;
NAZARA_API extern PFNGLBINDVERTEXARRAYPROC glBindVertexArray;
NAZARA_API extern PFNGLBLENDFUNCPROC glBlendFunc;
NAZARA_API extern PFNGLBUFFERDATAPROC glBufferData;
NAZARA_API extern PFNGLBUFFERSUBDATAPROC glBufferSubData;
NAZARA_API extern PFNGLCLEARPROC glClear;
NAZARA_API extern PFNGLCLEARCOLORPROC glClearColor;
NAZARA_API extern PFNGLCLEARDEPTHPROC glClearDepth;
NAZARA_API extern PFNGLCLEARSTENCILPROC glClearStencil;
NAZARA_API extern PFNGLCREATEPROGRAMPROC glCreateProgram;
NAZARA_API extern PFNGLCREATESHADERPROC glCreateShader;
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 PFNGLDEBUGMESSAGECALLBACKPROC glDebugMessageCallback;
NAZARA_API extern PFNGLDEBUGMESSAGECONTROLPROC glDebugMessageControl;
NAZARA_API extern PFNGLDEBUGMESSAGEINSERTPROC glDebugMessageInsert;
NAZARA_API extern PFNGLDELETEBUFFERSPROC glDeleteBuffers;
NAZARA_API extern PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers;
NAZARA_API extern PFNGLDELETEPROGRAMPROC glDeleteProgram;
NAZARA_API extern PFNGLDELETEQUERIESPROC glDeleteQueries;
NAZARA_API extern PFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers;
NAZARA_API extern PFNGLDELETESHADERPROC glDeleteShader;
NAZARA_API extern PFNGLDELETETEXTURESPROC glDeleteTextures;
NAZARA_API extern PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays;
NAZARA_API extern PFNGLDEPTHFUNCPROC glDepthFunc;
NAZARA_API extern PFNGLDEPTHMASKPROC glDepthMask;
NAZARA_API extern PFNGLDISABLEPROC glDisable;
NAZARA_API extern PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray;
NAZARA_API extern PFNGLDRAWARRAYSPROC glDrawArrays;
NAZARA_API extern PFNGLDRAWBUFFERPROC glDrawBuffer;
NAZARA_API extern PFNGLDRAWBUFFERSPROC glDrawBuffers;
NAZARA_API extern PFNGLDRAWELEMENTSPROC glDrawElements;
NAZARA_API extern PFNGLENDQUERYPROC glEndQuery;
NAZARA_API extern PFNGLFLUSHPROC glFlush;
NAZARA_API extern PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer;
NAZARA_API extern PFNGLFRAMEBUFFERTEXTUREPROC glFramebufferTexture;
NAZARA_API extern PFNGLFRAMEBUFFERTEXTURE1DPROC glFramebufferTexture1D;
NAZARA_API extern PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D;
NAZARA_API extern PFNGLFRAMEBUFFERTEXTURE3DPROC glFramebufferTexture3D;
NAZARA_API extern PFNGLFRAMEBUFFERTEXTURELAYERPROC glFramebufferTextureLayer;
NAZARA_API extern PFNGLENABLEPROC glEnable;
NAZARA_API extern PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray;
NAZARA_API extern PFNGLGENERATEMIPMAPPROC glGenerateMipmap;
NAZARA_API extern PFNGLGENBUFFERSPROC glGenBuffers;
NAZARA_API extern PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers;
NAZARA_API extern PFNGLGENQUERIESPROC glGenQueries;
NAZARA_API extern PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers;
NAZARA_API extern PFNGLGENTEXTURESPROC glGenTextures;
NAZARA_API extern PFNGLGENVERTEXARRAYSPROC glGenVertexArrays;
NAZARA_API extern PFNGLGETBUFFERPARAMETERIVPROC glGetBufferParameteriv;
NAZARA_API extern PFNGLGETDEBUGMESSAGELOGPROC glGetDebugMessageLog;
NAZARA_API extern PFNGLGETERRORPROC glGetError;
NAZARA_API extern PFNGLGETINTEGERVPROC glGetIntegerv;
NAZARA_API extern PFNGLGETPROGRAMIVPROC glGetProgramiv;
NAZARA_API extern PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog;
NAZARA_API extern PFNGLGETQUERYIVPROC glGetQueryiv;
NAZARA_API extern PFNGLGETQUERYOBJECTIVPROC glGetQueryObjectiv;
NAZARA_API extern PFNGLGETQUERYOBJECTUIVPROC glGetQueryObjectuiv;
NAZARA_API extern PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog;
NAZARA_API extern PFNGLGETSHADERIVPROC glGetShaderiv;
NAZARA_API extern PFNGLGETSHADERSOURCEPROC glGetShaderSource;
NAZARA_API extern PFNGLGETSTRINGPROC glGetString;
NAZARA_API extern PFNGLGETSTRINGIPROC glGetStringi;
NAZARA_API extern PFNGLGETTEXIMAGEPROC glGetTexImage;
NAZARA_API extern PFNGLGETTEXLEVELPARAMETERFVPROC glGetTexLevelParameterfv;
NAZARA_API extern PFNGLGETTEXLEVELPARAMETERIVPROC glGetTexLevelParameteriv;
NAZARA_API extern PFNGLGETTEXPARAMETERFVPROC glGetTexParameterfv;
NAZARA_API extern PFNGLGETTEXPARAMETERIVPROC glGetTexParameteriv;
NAZARA_API extern PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation;
NAZARA_API extern PFNGLLINKPROGRAMPROC glLinkProgram;
NAZARA_API extern PFNGLMAPBUFFERPROC glMapBuffer;
NAZARA_API extern PFNGLMAPBUFFERRANGEPROC glMapBufferRange;
NAZARA_API extern PFNGLPIXELSTOREIPROC glPixelStorei;
NAZARA_API extern PFNGLPOLYGONMODEPROC glPolygonMode;
NAZARA_API extern PFNGLPROGRAMUNIFORM1DPROC glProgramUniform1d;
NAZARA_API extern PFNGLPROGRAMUNIFORM1FPROC glProgramUniform1f;
NAZARA_API extern PFNGLPROGRAMUNIFORM1IPROC glProgramUniform1i;
NAZARA_API extern PFNGLPROGRAMUNIFORM2DVPROC glProgramUniform2dv;
NAZARA_API extern PFNGLPROGRAMUNIFORM2FVPROC glProgramUniform2fv;
NAZARA_API extern PFNGLPROGRAMUNIFORM3DVPROC glProgramUniform3dv;
NAZARA_API extern PFNGLPROGRAMUNIFORM3FVPROC glProgramUniform3fv;
NAZARA_API extern PFNGLPROGRAMUNIFORM4DVPROC glProgramUniform4dv;
NAZARA_API extern PFNGLPROGRAMUNIFORM4FVPROC glProgramUniform4fv;
NAZARA_API extern PFNGLPROGRAMUNIFORMMATRIX4DVPROC glProgramUniformMatrix4dv;
NAZARA_API extern PFNGLPROGRAMUNIFORMMATRIX4FVPROC glProgramUniformMatrix4fv;
NAZARA_API extern PFNGLREADPIXELSPROC glReadPixels;
NAZARA_API extern PFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage;
NAZARA_API extern PFNGLSCISSORPROC glScissor;
NAZARA_API extern PFNGLSHADERSOURCEPROC glShaderSource;
NAZARA_API extern PFNGLSTENCILFUNCPROC glStencilFunc;
NAZARA_API extern PFNGLSTENCILOPPROC glStencilOp;
NAZARA_API extern PFNGLTEXIMAGE1DPROC glTexImage1D;
NAZARA_API extern PFNGLTEXIMAGE2DPROC glTexImage2D;
NAZARA_API extern PFNGLTEXIMAGE3DPROC glTexImage3D;
NAZARA_API extern PFNGLTEXPARAMETERFPROC glTexParameterf;
NAZARA_API extern PFNGLTEXPARAMETERIPROC glTexParameteri;
NAZARA_API extern PFNGLTEXSTORAGE1DPROC glTexStorage1D;
NAZARA_API extern PFNGLTEXSTORAGE2DPROC glTexStorage2D;
NAZARA_API extern PFNGLTEXSTORAGE3DPROC glTexStorage3D;
NAZARA_API extern PFNGLTEXSUBIMAGE1DPROC glTexSubImage1D;
NAZARA_API extern PFNGLTEXSUBIMAGE2DPROC glTexSubImage2D;
NAZARA_API extern PFNGLTEXSUBIMAGE3DPROC glTexSubImage3D;
NAZARA_API extern PFNGLUNIFORM1DPROC glUniform1d;
NAZARA_API extern PFNGLUNIFORM1FPROC glUniform1f;
NAZARA_API extern PFNGLUNIFORM1IPROC glUniform1i;
NAZARA_API extern PFNGLUNIFORM2DVPROC glUniform2dv;
NAZARA_API extern PFNGLUNIFORM2FVPROC glUniform2fv;
NAZARA_API extern PFNGLUNIFORM3DVPROC glUniform3dv;
NAZARA_API extern PFNGLUNIFORM3FVPROC glUniform3fv;
NAZARA_API extern PFNGLUNIFORM4DVPROC glUniform4dv;
NAZARA_API extern PFNGLUNIFORM4FVPROC glUniform4fv;
NAZARA_API extern PFNGLUNIFORMMATRIX4DVPROC glUniformMatrix4dv;
NAZARA_API extern PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv;
NAZARA_API extern PFNGLUNMAPBUFFERPROC glUnmapBuffer;
NAZARA_API extern PFNGLUSEPROGRAMPROC glUseProgram;
NAZARA_API extern PFNGLVERTEXATTRIB4FPROC glVertexAttrib4f;
NAZARA_API extern PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer;
NAZARA_API extern PFNGLVIEWPORTPROC glViewport;
#if defined(NAZARA_PLATFORM_WINDOWS)
NAZARA_API extern PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormat;
NAZARA_API extern PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribs;
NAZARA_API extern PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB;
NAZARA_API extern PFNWGLGETEXTENSIONSSTRINGEXTPROC wglGetExtensionsStringEXT;
NAZARA_API extern PFNWGLSWAPINTERVALEXTPROC wglSwapInterval;
#elif defined(NAZARA_PLATFORM_LINUX)
NAZARA_API extern PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribs;
NAZARA_API extern PFNGLXSWAPINTERVALSGIPROC glXSwapInterval;
#endif
#endif // NAZARA_RENDERER_OPENGL
#endif // NAZARA_OPENGL_HPP

View File

@@ -1,42 +1,41 @@
// Copyright (C) 2012 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_RENDERTARGET_HPP
#define NAZARA_RENDERTARGET_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Renderer/Config.hpp>
#include <Nazara/Renderer/RenderTargetParameters.hpp>
class NzRenderer;
class NAZARA_API NzRenderTarget
{
friend class NzRenderer;
public:
NzRenderTarget() = default;
virtual ~NzRenderTarget();
#ifndef NAZARA_RENDERER_COMMON
virtual bool HasContext() const = 0;
#endif
virtual unsigned int GetHeight() const = 0;
virtual NzRenderTargetParameters GetParameters() const = 0;
virtual unsigned int GetWidth() const = 0;
bool IsActive() const;
virtual bool IsValid() const = 0;
bool SetActive(bool active);
protected:
virtual bool Activate() = 0;
virtual void Desactivate();
};
#endif // NAZARA_RENDERTARGET_HPP
// Copyright (C) 2012 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_RENDERTARGET_HPP
#define NAZARA_RENDERTARGET_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Renderer/Config.hpp>
#include <Nazara/Renderer/RenderTargetParameters.hpp>
class NzRenderer;
class NAZARA_API NzRenderTarget
{
friend class NzRenderer;
public:
NzRenderTarget() = default;
virtual ~NzRenderTarget();
virtual unsigned int GetHeight() const = 0;
virtual NzRenderTargetParameters GetParameters() const = 0;
virtual unsigned int GetWidth() const = 0;
bool IsActive() const;
virtual bool IsRenderable() const = 0;
bool SetActive(bool active);
// Fonctions OpenGL
virtual bool HasContext() const = 0;
protected:
virtual bool Activate() = 0;
virtual void Desactivate();
};
#endif // NAZARA_RENDERTARGET_HPP

View File

@@ -0,0 +1,60 @@
// Copyright (C) 2012 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_RENDERTEXTURE_HPP
#define NAZARA_RENDERTEXTURE_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/NonCopyable.hpp>
#include <Nazara/Core/ResourceListener.hpp>
#include <Nazara/Renderer/Config.hpp>
#include <Nazara/Renderer/RenderTarget.hpp>
#include <Nazara/Renderer/Texture.hpp>
struct NzRenderTextureImpl;
class NAZARA_API NzRenderTexture : public NzRenderTarget, NzResourceListener, NzNonCopyable
{
public:
NzRenderTexture() = default;
~NzRenderTexture();
bool AttachBuffer(nzAttachmentPoint attachmentPoint, nzUInt8 index, nzPixelFormat format);
bool AttachTexture(nzAttachmentPoint attachmentPoint, nzUInt8 index, NzTexture* texture);
bool AttachTexture(nzAttachmentPoint attachmentPoint, nzUInt8 index, NzTexture* texture, unsigned int z);
bool Create(unsigned int width, unsigned int height, bool lock = false);
void Destroy();
void Detach(nzAttachmentPoint attachmentPoint, nzUInt8 index);
unsigned int GetHeight() const;
NzRenderTargetParameters GetParameters() const;
unsigned int GetWidth() const;
bool IsComplete() const;
bool IsRenderable() const;
bool IsValid() const;
bool Lock() const;
void Unlock() const;
// Fonctions OpenGL
bool HasContext() const;
static bool IsSupported();
protected:
bool Activate() override;
void Desactivate() override;
private:
void OnResourceDestroy(const NzResource* resource, int index) override;
NzRenderTextureImpl* m_impl = nullptr;
};
#endif // NAZARA_RENDERTEXTURE_HPP

View File

@@ -1,71 +1,68 @@
// Copyright (C) 2012 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
// Interface inspirée de la SFML par Laurent Gomila
#pragma once
#ifndef NAZARA_RENDERWINDOW_HPP
#define NAZARA_RENDERWINDOW_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/Clock.hpp>
#include <Nazara/Renderer/Config.hpp>
#include <Nazara/Renderer/ContextParameters.hpp>
#include <Nazara/Renderer/RenderTarget.hpp>
#include <Nazara/Utility/Window.hpp>
class NzContext;
class NzImage;
class NzTexture;
struct NzContextParameters;
class NAZARA_API NzRenderWindow : public NzRenderTarget, public NzWindow
{
public:
NzRenderWindow() = default;
NzRenderWindow(NzVideoMode mode, const NzString& title, nzUInt32 style = nzWindowStyle_Default, const NzContextParameters& parameters = NzContextParameters());
NzRenderWindow(NzWindowHandle handle, const NzContextParameters& parameters = NzContextParameters());
virtual ~NzRenderWindow();
bool CopyToImage(NzImage* image); ///TODO: Const
bool CopyToTexture(NzTexture* texture); ///TODO: Const
bool Create(NzVideoMode mode, const NzString& title, nzUInt32 style = nzWindowStyle_Default, const NzContextParameters& parameters = NzContextParameters());
bool Create(NzWindowHandle handle, const NzContextParameters& parameters = NzContextParameters());
void Display();
void EnableVerticalSync(bool enabled);
#ifndef NAZARA_RENDERER_COMMON
NzContextParameters GetContextParameters() const;
#endif
unsigned int GetHeight() const;
NzRenderTargetParameters GetParameters() const;
unsigned int GetWidth() const;
#ifndef NAZARA_RENDERER_COMMON
bool HasContext() const;
#endif
bool IsValid() const;
void SetFramerateLimit(unsigned int limit);
protected:
virtual bool Activate() override;
private:
virtual void OnWindowDestroying() override;
virtual bool OnWindowCreated() override;
NzClock m_clock;
NzContextParameters m_parameters;
NzContext* m_context = nullptr;
unsigned int m_framerateLimit = 0;
};
#endif // NAZARA_RENDERWINDOW_HPP
// Copyright (C) 2012 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
// Interface inspirée de la SFML par Laurent Gomila
#pragma once
#ifndef NAZARA_RENDERWINDOW_HPP
#define NAZARA_RENDERWINDOW_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/Clock.hpp>
#include <Nazara/Renderer/Config.hpp>
#include <Nazara/Renderer/ContextParameters.hpp>
#include <Nazara/Renderer/RenderTarget.hpp>
#include <Nazara/Utility/Window.hpp>
class NzContext;
class NzImage;
class NzTexture;
struct NzContextParameters;
class NAZARA_API NzRenderWindow : public NzRenderTarget, public NzWindow
{
public:
NzRenderWindow() = default;
NzRenderWindow(NzVideoMode mode, const NzString& title, nzUInt32 style = nzWindowStyle_Default, const NzContextParameters& parameters = NzContextParameters());
NzRenderWindow(NzWindowHandle handle, const NzContextParameters& parameters = NzContextParameters());
virtual ~NzRenderWindow();
bool CopyToImage(NzImage* image); ///TODO: Const
bool CopyToTexture(NzTexture* texture); ///TODO: Const
bool Create(NzVideoMode mode, const NzString& title, nzUInt32 style = nzWindowStyle_Default, const NzContextParameters& parameters = NzContextParameters());
bool Create(NzWindowHandle handle, const NzContextParameters& parameters = NzContextParameters());
void Display();
void EnableVerticalSync(bool enabled);
unsigned int GetHeight() const;
NzRenderTargetParameters GetParameters() const;
unsigned int GetWidth() const;
bool IsRenderable() const;
bool IsValid() const;
void SetFramerateLimit(unsigned int limit);
// Fonctions OpenGL
NzContextParameters GetContextParameters() const;
bool HasContext() const;
protected:
bool Activate() override;
private:
bool OnWindowCreated() override;
void OnWindowDestroy() override;
NzClock m_clock;
NzContextParameters m_parameters;
NzContext* m_context = nullptr;
unsigned int m_framerateLimit = 0;
};
#endif // NAZARA_RENDERWINDOW_HPP

View File

@@ -1,89 +1,92 @@
// Copyright (C) 2012 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_TEXTURE_HPP
#define NAZARA_TEXTURE_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/NonCopyable.hpp>
#include <Nazara/Renderer/Enums.hpp>
#include <Nazara/Utility/Image.hpp>
#include <Nazara/Utility/PixelFormat.hpp>
struct NzTextureImpl;
class NAZARA_API NzTexture : public NzResource, NzNonCopyable
{
friend class NzShader;
public:
NzTexture();
explicit NzTexture(const NzImage& image);
~NzTexture();
#ifndef NAZARA_RENDERER_COMMON
bool Bind() const;
#endif
bool Create(nzImageType type, nzPixelFormat format, unsigned int width, unsigned int height, unsigned int depth = 1, nzUInt8 levelCount = 1, bool lock = false);
void Destroy();
bool Download(NzImage* image) const;
bool EnableMipmapping(bool enable);
unsigned int GetAnisotropyLevel() const;
nzUInt8 GetBPP() const;
unsigned int GetDepth() const;
nzTextureFilter GetFilterMode() const;
nzPixelFormat GetFormat() const;
unsigned int GetHeight() const;
nzImageType GetType() const;
unsigned int GetWidth() const;
nzTextureWrap GetWrapMode() const;
bool IsCompressed() const;
bool IsCubemap() const;
bool IsTarget() const;
bool IsValid() const;
bool LoadFromFile(const NzString& filePath, const NzImageParams& params = NzImageParams());
bool LoadFromImage(const NzImage& image);
bool LoadFromMemory(const void* data, std::size_t size, const NzImageParams& params = NzImageParams());
bool LoadFromStream(NzInputStream& stream, const NzImageParams& params = NzImageParams());
bool Lock();
bool SetAnisotropyLevel(unsigned int anistropyLevel);
bool SetFilterMode(nzTextureFilter filter);
bool SetMipmapRange(nzUInt8 minLevel, nzUInt8 maxLevel);
bool SetWrapMode(nzTextureWrap wrap);
bool Update(const NzImage& image, nzUInt8 level = 0);
bool Update(const NzImage& image, const NzRectui& rect, unsigned int z = 0, nzUInt8 level = 0);
bool Update(const NzImage& image, const NzCubeui& cube, nzUInt8 level = 0);
bool Update(const nzUInt8* pixels, nzUInt8 level = 0);
bool Update(const nzUInt8* pixels, const NzRectui& rect, unsigned int z = 0, nzUInt8 level = 0);
bool Update(const nzUInt8* pixels, const NzCubeui& cube, nzUInt8 level = 0);
bool UpdateFace(nzCubemapFace face, const NzImage& image, nzUInt8 level = 0);
bool UpdateFace(nzCubemapFace face, const NzImage& image, const NzRectui& rect, nzUInt8 level = 0);
bool UpdateFace(nzCubemapFace face, const nzUInt8* pixels, nzUInt8 level = 0);
bool UpdateFace(nzCubemapFace face, const nzUInt8* pixels, const NzRectui& rect, nzUInt8 level = 0);
void Unlock();
static unsigned int GetValidSize(unsigned int size);
static bool IsFormatSupported(nzPixelFormat format);
static bool IsMipmappingSupported();
static bool IsTypeSupported(nzImageType type);
private:
void SetTarget(bool isTarget);
NzTextureImpl* m_impl;
};
#endif // NAZARA_TEXTURE_HPP
// Copyright (C) 2012 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_TEXTURE_HPP
#define NAZARA_TEXTURE_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/NonCopyable.hpp>
#include <Nazara/Renderer/Enums.hpp>
#include <Nazara/Utility/Image.hpp>
#include <Nazara/Utility/PixelFormat.hpp>
class NzRenderTexture;
struct NzTextureImpl;
class NAZARA_API NzTexture : public NzResource, NzNonCopyable
{
friend NzRenderTexture;
friend class NzShader;
public:
NzTexture();
explicit NzTexture(const NzImage& image);
~NzTexture();
bool Create(nzImageType type, nzPixelFormat format, unsigned int width, unsigned int height, unsigned int depth = 1, nzUInt8 levelCount = 1, bool lock = false);
void Destroy();
bool Download(NzImage* image) const;
bool EnableMipmapping(bool enable);
unsigned int GetAnisotropyLevel() const;
nzUInt8 GetBPP() const;
unsigned int GetDepth() const;
nzTextureFilter GetFilterMode() const;
nzPixelFormat GetFormat() const;
unsigned int GetHeight() const;
nzImageType GetType() const;
unsigned int GetWidth() const;
nzTextureWrap GetWrapMode() const;
bool IsCompressed() const;
bool IsCubemap() const;
bool IsTarget() const;
bool IsValid() const;
bool LoadFromFile(const NzString& filePath, const NzImageParams& params = NzImageParams());
bool LoadFromImage(const NzImage& image);
bool LoadFromMemory(const void* data, std::size_t size, const NzImageParams& params = NzImageParams());
bool LoadFromStream(NzInputStream& stream, const NzImageParams& params = NzImageParams());
bool Lock();
bool SetAnisotropyLevel(unsigned int anistropyLevel);
bool SetFilterMode(nzTextureFilter filter);
bool SetMipmapRange(nzUInt8 minLevel, nzUInt8 maxLevel);
bool SetWrapMode(nzTextureWrap wrap);
bool Update(const NzImage& image, nzUInt8 level = 0);
bool Update(const NzImage& image, const NzRectui& rect, unsigned int z = 0, nzUInt8 level = 0);
bool Update(const NzImage& image, const NzCubeui& cube, nzUInt8 level = 0);
bool Update(const nzUInt8* pixels, nzUInt8 level = 0);
bool Update(const nzUInt8* pixels, const NzRectui& rect, unsigned int z = 0, nzUInt8 level = 0);
bool Update(const nzUInt8* pixels, const NzCubeui& cube, nzUInt8 level = 0);
bool UpdateFace(nzCubemapFace face, const NzImage& image, nzUInt8 level = 0);
bool UpdateFace(nzCubemapFace face, const NzImage& image, const NzRectui& rect, nzUInt8 level = 0);
bool UpdateFace(nzCubemapFace face, const nzUInt8* pixels, nzUInt8 level = 0);
bool UpdateFace(nzCubemapFace face, const nzUInt8* pixels, const NzRectui& rect, nzUInt8 level = 0);
void Unlock();
// Fonctions OpenGL
unsigned int GetOpenGLID() const;
bool Prepare() const;
static unsigned int GetValidSize(unsigned int size);
static bool IsFormatSupported(nzPixelFormat format);
static bool IsMipmappingSupported();
static bool IsTypeSupported(nzImageType type);
private:
NzRenderTexture* GetRenderTexture() const;
void SetRenderTexture(NzRenderTexture* renderTexture);
NzTextureImpl* m_impl;
};
#endif // NAZARA_TEXTURE_HPP