First commit
This commit is contained in:
82
include/Nazara/Renderer/Buffer.hpp
Normal file
82
include/Nazara/Renderer/Buffer.hpp
Normal file
@@ -0,0 +1,82 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_BUFFER_HPP
|
||||
#define NAZARA_BUFFER_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Utility/Resource.hpp>
|
||||
|
||||
enum nzBufferLock
|
||||
{
|
||||
nzBufferLock_DiscardAndWrite,
|
||||
nzBufferLock_ReadOnly,
|
||||
nzBufferLock_ReadWrite,
|
||||
nzBufferLock_WriteOnly
|
||||
};
|
||||
|
||||
enum nzBufferStorage
|
||||
{
|
||||
nzBufferStorage_Hardware,
|
||||
nzBufferStorage_Software
|
||||
};
|
||||
|
||||
enum nzBufferType
|
||||
{
|
||||
nzBufferType_Index,
|
||||
nzBufferType_Vertex
|
||||
};
|
||||
|
||||
enum nzBufferUsage
|
||||
{
|
||||
nzBufferUsage_Dynamic,
|
||||
nzBufferUsage_Static
|
||||
};
|
||||
|
||||
class NzBufferImpl;
|
||||
class NzRenderer;
|
||||
|
||||
class NAZARA_API NzBuffer : public NzResource
|
||||
{
|
||||
friend class NzRenderer;
|
||||
|
||||
public:
|
||||
NzBuffer(nzBufferType type);
|
||||
NzBuffer(nzBufferType type, unsigned int length, nzUInt8 typeSize, nzBufferUsage usage = nzBufferUsage_Static);
|
||||
~NzBuffer();
|
||||
|
||||
bool CopyContent(NzBuffer& buffer);
|
||||
|
||||
bool Create(unsigned int length, nzUInt8 typeSize, nzBufferUsage usage = nzBufferUsage_Static);
|
||||
void Destroy();
|
||||
|
||||
bool Fill(const void* data, unsigned int offset, unsigned int length);
|
||||
|
||||
unsigned int GetLength() const;
|
||||
unsigned int GetSize() const;
|
||||
nzBufferStorage GetStorage() const;
|
||||
nzBufferType GetType() const;
|
||||
nzUInt8 GetTypeSize() const;
|
||||
nzBufferUsage GetUsage() const;
|
||||
|
||||
bool IsHardware() const;
|
||||
|
||||
void* Lock(nzBufferLock lock, unsigned int offset = 0, unsigned int length = 0);
|
||||
bool Unlock();
|
||||
|
||||
static bool IsHardwareSupported();
|
||||
|
||||
private:
|
||||
nzBufferStorage m_storage;
|
||||
nzBufferType m_type;
|
||||
nzBufferUsage m_usage;
|
||||
nzUInt8 m_typeSize;
|
||||
NzBufferImpl* m_impl;
|
||||
unsigned int m_length;
|
||||
|
||||
};
|
||||
|
||||
#endif // NAZARA_BUFFER_HPP
|
||||
47
include/Nazara/Renderer/Config.hpp
Normal file
47
include/Nazara/Renderer/Config.hpp
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
Nazara Engine
|
||||
|
||||
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
|
||||
|
||||
// Force les buffers à posséder un stride multiple de 32 bytes (Gain de performances sur certaines cartes)
|
||||
#define NAZARA_RENDERER_FORCE_DECLARATION_STRIDE_MULTIPLE_OF_32 0
|
||||
|
||||
// Utilise un tracker pour repérer les éventuels leaks (Ralentit l'exécution)
|
||||
#define NAZARA_RENDERER_MEMORYLEAKTRACKER 0
|
||||
|
||||
// Active les tests de sécurité basés sur le code (Conseillé pour le développement)
|
||||
#define NAZARA_RENDERER_SAFE 1
|
||||
|
||||
// Fait en sorte que le Renderer soit un singleton plutôt qu'une instance globale
|
||||
#define NAZARA_RENDERER_SINGLETON 0
|
||||
|
||||
#endif // NAZARA_CONFIG_MODULENAME_HPP
|
||||
44
include/Nazara/Renderer/Context.hpp
Normal file
44
include/Nazara/Renderer/Context.hpp
Normal file
@@ -0,0 +1,44 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// 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 class NzContextImpl;
|
||||
|
||||
public:
|
||||
NzContext();
|
||||
~NzContext();
|
||||
|
||||
bool Create(const NzContextParameters& parameters = NzContextParameters());
|
||||
const NzContextParameters& GetParameters() const;
|
||||
bool IsActive() const;
|
||||
bool SetActive(bool active);
|
||||
void SwapBuffers();
|
||||
|
||||
static const NzContext* GetCurrent();
|
||||
static const NzContext* GetReference();
|
||||
static bool InitializeReference();
|
||||
static void UninitializeReference();
|
||||
|
||||
private:
|
||||
NzContextParameters m_parameters;
|
||||
NzContextImpl* m_impl;
|
||||
|
||||
static NzContext* s_reference;
|
||||
};
|
||||
|
||||
#endif // NAZARA_CONTEXT_HPP
|
||||
54
include/Nazara/Renderer/ContextParameters.hpp
Normal file
54
include/Nazara/Renderer/ContextParameters.hpp
Normal file
@@ -0,0 +1,54 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_CONTEXTPARAMETERS_HPP
|
||||
#define NAZARA_CONTEXTPARAMETERS_HPP
|
||||
|
||||
#include <Nazara/Renderer/RenderTargetParameters.hpp>
|
||||
#include <Nazara/Utility/VideoMode.hpp>
|
||||
#include <Nazara/Utility/WindowHandle.hpp>
|
||||
|
||||
class NzContext;
|
||||
|
||||
struct NAZARA_API NzContextParameters
|
||||
{
|
||||
NzContextParameters(const NzRenderTargetParameters& parameters = NzRenderTargetParameters()) :
|
||||
antialiasingLevel(parameters.antialiasingLevel),
|
||||
bitsPerPixel(NzVideoMode::GetDesktopMode().bitsPerPixel),
|
||||
depthBits(parameters.depthBits),
|
||||
majorVersion(defaultMajorVersion),
|
||||
minorVersion(defaultMinorVersion),
|
||||
stencilBits(parameters.stencilBits),
|
||||
shareContext(defaultShareContext),
|
||||
window(defaultWindow),
|
||||
compatibilityProfile(defaultCompatibilityProfile),
|
||||
doubleBuffered(defaultDoubleBuffered),
|
||||
shared(defaultShared)
|
||||
{
|
||||
}
|
||||
|
||||
nzUInt8 antialiasingLevel;
|
||||
nzUInt8 bitsPerPixel;
|
||||
nzUInt8 depthBits;
|
||||
nzUInt8 majorVersion;
|
||||
nzUInt8 minorVersion;
|
||||
nzUInt8 stencilBits;
|
||||
const NzContext* shareContext;
|
||||
NzWindowHandle window;
|
||||
bool compatibilityProfile;
|
||||
bool doubleBuffered;
|
||||
bool shared;
|
||||
|
||||
static nzUInt8 defaultMajorVersion;
|
||||
static nzUInt8 defaultMinorVersion;
|
||||
static const NzContext* defaultShareContext;
|
||||
static NzWindowHandle defaultWindow;
|
||||
static bool defaultCompatibilityProfile;
|
||||
static bool defaultDoubleBuffered;
|
||||
static bool defaultShared;
|
||||
};
|
||||
|
||||
#endif // NAZARA_CONTEXTPARAMETERS_HPP
|
||||
11
include/Nazara/Renderer/Debug.hpp
Normal file
11
include/Nazara/Renderer/Debug.hpp
Normal file
@@ -0,0 +1,11 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Renderer/Config.hpp>
|
||||
#if NAZARA_RENDERER_MEMORYLEAKTRACKER || defined(NAZARA_DEBUG)
|
||||
#include <Nazara/Core/Debug/MemoryLeakTracker.hpp>
|
||||
|
||||
#define delete NzMemoryManager::NextFree(__FILE__, __LINE__), delete
|
||||
#define new new(__FILE__, __LINE__)
|
||||
#endif
|
||||
8
include/Nazara/Renderer/DebugOff.hpp
Normal file
8
include/Nazara/Renderer/DebugOff.hpp
Normal file
@@ -0,0 +1,8 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#if NAZARA_RENDERER_MEMORYLEAKTRACKER || defined(NAZARA_DEBUG)
|
||||
#undef delete
|
||||
#undef new
|
||||
#endif
|
||||
41
include/Nazara/Renderer/IndexBuffer.hpp
Normal file
41
include/Nazara/Renderer/IndexBuffer.hpp
Normal file
@@ -0,0 +1,41 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_INDEXBUFFER_HPP
|
||||
#define NAZARA_INDEXBUFFER_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Renderer/Buffer.hpp>
|
||||
|
||||
class NAZARA_API NzIndexBuffer
|
||||
{
|
||||
public:
|
||||
NzIndexBuffer(NzBuffer* buffer, unsigned int startIndex, unsigned int indexCount);
|
||||
NzIndexBuffer(unsigned int length, nzUInt8 indexSize, nzBufferUsage usage = nzBufferUsage_Static);
|
||||
NzIndexBuffer(const NzIndexBuffer& indexBuffer);
|
||||
~NzIndexBuffer();
|
||||
|
||||
bool Fill(const void* data, unsigned int offset, unsigned int length);
|
||||
|
||||
NzBuffer* GetBuffer() const;
|
||||
nzUInt8 GetIndexSize() const;
|
||||
unsigned int GetIndexCount() const;
|
||||
unsigned int GetStartIndex() const;
|
||||
|
||||
bool IsHardware() const;
|
||||
bool IsSequential() const;
|
||||
|
||||
void* Lock(nzBufferLock lock, unsigned int offset = 0, unsigned int length = 0);
|
||||
bool Unlock();
|
||||
|
||||
private:
|
||||
NzBuffer* m_buffer;
|
||||
bool m_ownsBuffer;
|
||||
unsigned int m_indexCount;
|
||||
unsigned int m_startIndex;
|
||||
};
|
||||
|
||||
#endif // NAZARA_INDEXBUFFER_HPP
|
||||
159
include/Nazara/Renderer/OpenGL.hpp
Normal file
159
include/Nazara/Renderer/OpenGL.hpp
Normal file
@@ -0,0 +1,159 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// 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/gl3.h>
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
// Il semblerait qu'il ne soit pas conseillé d'inclure gl3.h t glext.h en même temps, mais je ne vois pas oomment gérer les extensions autrement...
|
||||
#include <GLext/glext.h>
|
||||
#if defined(NAZARA_PLATFORM_WINDOWS)
|
||||
#include <GLext/wglext.h>
|
||||
#elif defined(NAZARA_PLATFORM_LINUX)
|
||||
#include <GLext/glxext.h>
|
||||
#else
|
||||
#error OS not handled
|
||||
#endif
|
||||
|
||||
typedef void (*NzOpenGLFunc)();
|
||||
|
||||
class NAZARA_API NzOpenGL
|
||||
{
|
||||
public:
|
||||
enum Extension
|
||||
{
|
||||
AnisotropicFilter,
|
||||
FP64,
|
||||
Framebuffer_Object,
|
||||
Occlusion_Query,
|
||||
Texture3D,
|
||||
|
||||
Count
|
||||
};
|
||||
|
||||
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 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 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 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 PFNGLGETBUFFERPARAMETERIVPROC glGetBufferParameteriv;
|
||||
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 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 PFNGLPOLYGONMODEPROC glPolygonMode;
|
||||
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 PFNGLTEXIMAGE2DPROC glTexImage2D;
|
||||
NAZARA_API extern PFNGLTEXIMAGE3DEXTPROC glTexImage3D;
|
||||
NAZARA_API extern PFNGLTEXPARAMETERFPROC glTexParameterf;
|
||||
NAZARA_API extern PFNGLTEXPARAMETERIPROC glTexParameteri;
|
||||
NAZARA_API extern PFNGLTEXSUBIMAGE2DPROC glTexSubImage2D;
|
||||
NAZARA_API extern PFNGLTEXSUBIMAGE3DEXTPROC 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
|
||||
40
include/Nazara/Renderer/RenderTarget.hpp
Normal file
40
include/Nazara/Renderer/RenderTarget.hpp
Normal file
@@ -0,0 +1,40 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// 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/RenderTargetParameters.hpp>
|
||||
|
||||
class NzRenderer;
|
||||
|
||||
class NAZARA_API NzRenderTarget
|
||||
{
|
||||
friend class NzRenderer;
|
||||
|
||||
public:
|
||||
NzRenderTarget() = default;
|
||||
virtual ~NzRenderTarget();
|
||||
|
||||
virtual bool CanActivate() const = 0;
|
||||
|
||||
virtual NzRenderTargetParameters GetRenderTargetParameters() const = 0;
|
||||
|
||||
#ifdef NAZARA_RENDERER_OPENGL
|
||||
virtual bool HasContext() const = 0;
|
||||
#endif
|
||||
|
||||
bool IsActive() const;
|
||||
|
||||
bool SetActive(bool active);
|
||||
|
||||
protected:
|
||||
virtual bool Activate() = 0;
|
||||
virtual void Desactivate();
|
||||
};
|
||||
|
||||
#endif // NAZARA_RENDERTARGET_HPP
|
||||
26
include/Nazara/Renderer/RenderTargetParameters.hpp
Normal file
26
include/Nazara/Renderer/RenderTargetParameters.hpp
Normal file
@@ -0,0 +1,26 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_RENDERTARGETPARAMETERS_HPP
|
||||
#define NAZARA_RENDERTARGETPARAMETERS_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
|
||||
struct NzRenderTargetParameters
|
||||
{
|
||||
NzRenderTargetParameters(nzUInt8 antialiasing = 0, nzUInt8 depth = 24, nzUInt8 stencil = 0) :
|
||||
antialiasingLevel(antialiasing),
|
||||
depthBits(depth),
|
||||
stencilBits(stencil)
|
||||
{
|
||||
}
|
||||
|
||||
nzUInt8 antialiasingLevel;
|
||||
nzUInt8 depthBits;
|
||||
nzUInt8 stencilBits;
|
||||
};
|
||||
|
||||
#endif // NAZARA_RENDERTARGETPARAMETERS_HPP
|
||||
59
include/Nazara/Renderer/RenderWindow.hpp
Normal file
59
include/Nazara/Renderer/RenderWindow.hpp
Normal file
@@ -0,0 +1,59 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// 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/Renderer/RenderTarget.hpp>
|
||||
#include <Nazara/Utility/Window.hpp>
|
||||
|
||||
#ifndef NAZARA_RENDERER_COMMON
|
||||
#include <Nazara/Renderer/ContextParameters.hpp>
|
||||
#endif
|
||||
|
||||
class NzContext;
|
||||
struct NzContextParameters;
|
||||
|
||||
class NAZARA_API NzRenderWindow : public NzRenderTarget, public NzWindow
|
||||
{
|
||||
public:
|
||||
NzRenderWindow();
|
||||
NzRenderWindow(NzVideoMode mode, const NzString& title, nzUInt32 style = NzWindow::Default, const NzContextParameters& parameters = NzContextParameters());
|
||||
NzRenderWindow(NzWindowHandle handle, const NzContextParameters& parameters = NzContextParameters());
|
||||
virtual ~NzRenderWindow();
|
||||
|
||||
bool CanActivate() const;
|
||||
|
||||
bool Create(NzVideoMode mode, const NzString& title, nzUInt32 style = NzWindow::Default, const NzContextParameters& parameters = NzContextParameters());
|
||||
bool Create(NzWindowHandle handle, const NzContextParameters& parameters = NzContextParameters());
|
||||
|
||||
void Display();
|
||||
|
||||
void EnableVerticalSync(bool enabled);
|
||||
|
||||
NzRenderTargetParameters GetRenderTargetParameters() const;
|
||||
|
||||
#ifndef NAZARA_RENDERER_COMMON
|
||||
NzContextParameters GetContextParameters() const;
|
||||
|
||||
bool HasContext() const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
bool Activate();
|
||||
|
||||
private:
|
||||
void OnClose();
|
||||
bool OnCreate();
|
||||
|
||||
NzContext* m_context;
|
||||
NzContextParameters m_parameters;
|
||||
};
|
||||
|
||||
#endif // NAZARA_RENDERWINDOW_HPP
|
||||
79
include/Nazara/Renderer/Renderer.hpp
Normal file
79
include/Nazara/Renderer/Renderer.hpp
Normal file
@@ -0,0 +1,79 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_RENDERER_HPP
|
||||
#define NAZARA_RENDERER_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Renderer/IndexBuffer.hpp>
|
||||
#include <Nazara/Renderer/RenderTarget.hpp>
|
||||
#include <Nazara/Renderer/Shader.hpp>
|
||||
#include <Nazara/Renderer/VertexBuffer.hpp>
|
||||
|
||||
#define NazaraRenderer NzRenderer::Instance()
|
||||
|
||||
enum nzRendererCap
|
||||
{
|
||||
nzRendererCap_AnisotropicFilter,
|
||||
nzRendererCap_FP64,
|
||||
nzRendererCap_HardwareBuffer,
|
||||
nzRendererCap_MultipleRenderTargets,
|
||||
nzRendererCap_Texture3D,
|
||||
nzRendererCap_TextureCubemap,
|
||||
nzRendererCap_TextureMulti,
|
||||
nzRendererCap_TextureNPOT,
|
||||
|
||||
nzRendererCap_Count
|
||||
};
|
||||
|
||||
enum nzRendererClear
|
||||
{
|
||||
nzRendererClear_Color = 0x01,
|
||||
nzRendererClear_Depth = 0x02,
|
||||
nzRendererClear_Stencil = 0x04
|
||||
};
|
||||
|
||||
class NAZARA_API NzRenderer
|
||||
{
|
||||
public:
|
||||
NzRenderer();
|
||||
~NzRenderer();
|
||||
|
||||
void Clear(nzRendererClear flags);
|
||||
|
||||
NzShader* GetShader() const;
|
||||
NzRenderTarget* GetTarget() const;
|
||||
|
||||
bool HasCapability(nzRendererCap capability) const;
|
||||
bool Initialize();
|
||||
|
||||
void SetClearColor(nzUInt8 r, nzUInt8 g, nzUInt8 b, nzUInt8 a = 255);
|
||||
void SetClearDepth(double depth);
|
||||
void SetClearStencil(unsigned int value);
|
||||
bool SetIndexBuffer(const NzIndexBuffer* indexBuffer);
|
||||
bool SetShader(NzShader* shader);
|
||||
bool SetTarget(NzRenderTarget* target);
|
||||
bool SetVertexBuffer(const NzVertexBuffer* vertexBuffer);
|
||||
|
||||
void Uninitialize();
|
||||
|
||||
#if NAZARA_RENDERER_SINGLETON
|
||||
static void Destroy();
|
||||
#endif
|
||||
static NzRenderer* Instance();
|
||||
|
||||
private:
|
||||
static NzRenderer* s_instance;
|
||||
|
||||
const NzIndexBuffer* m_indexBuffer;
|
||||
NzRenderTarget* m_target;
|
||||
NzShader* m_shader;
|
||||
const NzVertexBuffer* m_vertexBuffer;
|
||||
bool m_capabilities[nzRendererCap_Count];
|
||||
bool m_vertexBufferUpdated;
|
||||
};
|
||||
|
||||
#endif // NAZARA_RENDERER_HPP
|
||||
75
include/Nazara/Renderer/Shader.hpp
Normal file
75
include/Nazara/Renderer/Shader.hpp
Normal file
@@ -0,0 +1,75 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_SHADER_HPP
|
||||
#define NAZARA_SHADER_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/Matrix4.hpp>
|
||||
|
||||
enum nzShaderLanguage
|
||||
{
|
||||
nzShaderLanguage_Unknown,
|
||||
|
||||
nzShaderLanguage_Cg,
|
||||
nzShaderLanguage_GLSL
|
||||
};
|
||||
|
||||
enum nzShaderType
|
||||
{
|
||||
nzShaderType_Fragment,
|
||||
nzShaderType_Geometry,
|
||||
nzShaderType_Vertex,
|
||||
|
||||
nzShaderType_Count
|
||||
};
|
||||
|
||||
class NzRenderer;
|
||||
class NzShaderImpl;
|
||||
|
||||
class NAZARA_API NzShader
|
||||
{
|
||||
friend class NzRenderer;
|
||||
|
||||
public:
|
||||
NzShader();
|
||||
NzShader(nzShaderLanguage language);
|
||||
~NzShader();
|
||||
|
||||
bool Create(nzShaderLanguage language);
|
||||
bool Compile();
|
||||
|
||||
void Destroy();
|
||||
|
||||
NzString GetLog() const;
|
||||
nzShaderLanguage GetLanguage() const;
|
||||
NzString GetSourceCode(nzShaderType type) const;
|
||||
|
||||
bool IsCompiled() const;
|
||||
bool IsLoaded(nzShaderType type) const;
|
||||
|
||||
bool Load(nzShaderType type, const NzString& source);
|
||||
bool LoadFromFile(nzShaderType type, const NzString& source);
|
||||
|
||||
bool SendBoolean(const NzString& name, bool value);
|
||||
bool SendDouble(const NzString& name, double value);
|
||||
bool SendFloat(const NzString& name, float value);
|
||||
bool SendInteger(const NzString& name, int value);
|
||||
bool SendMatrix(const NzString& name, const NzMatrix4d& matrix);
|
||||
bool SendMatrix(const NzString& name, const NzMatrix4f& matrix);
|
||||
|
||||
static bool IsLanguageSupported(nzShaderLanguage language);
|
||||
static bool IsTypeSupported(nzShaderType type);
|
||||
|
||||
private:
|
||||
bool CommitUniforms();
|
||||
|
||||
NzShaderImpl* m_impl;
|
||||
bool m_compiled;
|
||||
};
|
||||
|
||||
#endif // NAZARA_SHADER_HPP
|
||||
40
include/Nazara/Renderer/VertexBuffer.hpp
Normal file
40
include/Nazara/Renderer/VertexBuffer.hpp
Normal file
@@ -0,0 +1,40 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_VERTEXBUFFER_HPP
|
||||
#define NAZARA_VERTEXBUFFER_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Renderer/Buffer.hpp>
|
||||
|
||||
class NAZARA_API NzVertexBuffer
|
||||
{
|
||||
public:
|
||||
NzVertexBuffer(NzBuffer* buffer, unsigned int startVertex, unsigned int vertexCount);
|
||||
NzVertexBuffer(unsigned int length, nzUInt8 typeSize, nzBufferUsage usage = nzBufferUsage_Static);
|
||||
NzVertexBuffer(const NzVertexBuffer& vertexBuffer);
|
||||
~NzVertexBuffer();
|
||||
|
||||
bool Fill(const void* data, unsigned int offset, unsigned int length);
|
||||
|
||||
NzBuffer* GetBuffer() const;
|
||||
unsigned int GetStartVertex() const;
|
||||
nzUInt8 GetTypeSize() const;
|
||||
unsigned int GetVertexCount() const;
|
||||
|
||||
bool IsHardware() const;
|
||||
|
||||
void* Lock(nzBufferLock lock, unsigned int offset = 0, unsigned int length = 0);
|
||||
bool Unlock();
|
||||
|
||||
private:
|
||||
NzBuffer* m_buffer;
|
||||
bool m_ownsBuffer;
|
||||
unsigned int m_startVertex;
|
||||
unsigned int m_vertexCount;
|
||||
};
|
||||
|
||||
#endif // NAZARA_VERTEXBUFFER_HPP
|
||||
75
include/Nazara/Renderer/VertexDeclaration.hpp
Normal file
75
include/Nazara/Renderer/VertexDeclaration.hpp
Normal file
@@ -0,0 +1,75 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#ifndef NAZARA_VERTEXDECLARATION_HPP
|
||||
#define NAZARA_VERTEXDECLARATION_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <vector>
|
||||
|
||||
enum nzElementType
|
||||
{
|
||||
nzElementType_Color,
|
||||
nzElementType_Double1,
|
||||
nzElementType_Double2,
|
||||
nzElementType_Double3,
|
||||
nzElementType_Double4,
|
||||
nzElementType_Float1,
|
||||
nzElementType_Float2,
|
||||
nzElementType_Float3,
|
||||
nzElementType_Float4
|
||||
};
|
||||
|
||||
enum nzElementUsage
|
||||
{
|
||||
nzElementType_Diffuse,
|
||||
nzElementType_Normal,
|
||||
nzElementType_Position,
|
||||
nzElementType_Tangent,
|
||||
nzElementType_TexCoord
|
||||
};
|
||||
|
||||
struct NzVertexElement
|
||||
{
|
||||
NzVertexElement() : stream(0), usageIndex(0) {}
|
||||
|
||||
unsigned int offset;
|
||||
unsigned int stream;
|
||||
unsigned int usageIndex;
|
||||
nzElementType type;
|
||||
nzElementUsage usage;
|
||||
};
|
||||
|
||||
class NAZARA_API NzVertexDeclaration
|
||||
{
|
||||
public:
|
||||
struct Element
|
||||
{
|
||||
unsigned int offset;
|
||||
unsigned int usageIndex;
|
||||
nzElementType type;
|
||||
nzElementUsage usage;
|
||||
};
|
||||
|
||||
NzVertexDeclaration() = default;
|
||||
~NzVertexDeclaration() = default;
|
||||
|
||||
bool Create(const NzVertexElement* elements, unsigned int elementCount);
|
||||
|
||||
const Element* GetElement(unsigned int i, unsigned int stream = 0) const;
|
||||
unsigned int GetElementCount(unsigned int stream = 0) const;
|
||||
unsigned int GetStreamCount() const;
|
||||
unsigned int GetStride(unsigned int stream = 0) const;
|
||||
|
||||
private:
|
||||
struct Stream
|
||||
{
|
||||
std::vector<Element> elements;
|
||||
unsigned int stride;
|
||||
};
|
||||
|
||||
std::vector<Stream> m_streams;
|
||||
};
|
||||
|
||||
#endif // NAZARA_VERTEXDECLARATION_HPP
|
||||
Reference in New Issue
Block a user