Merge branch 'OpenGL3-upgrade' into NDK
Conflicts: src/Nazara/Graphics/SkyboxBackground.cpp src/Nazara/Renderer/RenderTexture.cpp src/Nazara/Renderer/Renderer.cpp Former-commit-id: e8914d4e32a689b7df365dca15a438f10722530c
This commit is contained in:
commit
70ea6912e1
|
|
@ -107,20 +107,10 @@ enum nzPixelBufferType
|
|||
enum nzRendererCap
|
||||
{
|
||||
nzRendererCap_AnisotropicFilter,
|
||||
nzRendererCap_ConditionalRendering,
|
||||
nzRendererCap_FP64,
|
||||
nzRendererCap_HardwareBuffer,
|
||||
nzRendererCap_Instancing,
|
||||
nzRendererCap_MultipleRenderTargets,
|
||||
nzRendererCap_OcclusionQuery,
|
||||
nzRendererCap_PixelBufferObject,
|
||||
nzRendererCap_RenderTexture,
|
||||
nzRendererCap_Texture3D,
|
||||
nzRendererCap_TextureCubemap,
|
||||
nzRendererCap_TextureMulti,
|
||||
nzRendererCap_TextureNPOT,
|
||||
|
||||
nzRendererCap_Max = nzRendererCap_TextureNPOT
|
||||
nzRendererCap_Max = nzRendererCap_Instancing
|
||||
};
|
||||
|
||||
enum nzRendererBufferFlags
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ class NAZARA_RENDERER_API NzGpuQuery : NzNonCopyable
|
|||
unsigned int GetOpenGLID() const;
|
||||
|
||||
static bool IsModeSupported(nzGpuQueryMode mode);
|
||||
static bool IsSupported();
|
||||
|
||||
private:
|
||||
nzGpuQueryMode m_mode;
|
||||
|
|
|
|||
|
|
@ -32,23 +32,15 @@ namespace GLX
|
|||
enum nzOpenGLExtension
|
||||
{
|
||||
nzOpenGLExtension_AnisotropicFilter,
|
||||
nzOpenGLExtension_ConditionalRender,
|
||||
nzOpenGLExtension_DebugOutput,
|
||||
nzOpenGLExtension_DrawInstanced,
|
||||
nzOpenGLExtension_FP64,
|
||||
nzOpenGLExtension_FrameBufferObject,
|
||||
nzOpenGLExtension_GetProgramBinary,
|
||||
nzOpenGLExtension_InstancedArray,
|
||||
nzOpenGLExtension_PixelBufferObject,
|
||||
nzOpenGLExtension_SamplerObjects,
|
||||
nzOpenGLExtension_SeparateShaderObjects,
|
||||
nzOpenGLExtension_Shader_ImageLoadStore,
|
||||
nzOpenGLExtension_TextureArray,
|
||||
nzOpenGLExtension_TextureCompression_s3tc,
|
||||
nzOpenGLExtension_TextureStorage,
|
||||
nzOpenGLExtension_VertexArrayObjects,
|
||||
|
||||
nzOpenGLExtension_Max = nzOpenGLExtension_VertexArrayObjects
|
||||
nzOpenGLExtension_Max = nzOpenGLExtension_TextureStorage
|
||||
};
|
||||
|
||||
class NzContext;
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ class NAZARA_RENDERER_API NzRenderBuffer : public NzRefCounted, NzNonCopyable
|
|||
|
||||
bool IsValid() const;
|
||||
|
||||
static bool IsSupported();
|
||||
template<typename... Args> static NzRenderBufferRef New(Args&&... args);
|
||||
|
||||
// Signals:
|
||||
|
|
|
|||
|
|
@ -61,7 +61,6 @@ class NAZARA_RENDERER_API NzRenderTexture : public NzRenderTarget, NzNonCopyable
|
|||
|
||||
static inline void Blit(NzRenderTexture* src, NzRenderTexture* dst, nzUInt32 buffers = nzRendererBuffer_Color | nzRendererBuffer_Depth | nzRendererBuffer_Stencil, bool bilinearFilter = false);
|
||||
static void Blit(NzRenderTexture* src, NzRectui srcRect, NzRenderTexture* dst, NzRectui dstRect, nzUInt32 buffers = nzRendererBuffer_Color | nzRendererBuffer_Depth | nzRendererBuffer_Stencil, bool bilinearFilter = false);
|
||||
static bool IsSupported();
|
||||
|
||||
protected:
|
||||
bool Activate() const override;
|
||||
|
|
|
|||
|
|
@ -102,7 +102,6 @@ class NAZARA_RENDERER_API NzTexture : public NzAbstractImage, public NzRefCounte
|
|||
// Fonctions OpenGL
|
||||
unsigned int GetOpenGLID() const;
|
||||
|
||||
static unsigned int GetValidSize(unsigned int size);
|
||||
static bool IsFormatSupported(nzPixelFormat format);
|
||||
static bool IsMipmappingSupported();
|
||||
static bool IsTypeSupported(nzImageType type);
|
||||
|
|
|
|||
|
|
@ -8,27 +8,16 @@
|
|||
#include <Nazara/Renderer/Renderer.hpp>
|
||||
#include <Nazara/Graphics/Debug.hpp>
|
||||
|
||||
NzAbstractRenderTechnique::NzAbstractRenderTechnique()
|
||||
NzAbstractRenderTechnique::NzAbstractRenderTechnique() :
|
||||
m_instancingEnabled(true)
|
||||
{
|
||||
#ifdef NAZARA_DEBUG
|
||||
if (!NzRenderer::IsInitialized())
|
||||
{
|
||||
NazaraError("NazaraRenderer is not initialized");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
m_instancingEnabled = NzRenderer::HasCapability(nzRendererCap_Instancing);
|
||||
}
|
||||
|
||||
NzAbstractRenderTechnique::~NzAbstractRenderTechnique() = default;
|
||||
|
||||
void NzAbstractRenderTechnique::EnableInstancing(bool instancing)
|
||||
{
|
||||
if (NzRenderer::HasCapability(nzRendererCap_Instancing))
|
||||
m_instancingEnabled = instancing;
|
||||
else if (instancing)
|
||||
NazaraError("NazaraRenderer does not support instancing");
|
||||
}
|
||||
|
||||
NzString NzAbstractRenderTechnique::GetName() const
|
||||
|
|
|
|||
|
|
@ -395,12 +395,8 @@ void NzDeferredRenderTechnique::SetPass(nzRenderPassType relativeTo, int positio
|
|||
|
||||
bool NzDeferredRenderTechnique::IsSupported()
|
||||
{
|
||||
// On ne va pas s'embêter à écrire un Deferred Renderer qui ne passe pas par le MRT, ce serait trop lent pour servir...
|
||||
return NzOpenGL::GetGLSLVersion() >= 140 && // On ne va pas s'embêter non plus avec le mode de compatibilité
|
||||
NzRenderer::HasCapability(nzRendererCap_RenderTexture) &&
|
||||
NzRenderer::HasCapability(nzRendererCap_MultipleRenderTargets) &&
|
||||
NzRenderer::GetMaxColorAttachments() >= 4 &&
|
||||
NzRenderer::GetMaxRenderTargets() >= 4;
|
||||
// Depuis qu'OpenGL 3.3 est la version minimale, le Renderer supporte ce qu'il faut, mais par acquis de conscience...
|
||||
return NzRenderer::GetMaxColorAttachments() >= 4 && NzRenderer::GetMaxRenderTargets() >= 4;
|
||||
}
|
||||
|
||||
bool NzDeferredRenderTechnique::Resize(const NzVector2ui& dimensions) const
|
||||
|
|
|
|||
|
|
@ -16,21 +16,22 @@
|
|||
|
||||
namespace
|
||||
{
|
||||
const nzUInt8 r_coreFragmentShader[] = {
|
||||
const nzUInt8 r_basicFragmentShader[] = {
|
||||
#include <Nazara/Graphics/Resources/Shaders/Basic/core.frag.h>
|
||||
};
|
||||
|
||||
const nzUInt8 r_coreVertexShader[] = {
|
||||
const nzUInt8 r_basicVertexShader[] = {
|
||||
#include <Nazara/Graphics/Resources/Shaders/Basic/core.vert.h>
|
||||
};
|
||||
|
||||
const nzUInt8 r_compatibilityFragmentShader[] = {
|
||||
#include <Nazara/Graphics/Resources/Shaders/Basic/compatibility.frag.h>
|
||||
const nzUInt8 r_phongLightingFragmentShader[] = {
|
||||
#include <Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag.h>
|
||||
};
|
||||
|
||||
const nzUInt8 r_compatibilityVertexShader[] = {
|
||||
#include <Nazara/Graphics/Resources/Shaders/Basic/compatibility.vert.h>
|
||||
const nzUInt8 r_phongLightingVertexShader[] = {
|
||||
#include <Nazara/Graphics/Resources/Shaders/PhongLighting/core.vert.h>
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
bool NzMaterialParams::IsValid() const
|
||||
|
|
@ -722,24 +723,12 @@ bool NzMaterial::Initialize()
|
|||
return false;
|
||||
}
|
||||
|
||||
bool glsl140 = (NzOpenGL::GetGLSLVersion() >= 140);
|
||||
|
||||
// Basic shader
|
||||
{
|
||||
NzUberShaderPreprocessorRef uberShader = NzUberShaderPreprocessor::New();
|
||||
|
||||
NzString fragmentShader;
|
||||
NzString vertexShader;
|
||||
if (glsl140)
|
||||
{
|
||||
fragmentShader.Set(reinterpret_cast<const char*>(r_coreFragmentShader), sizeof(r_coreFragmentShader));
|
||||
vertexShader.Set(reinterpret_cast<const char*>(r_coreVertexShader), sizeof(r_coreVertexShader));
|
||||
}
|
||||
else
|
||||
{
|
||||
fragmentShader.Set(reinterpret_cast<const char*>(r_compatibilityFragmentShader), sizeof(r_compatibilityFragmentShader));
|
||||
vertexShader.Set(reinterpret_cast<const char*>(r_compatibilityVertexShader), sizeof(r_compatibilityVertexShader));
|
||||
}
|
||||
NzString fragmentShader(reinterpret_cast<const char*>(r_basicFragmentShader), sizeof(r_basicFragmentShader));
|
||||
NzString vertexShader(reinterpret_cast<const char*>(r_basicVertexShader), sizeof(r_basicVertexShader));
|
||||
|
||||
uberShader->SetShader(nzShaderStage_Fragment, fragmentShader, "FLAG_TEXTUREOVERLAY ALPHA_MAPPING ALPHA_TEST AUTO_TEXCOORDS DIFFUSE_MAPPING");
|
||||
uberShader->SetShader(nzShaderStage_Vertex, vertexShader, "FLAG_BILLBOARD FLAG_INSTANCING FLAG_VERTEXCOLOR TEXTURE_MAPPING TRANSFORM UNIFORM_VERTEX_DEPTH");
|
||||
|
|
@ -751,34 +740,8 @@ bool NzMaterial::Initialize()
|
|||
{
|
||||
NzUberShaderPreprocessorRef uberShader = NzUberShaderPreprocessor::New();
|
||||
|
||||
NzString fragmentShader;
|
||||
NzString vertexShader;
|
||||
if (glsl140)
|
||||
{
|
||||
const nzUInt8 coreFragmentShader[] = {
|
||||
#include <Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag.h>
|
||||
};
|
||||
|
||||
const nzUInt8 coreVertexShader[] = {
|
||||
#include <Nazara/Graphics/Resources/Shaders/PhongLighting/core.vert.h>
|
||||
};
|
||||
|
||||
fragmentShader.Set(reinterpret_cast<const char*>(coreFragmentShader), sizeof(coreFragmentShader));
|
||||
vertexShader.Set(reinterpret_cast<const char*>(coreVertexShader), sizeof(coreVertexShader));
|
||||
}
|
||||
else
|
||||
{
|
||||
const nzUInt8 compatibilityFragmentShader[] = {
|
||||
#include <Nazara/Graphics/Resources/Shaders/PhongLighting/compatibility.frag.h>
|
||||
};
|
||||
|
||||
const nzUInt8 compatibilityVertexShader[] = {
|
||||
#include <Nazara/Graphics/Resources/Shaders/PhongLighting/compatibility.vert.h>
|
||||
};
|
||||
|
||||
fragmentShader.Set(reinterpret_cast<const char*>(compatibilityFragmentShader), sizeof(compatibilityFragmentShader));
|
||||
vertexShader.Set(reinterpret_cast<const char*>(compatibilityVertexShader), sizeof(compatibilityVertexShader));
|
||||
}
|
||||
NzString fragmentShader(reinterpret_cast<const char*>(r_phongLightingFragmentShader), sizeof(r_phongLightingFragmentShader));
|
||||
NzString vertexShader(reinterpret_cast<const char*>(r_phongLightingVertexShader), sizeof(r_phongLightingVertexShader));
|
||||
|
||||
uberShader->SetShader(nzShaderStage_Fragment, fragmentShader, "FLAG_DEFERRED FLAG_TEXTUREOVERLAY ALPHA_MAPPING ALPHA_TEST AUTO_TEXCOORDS DIFFUSE_MAPPING EMISSIVE_MAPPING LIGHTING NORMAL_MAPPING PARALLAX_MAPPING SPECULAR_MAPPING");
|
||||
uberShader->SetShader(nzShaderStage_Vertex, vertexShader, "FLAG_BILLBOARD FLAG_DEFERRED FLAG_INSTANCING FLAG_VERTEXCOLOR COMPUTE_TBNMATRIX LIGHTING PARALLAX_MAPPING TEXTURE_MAPPING TRANSFORM UNIFORM_VERTEX_DEPTH");
|
||||
|
|
|
|||
|
|
@ -1,37 +0,0 @@
|
|||
/********************Entrant********************/
|
||||
varying vec2 vTexCoord;
|
||||
varying vec4 vColor;
|
||||
|
||||
/********************Uniformes********************/
|
||||
uniform sampler2D MaterialAlphaMap;
|
||||
uniform float MaterialAlphaThreshold;
|
||||
uniform vec4 MaterialDiffuse;
|
||||
uniform sampler2D MaterialDiffuseMap;
|
||||
uniform vec2 InvTargetSize;
|
||||
|
||||
/********************Fonctions********************/
|
||||
void main()
|
||||
{
|
||||
vec4 fragmentColor = MaterialDiffuse; * vColor;
|
||||
|
||||
#if AUTO_TEXCOORDS
|
||||
vec2 texCoord = gl_FragCoord.xy * InvTargetSize;
|
||||
#else
|
||||
vec2 texCoord = vTexCoord;
|
||||
#endif
|
||||
|
||||
#if DIFFUSE_MAPPING
|
||||
fragmentColor *= texture2D(MaterialDiffuseMap, texCoord);
|
||||
#endif
|
||||
|
||||
#if ALPHA_MAPPING
|
||||
fragmentColor.a *= texture2D(MaterialAlphaMap, texCoord).r;
|
||||
#endif
|
||||
|
||||
#if ALPHA_TEST
|
||||
if (fragmentColor.a < MaterialAlphaThreshold)
|
||||
discard;
|
||||
#endif
|
||||
|
||||
gl_FragColor = fragmentColor;
|
||||
}
|
||||
|
|
@ -1 +0,0 @@
|
|||
47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,69,110,116,114,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,118,97,114,121,105,110,103,32,118,101,99,50,32,118,84,101,120,67,111,111,114,100,59,13,10,118,97,114,121,105,110,103,32,118,101,99,52,32,118,67,111,108,111,114,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,59,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,59,13,10,117,110,105,102,111,114,109,32,118,101,99,50,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,118,111,105,100,32,109,97,105,110,40,41,13,10,123,13,10,9,118,101,99,52,32,102,114,97,103,109,101,110,116,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,59,32,42,32,118,67,111,108,111,114,59,13,10,13,10,35,105,102,32,65,85,84,79,95,84,69,88,67,79,79,82,68,83,13,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,32,61,32,103,108,95,70,114,97,103,67,111,111,114,100,46,120,121,32,42,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,13,10,35,101,108,115,101,13,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,32,61,32,118,84,101,120,67,111,111,114,100,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,68,73,70,70,85,83,69,95,77,65,80,80,73,78,71,13,10,9,102,114,97,103,109,101,110,116,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,50,68,40,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,44,32,116,101,120,67,111,111,114,100,41,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,65,76,80,72,65,95,77,65,80,80,73,78,71,13,10,9,102,114,97,103,109,101,110,116,67,111,108,111,114,46,97,32,42,61,32,116,101,120,116,117,114,101,50,68,40,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,65,76,80,72,65,95,84,69,83,84,13,10,9,105,102,32,40,102,114,97,103,109,101,110,116,67,111,108,111,114,46,97,32,60,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,41,13,10,9,9,100,105,115,99,97,114,100,59,13,10,35,101,110,100,105,102,13,10,13,10,9,103,108,95,70,114,97,103,67,111,108,111,114,32,61,32,102,114,97,103,109,101,110,116,67,111,108,111,114,59,13,10,125,
|
||||
|
|
@ -1,99 +0,0 @@
|
|||
/********************Entrant********************/
|
||||
#if FLAG_BILLBOARD
|
||||
varying vec3 InstanceData0; // center
|
||||
varying vec4 InstanceData1; // size | sin cos
|
||||
varying vec4 InstanceData2; // color
|
||||
#else
|
||||
varying mat4 InstanceData0;
|
||||
#endif
|
||||
|
||||
varying vec4 VertexColor;
|
||||
varying vec3 VertexPosition;
|
||||
varying vec2 VertexTexCoord;
|
||||
|
||||
/********************Sortant********************/
|
||||
varying vec2 vTexCoord;
|
||||
varying vec4 vColor;
|
||||
|
||||
/********************Uniformes********************/
|
||||
uniform float VertexDepth;
|
||||
uniform mat4 ViewProjMatrix;
|
||||
uniform mat4 WorldViewProjMatrix;
|
||||
|
||||
/********************Fonctions********************/
|
||||
void main()
|
||||
{
|
||||
#if FLAG_VERTEXCOLOR
|
||||
vec4 color = VertexColor;
|
||||
#else
|
||||
vec4 color = vec4(1.0);
|
||||
#endif
|
||||
vec2 texCoords;
|
||||
|
||||
#if FLAG_BILLBOARD
|
||||
#if FLAG_INSTANCING
|
||||
vec3 billboardCenter = InstanceData0;
|
||||
vec2 billboardSize = InstanceData1.xy;
|
||||
vec2 billboardSinCos = InstanceData1.zw;
|
||||
vec4 billboardColor = InstanceData2;
|
||||
|
||||
vec2 rotatedPosition;
|
||||
rotatedPosition.x = VertexPosition.x*billboardSinCos.y - VertexPosition.y*billboardSinCos.x;
|
||||
rotatedPosition.y = VertexPosition.y*billboardSinCos.y + VertexPosition.x*billboardSinCos.x;
|
||||
rotatedPosition *= billboardSize;
|
||||
|
||||
vec3 cameraRight = vec3(ViewMatrix[0][0], ViewMatrix[1][0], ViewMatrix[2][0]);
|
||||
vec3 cameraUp = vec3(ViewMatrix[0][1], ViewMatrix[1][1], ViewMatrix[2][1]);
|
||||
vec3 vertexPos = billboardCenter + cameraRight*rotatedPosition.x + cameraUp*rotatedPosition.y;
|
||||
|
||||
gl_Position = ViewProjMatrix * vec4(vertexPos, 1.0);
|
||||
color = billboardColor;
|
||||
texCoords = VertexPosition.xy + vec2(0.5, 0.5);
|
||||
#else
|
||||
vec2 billboardCorner = VertexTexCoord - vec2(0.5, 0.5);
|
||||
vec2 billboardSize = VertexUserdata0.xy;
|
||||
vec2 billboardSinCos = VertexUserdata0.zw;
|
||||
|
||||
vec2 rotatedPosition;
|
||||
rotatedPosition.x = billboardCorner.x*billboardSinCos.y - billboardCorner.y*billboardSinCos.x;
|
||||
rotatedPosition.y = billboardCorner.y*billboardSinCos.y + billboardCorner.x*billboardSinCos.x;
|
||||
rotatedPosition *= billboardSize;
|
||||
|
||||
vec3 cameraRight = vec3(ViewMatrix[0][0], ViewMatrix[1][0], ViewMatrix[2][0]);
|
||||
vec3 cameraUp = vec3(ViewMatrix[0][1], ViewMatrix[1][1], ViewMatrix[2][1]);
|
||||
vec3 vertexPos = VertexPosition + cameraRight*rotatedPosition.x + cameraUp*rotatedPosition.y;
|
||||
|
||||
gl_Position = ViewProjMatrix * vec4(vertexPos, 1.0);
|
||||
texCoords = VertexTexCoord;
|
||||
#endif
|
||||
#else
|
||||
#if FLAG_INSTANCING
|
||||
#if TRANSFORM
|
||||
gl_Position = ViewProjMatrix * InstanceData0 * vec4(VertexPosition, 1.0);
|
||||
#else
|
||||
#if UNIFORM_VERTEX_DEPTH
|
||||
gl_Position = InstanceData0 * vec4(VertexPosition.xy, VertexDepth, 1.0);
|
||||
#else
|
||||
gl_Position = InstanceData0 * vec4(VertexPosition, 1.0);
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
#if TRANSFORM
|
||||
gl_Position = WorldViewProjMatrix * vec4(VertexPosition, 1.0);
|
||||
#else
|
||||
#if UNIFORM_VERTEX_DEPTH
|
||||
gl_Position = vec4(VertexPosition.xy, VertexDepth, 1.0);
|
||||
#else
|
||||
gl_Position = vec4(VertexPosition, 1.0);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
texCoords = VertexTexCoord;
|
||||
#endif
|
||||
|
||||
vColor = color;
|
||||
#if TEXTURE_MAPPING
|
||||
vTexCoord = vec2(texCoords);
|
||||
#endif
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -1,237 +0,0 @@
|
|||
#if FLAG_DEFERRED
|
||||
#error Deferred Shading is not supported by compatibility shaders
|
||||
#endif
|
||||
|
||||
#define LIGHT_DIRECTIONAL 0
|
||||
#define LIGHT_POINT 1
|
||||
#define LIGHT_SPOT 2
|
||||
|
||||
/********************Entrant********************/
|
||||
varying mat3 vLightToWorld;
|
||||
varying vec3 vNormal;
|
||||
varying vec2 vTexCoord;
|
||||
varying vec3 vWorldPos;
|
||||
varying vec4 vColor;
|
||||
|
||||
/********************Uniformes********************/
|
||||
struct Light
|
||||
{
|
||||
int type;
|
||||
vec4 color;
|
||||
vec2 factors;
|
||||
|
||||
vec4 parameters1;
|
||||
vec4 parameters2;
|
||||
vec2 parameters3;
|
||||
};
|
||||
|
||||
// Lumières
|
||||
uniform Light Lights[3];
|
||||
|
||||
// Matériau
|
||||
uniform sampler2D MaterialAlphaMap;
|
||||
uniform float MaterialAlphaThreshold;
|
||||
uniform vec4 MaterialAmbient;
|
||||
uniform vec4 MaterialDiffuse;
|
||||
uniform sampler2D MaterialDiffuseMap;
|
||||
uniform sampler2D MaterialEmissiveMap;
|
||||
uniform sampler2D MaterialNormalMap;
|
||||
uniform float MaterialShininess;
|
||||
uniform vec4 MaterialSpecular;
|
||||
uniform sampler2D MaterialSpecularMap;
|
||||
|
||||
// Autres
|
||||
uniform vec3 EyePosition;
|
||||
uniform vec4 SceneAmbient;
|
||||
|
||||
/********************Fonctions********************/
|
||||
void main()
|
||||
{
|
||||
vec4 diffuseColor = MaterialDiffuse * vColor;
|
||||
|
||||
#if AUTO_TEXCOORDS
|
||||
vec2 texCoord = gl_FragCoord.xy * InvTargetSize;
|
||||
#else
|
||||
vec2 texCoord = vTexCoord;
|
||||
#endif
|
||||
|
||||
#if DIFFUSE_MAPPING
|
||||
diffuseColor *= texture(MaterialDiffuseMap, texCoord);
|
||||
#endif
|
||||
|
||||
#if ALPHA_MAPPING
|
||||
diffuseColor.a *= texture(MaterialAlphaMap, texCoord).r;
|
||||
#endif
|
||||
|
||||
#if ALPHA_TEST
|
||||
if (diffuseColor.a < MaterialAlphaThreshold)
|
||||
discard;
|
||||
#endif
|
||||
|
||||
#if LIGHTING
|
||||
vec3 lightAmbient = vec3(0.0);
|
||||
vec3 lightDiffuse = vec3(0.0);
|
||||
vec3 lightSpecular = vec3(0.0);
|
||||
|
||||
#if NORMAL_MAPPING
|
||||
vec3 normal = normalize(vLightToWorld * (2.0 * vec3(texture(MaterialNormalMap, texCoord)) - 1.0));
|
||||
#else
|
||||
vec3 normal = normalize(vNormal);
|
||||
#endif
|
||||
|
||||
if (MaterialShininess > 0.0)
|
||||
{
|
||||
vec3 eyeVec = normalize(EyePosition - vWorldPos);
|
||||
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
if (Lights[i].type == LIGHT_DIRECTIONAL)
|
||||
{
|
||||
vec3 lightDir = -Lights[i].parameters1.xyz;
|
||||
|
||||
// Ambient
|
||||
lightAmbient += Lights[i].color.rgb * Lights[i].factors.x * (MaterialAmbient.rgb + SceneAmbient.rgb);
|
||||
|
||||
// Diffuse
|
||||
float lambert = max(dot(normal, lightDir), 0.0);
|
||||
|
||||
lightDiffuse += lambert * Lights[i].color.rgb * Lights[i].factors.y;
|
||||
|
||||
// Specular
|
||||
vec3 reflection = reflect(-lightDir, normal);
|
||||
float specularFactor = max(dot(reflection, eyeVec), 0.0);
|
||||
specularFactor = pow(specularFactor, MaterialShininess);
|
||||
|
||||
lightSpecular += specularFactor * Lights[i].color.rgb;
|
||||
}
|
||||
else if (Lights[i].type == LIGHT_POINT)
|
||||
{
|
||||
vec3 lightDir = Lights[i].parameters1.xyz - vWorldPos;
|
||||
float lightDirLength = length(lightDir);
|
||||
lightDir /= lightDirLength; // Normalisation
|
||||
|
||||
float att = max(Lights[i].parameters1.w - Lights[i].parameters2.w*lightDirLength, 0.0);
|
||||
|
||||
// Ambient
|
||||
lightAmbient += att * Lights[i].color.rgb * Lights[i].factors.x * (MaterialAmbient.rgb + SceneAmbient.rgb);
|
||||
|
||||
// Diffuse
|
||||
float lambert = max(dot(normal, lightDir), 0.0);
|
||||
|
||||
lightDiffuse += att * lambert * Lights[i].color.rgb * Lights[i].factors.y;
|
||||
|
||||
// Specular
|
||||
vec3 reflection = reflect(-lightDir, normal);
|
||||
float specularFactor = max(dot(reflection, eyeVec), 0.0);
|
||||
specularFactor = pow(specularFactor, MaterialShininess);
|
||||
|
||||
lightSpecular += att * specularFactor * Lights[i].color.rgb;
|
||||
}
|
||||
else if (Lights[i].type == LIGHT_SPOT)
|
||||
{
|
||||
vec3 lightDir = Lights[i].parameters1.xyz - vWorldPos;
|
||||
float lightDirLength = length(lightDir);
|
||||
lightDir /= lightDirLength; // Normalisation
|
||||
|
||||
float att = max(Lights[i].parameters1.w - Lights[i].parameters2.w*lightDirLength, 0.0);
|
||||
|
||||
// Ambient
|
||||
lightAmbient += att * Lights[i].color.rgb * Lights[i].factors.x * (MaterialAmbient.rgb + SceneAmbient.rgb);
|
||||
|
||||
// Diffuse
|
||||
float lambert = max(dot(normal, lightDir), 0.0);
|
||||
|
||||
// Modification de l'atténuation pour gérer le spot
|
||||
float curAngle = dot(Lights[i].parameters2.xyz, -lightDir);
|
||||
float outerAngle = Lights[i].parameters3.y;
|
||||
float innerMinusOuterAngle = Lights[i].parameters3.x - outerAngle;
|
||||
att *= max((curAngle - outerAngle) / innerMinusOuterAngle, 0.0);
|
||||
|
||||
lightDiffuse += att * lambert * Lights[i].color.rgb * Lights[i].factors.y;
|
||||
|
||||
// Specular
|
||||
vec3 reflection = reflect(-lightDir, normal);
|
||||
float specularFactor = max(dot(reflection, eyeVec), 0.0);
|
||||
specularFactor = pow(specularFactor, MaterialShininess);
|
||||
|
||||
lightSpecular += att * specularFactor * Lights[i].color.rgb;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
if (Lights[i].type == LIGHT_DIRECTIONAL)
|
||||
{
|
||||
vec3 lightDir = -Lights[i].parameters1.xyz;
|
||||
|
||||
// Ambient
|
||||
lightAmbient += Lights[i].color.rgb * Lights[i].factors.x * (MaterialAmbient.rgb + SceneAmbient.rgb);
|
||||
|
||||
// Diffuse
|
||||
float lambert = max(dot(normal, lightDir), 0.0);
|
||||
|
||||
lightDiffuse += lambert * Lights[i].color.rgb * Lights[i].factors.y;
|
||||
}
|
||||
else if (Lights[i].type == LIGHT_POINT)
|
||||
{
|
||||
vec3 lightDir = Lights[i].parameters1.xyz - vWorldPos;
|
||||
float lightDirLength = length(lightDir);
|
||||
lightDir /= lightDirLength; // Normalisation
|
||||
|
||||
float att = max(Lights[i].parameters1.w - Lights[i].parameters2.w*lightDirLength, 0.0);
|
||||
|
||||
// Ambient
|
||||
lightAmbient += att * Lights[i].color.rgb * Lights[i].factors.x * (MaterialAmbient.rgb + SceneAmbient.rgb);
|
||||
|
||||
// Diffuse
|
||||
float lambert = max(dot(normal, lightDir), 0.0);
|
||||
|
||||
lightDiffuse += att * lambert * Lights[i].color.rgb * Lights[i].factors.y;
|
||||
}
|
||||
else if (Lights[i].type == LIGHT_SPOT)
|
||||
{
|
||||
vec3 lightDir = Lights[i].parameters1.xyz - vWorldPos;
|
||||
float lightDirLength = length(lightDir);
|
||||
lightDir /= lightDirLength; // Normalisation
|
||||
|
||||
float att = max(Lights[i].parameters1.w - Lights[i].parameters2.w*lightDirLength, 0.0);
|
||||
|
||||
// Ambient
|
||||
lightAmbient += att * Lights[i].color.rgb * Lights[i].factors.x * (MaterialAmbient.rgb + SceneAmbient.rgb);
|
||||
|
||||
// Diffuse
|
||||
float lambert = max(dot(normal, lightDir), 0.0);
|
||||
|
||||
// Modification de l'atténuation pour gérer le spot
|
||||
float curAngle = dot(Lights[i].parameters2.xyz, -lightDir);
|
||||
float outerAngle = Lights[i].parameters3.y;
|
||||
float innerMinusOuterAngle = Lights[i].parameters3.x - outerAngle;
|
||||
att *= max((curAngle - outerAngle) / innerMinusOuterAngle, 0.0);
|
||||
|
||||
lightDiffuse += att * lambert * Lights[i].color.rgb * Lights[i].factors.y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lightSpecular *= MaterialSpecular.rgb;
|
||||
#if SPECULAR_MAPPING
|
||||
lightSpecular *= texture(MaterialSpecularMap, texCoord).rgb; // Utiliser l'alpha de MaterialSpecular n'aurait aucun sens
|
||||
#endif
|
||||
|
||||
vec3 lightColor = (lightAmbient + lightDiffuse + lightSpecular);
|
||||
vec4 fragmentColor = vec4(lightColor, 1.0) * diffuseColor;
|
||||
|
||||
#if EMISSIVE_MAPPING
|
||||
float lightIntensity = dot(lightColor, vec3(0.3, 0.59, 0.11));
|
||||
|
||||
vec3 emissionColor = MaterialDiffuse.rgb * texture(MaterialEmissiveMap, texCoord).rgb;
|
||||
RenderTarget0 = vec4(mix(fragmentColor.rgb, emissionColor, clamp(1.0 - 3.0*lightIntensity, 0.0, 1.0)), fragmentColor.a);
|
||||
#else
|
||||
RenderTarget0 = fragmentColor;
|
||||
#endif // EMISSIVE_MAPPING
|
||||
#else
|
||||
RenderTarget0 = diffuseColor;
|
||||
#endif // LIGHTING
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -1,135 +0,0 @@
|
|||
/********************Entrant********************/
|
||||
#if FLAG_BILLBOARD
|
||||
varying vec3 InstanceData0; // center
|
||||
varying vec4 InstanceData1; // size | sin cos
|
||||
varying vec4 InstanceData2; // color
|
||||
#else
|
||||
varying mat4 InstanceData0;
|
||||
#endif
|
||||
|
||||
varying vec3 VertexPosition;
|
||||
varying vec3 VertexNormal;
|
||||
varying vec3 VertexTangent;
|
||||
varying vec2 VertexTexCoord;
|
||||
|
||||
/********************Sortant********************/
|
||||
varying mat3 vLightToWorld;
|
||||
varying vec3 vNormal;
|
||||
varying vec2 vTexCoord;
|
||||
varying vec3 vWorldPos;
|
||||
varying vec4 vColor;
|
||||
|
||||
/********************Uniformes********************/
|
||||
uniform float VertexDepth;
|
||||
uniform mat4 ViewProjMatrix;
|
||||
uniform mat4 WorldMatrix;
|
||||
uniform mat4 WorldViewProjMatrix;
|
||||
|
||||
/********************Fonctions********************/
|
||||
void main()
|
||||
{
|
||||
#if FLAG_VERTEXCOLOR
|
||||
vec4 color = VertexColor;
|
||||
#else
|
||||
vec4 color = vec4(1.0);
|
||||
#endif
|
||||
vec2 texCoords;
|
||||
|
||||
#if FLAG_BILLBOARD
|
||||
#if FLAG_INSTANCING
|
||||
vec3 billboardCenter = InstanceData0;
|
||||
vec2 billboardSize = InstanceData1.xy;
|
||||
vec2 billboardSinCos = InstanceData1.zw;
|
||||
vec4 billboardColor = InstanceData2;
|
||||
|
||||
vec2 rotatedPosition;
|
||||
rotatedPosition.x = VertexPosition.x*billboardSinCos.y - VertexPosition.y*billboardSinCos.x;
|
||||
rotatedPosition.y = VertexPosition.y*billboardSinCos.y + VertexPosition.x*billboardSinCos.x;
|
||||
rotatedPosition *= billboardSize;
|
||||
|
||||
vec3 cameraRight = vec3(ViewMatrix[0][0], ViewMatrix[1][0], ViewMatrix[2][0]);
|
||||
vec3 cameraUp = vec3(ViewMatrix[0][1], ViewMatrix[1][1], ViewMatrix[2][1]);
|
||||
vec3 vertexPos = billboardCenter + cameraRight*rotatedPosition.x + cameraUp*rotatedPosition.y;
|
||||
|
||||
gl_Position = ViewProjMatrix * vec4(vertexPos, 1.0);
|
||||
color = billboardColor;
|
||||
texCoords = VertexPosition.xy + vec2(0.5, 0.5);
|
||||
#else
|
||||
vec2 billboardCorner = VertexTexCoord - vec2(0.5, 0.5);
|
||||
vec2 billboardSize = VertexUserdata0.xy;
|
||||
vec2 billboardSinCos = VertexUserdata0.zw;
|
||||
|
||||
vec2 rotatedPosition;
|
||||
rotatedPosition.x = billboardCorner.x*billboardSinCos.y - billboardCorner.y*billboardSinCos.x;
|
||||
rotatedPosition.y = billboardCorner.y*billboardSinCos.y + billboardCorner.x*billboardSinCos.x;
|
||||
rotatedPosition *= billboardSize;
|
||||
|
||||
vec3 cameraRight = vec3(ViewMatrix[0][0], ViewMatrix[1][0], ViewMatrix[2][0]);
|
||||
vec3 cameraUp = vec3(ViewMatrix[0][1], ViewMatrix[1][1], ViewMatrix[2][1]);
|
||||
vec3 vertexPos = VertexPosition + cameraRight*rotatedPosition.x + cameraUp*rotatedPosition.y;
|
||||
|
||||
gl_Position = ViewProjMatrix * vec4(vertexPos, 1.0);
|
||||
texCoords = VertexTexCoord;
|
||||
#endif
|
||||
#else
|
||||
#if FLAG_INSTANCING
|
||||
#if TRANSFORM
|
||||
gl_Position = ViewProjMatrix * InstanceData0 * vec4(VertexPosition, 1.0);
|
||||
#else
|
||||
#if UNIFORM_VERTEX_DEPTH
|
||||
gl_Position = InstanceData0 * vec4(VertexPosition.xy, VertexDepth, 1.0);
|
||||
#else
|
||||
gl_Position = InstanceData0 * vec4(VertexPosition, 1.0);
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
#if TRANSFORM
|
||||
gl_Position = WorldViewProjMatrix * vec4(VertexPosition, 1.0);
|
||||
#else
|
||||
#if UNIFORM_VERTEX_DEPTH
|
||||
gl_Position = vec4(VertexPosition.xy, VertexDepth, 1.0);
|
||||
#else
|
||||
gl_Position = vec4(VertexPosition, 1.0);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
texCoords = VertexTexCoord;
|
||||
#endif
|
||||
|
||||
vColor = color;
|
||||
|
||||
#if LIGHTING
|
||||
#if FLAG_INSTANCING
|
||||
mat3 rotationMatrix = mat3(InstanceData0[0].xyz, InstanceData0[1].xyz, InstanceData0[2].xyz);
|
||||
#else
|
||||
mat3 rotationMatrix = mat3(WorldMatrix[0].xyz, WorldMatrix[1].xyz, WorldMatrix[2].xyz);
|
||||
#endif
|
||||
|
||||
#if NORMAL_MAPPING
|
||||
vec3 binormal = cross(VertexNormal, VertexTangent);
|
||||
vLightToWorld[0] = normalize(rotationMatrix * VertexTangent);
|
||||
vLightToWorld[1] = normalize(rotationMatrix * binormal);
|
||||
vLightToWorld[2] = normalize(rotationMatrix * VertexNormal);
|
||||
#else
|
||||
vNormal = normalize(rotationMatrix * VertexNormal);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if TEXTURE_MAPPING
|
||||
vTexCoord = vec2(texCoords);
|
||||
#endif
|
||||
|
||||
#if LIGHTING && PARALLAX_MAPPING
|
||||
vViewDir = EyePosition - VertexPosition;
|
||||
vViewDir *= vLightToWorld;
|
||||
#endif
|
||||
|
||||
#if LIGHTING && !FLAG_DEFERRED
|
||||
#if FLAG_INSTANCING
|
||||
vWorldPos = vec3(InstanceData0 * vec4(VertexPosition, 1.0));
|
||||
#else
|
||||
vWorldPos = vec3(WorldMatrix * vec4(VertexPosition, 1.0));
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -11,20 +11,12 @@
|
|||
#include <stdexcept>
|
||||
#include <Nazara/Renderer/Debug.hpp>
|
||||
|
||||
NzGpuQuery::NzGpuQuery() :
|
||||
m_id(0)
|
||||
{
|
||||
if (IsSupported())
|
||||
NzGpuQuery::NzGpuQuery()
|
||||
{
|
||||
NzContext::EnsureContext();
|
||||
|
||||
m_id = 0;
|
||||
glGenQueries(1, reinterpret_cast<GLuint*>(&m_id));
|
||||
}
|
||||
else
|
||||
{
|
||||
NazaraError("Occlusion queries not supported");
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef NAZARA_DEBUG
|
||||
if (!m_id)
|
||||
|
|
@ -110,15 +102,13 @@ bool NzGpuQuery::IsModeSupported(nzGpuQueryMode mode)
|
|||
{
|
||||
switch (mode)
|
||||
{
|
||||
case nzGpuQueryMode_AnySamplesPassed:
|
||||
case nzGpuQueryMode_TimeElapsed:
|
||||
return NzOpenGL::GetVersion() >= 330;
|
||||
|
||||
case nzGpuQueryMode_AnySamplesPassedConservative:
|
||||
return NzOpenGL::GetVersion() >= 430;
|
||||
|
||||
case nzGpuQueryMode_AnySamplesPassed:
|
||||
case nzGpuQueryMode_PrimitiveGenerated:
|
||||
case nzGpuQueryMode_SamplesPassed:
|
||||
case nzGpuQueryMode_TimeElapsed:
|
||||
case nzGpuQueryMode_TransformFeedbackPrimitivesWritten:
|
||||
return true;
|
||||
}
|
||||
|
|
@ -126,8 +116,3 @@ bool NzGpuQuery::IsModeSupported(nzGpuQueryMode mode)
|
|||
NazaraError("Gpu Query mode not handled (0x" + NzString::Number(mode, 16) + ')');
|
||||
return false;
|
||||
}
|
||||
|
||||
bool NzGpuQuery::IsSupported()
|
||||
{
|
||||
return NzRenderer::HasCapability(nzRendererCap_OcclusionQuery);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -800,10 +800,10 @@ bool NzOpenGL::Initialize()
|
|||
|
||||
NazaraDebug("OpenGL version: " + NzString::Number(major) + '.' + NzString::Number(minor));
|
||||
|
||||
// Le moteur ne fonctionnera pas avec OpenGL 1.x, autant s'arrêter là si c'est le cas
|
||||
if (s_openglVersion < 200)
|
||||
// Le moteur nécessite OpenGL 3.3, autant s'arrêter là si ce n'est pas le cas
|
||||
if (s_openglVersion < 330)
|
||||
{
|
||||
NazaraError("OpenGL " + NzString::Number(major) + '.' + NzString::Number(minor) + " detected (2.0 required). Please upgrade your drivers or your video card");
|
||||
NazaraError("OpenGL " + NzString::Number(major) + '.' + NzString::Number(minor) + " detected (3.3 required). Please upgrade your drivers or your video card");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -832,10 +832,8 @@ bool NzOpenGL::Initialize()
|
|||
|
||||
s_glslVersion = major*100 + minor*10; // GLSL 3.3 => 330
|
||||
|
||||
// Possible uniquement dans le cas où le GLSL vient d'une extension d'OpenGL 1
|
||||
// Ce qui est rejeté il y a un moment déjà, mais on doit s'attendre à tout de la part d'un driver...
|
||||
// (Exemple: Un driver OpenGL 2 mais ne supportant que le GLSL 100)
|
||||
if (s_glslVersion < 110)
|
||||
// Normalement rejeté il y a un moment déjà, mais on doit s'attendre à tout de la part d'un driver...
|
||||
if (s_glslVersion < 330)
|
||||
{
|
||||
NazaraError("GLSL version is too low, please upgrade your drivers or your video card");
|
||||
return false;
|
||||
|
|
@ -857,18 +855,26 @@ bool NzOpenGL::Initialize()
|
|||
{
|
||||
glActiveTexture = reinterpret_cast<PFNGLACTIVETEXTUREPROC>(LoadEntry("glActiveTexture"));
|
||||
glAttachShader = reinterpret_cast<PFNGLATTACHSHADERPROC>(LoadEntry("glAttachShader"));
|
||||
glBeginConditionalRender = reinterpret_cast<PFNGLBEGINCONDITIONALRENDERPROC>(LoadEntry("glBeginConditionalRender"));
|
||||
glBeginQuery = reinterpret_cast<PFNGLBEGINQUERYPROC>(LoadEntry("glBeginQuery"));
|
||||
glBindAttribLocation = reinterpret_cast<PFNGLBINDATTRIBLOCATIONPROC>(LoadEntry("glBindAttribLocation"));
|
||||
glBindBuffer = reinterpret_cast<PFNGLBINDBUFFERPROC>(LoadEntry("glBindBuffer"));
|
||||
glBindFragDataLocation = reinterpret_cast<PFNGLBINDFRAGDATALOCATIONPROC>(LoadEntry("glBindFragDataLocation"));
|
||||
glBindFramebuffer = reinterpret_cast<PFNGLBINDFRAMEBUFFERPROC>(LoadEntry("glBindFramebuffer"));
|
||||
glBindRenderbuffer = reinterpret_cast<PFNGLBINDRENDERBUFFERPROC>(LoadEntry("glBindRenderbuffer"));
|
||||
glBindSampler = reinterpret_cast<PFNGLBINDSAMPLERPROC>(LoadEntry("glBindSampler"));
|
||||
glBindTexture = reinterpret_cast<PFNGLBINDTEXTUREPROC>(LoadEntry("glBindTexture"));
|
||||
glBindVertexArray = reinterpret_cast<PFNGLBINDVERTEXARRAYPROC>(LoadEntry("glBindVertexArray"));
|
||||
glBlendFunc = reinterpret_cast<PFNGLBLENDFUNCPROC>(LoadEntry("glBlendFunc"));
|
||||
glBlendFuncSeparate = reinterpret_cast<PFNGLBLENDFUNCSEPARATEPROC>(LoadEntry("glBlendFuncSeparate"));
|
||||
glBlitFramebuffer = reinterpret_cast<PFNGLBLITFRAMEBUFFERPROC>(LoadEntry("glBlitFramebuffer"));
|
||||
glBufferData = reinterpret_cast<PFNGLBUFFERDATAPROC>(LoadEntry("glBufferData"));
|
||||
glBufferSubData = reinterpret_cast<PFNGLBUFFERSUBDATAPROC>(LoadEntry("glBufferSubData"));
|
||||
glClear = reinterpret_cast<PFNGLCLEARPROC>(LoadEntry("glClear"));
|
||||
glClearColor = reinterpret_cast<PFNGLCLEARCOLORPROC>(LoadEntry("glClearColor"));
|
||||
glClearDepth = reinterpret_cast<PFNGLCLEARDEPTHPROC>(LoadEntry("glClearDepth"));
|
||||
glClearStencil = reinterpret_cast<PFNGLCLEARSTENCILPROC>(LoadEntry("glClearStencil"));
|
||||
glCheckFramebufferStatus = reinterpret_cast<PFNGLCHECKFRAMEBUFFERSTATUSPROC>(LoadEntry("glCheckFramebufferStatus"));
|
||||
glCreateProgram = reinterpret_cast<PFNGLCREATEPROGRAMPROC>(LoadEntry("glCreateProgram"));
|
||||
glCreateShader = reinterpret_cast<PFNGLCREATESHADERPROC>(LoadEntry("glCreateShader"));
|
||||
glColorMask = reinterpret_cast<PFNGLCOLORMASKPROC>(LoadEntry("glColorMask"));
|
||||
|
|
@ -876,25 +882,43 @@ bool NzOpenGL::Initialize()
|
|||
glCompileShader = reinterpret_cast<PFNGLCOMPILESHADERPROC>(LoadEntry("glCompileShader"));
|
||||
glCopyTexSubImage2D = reinterpret_cast<PFNGLCOPYTEXSUBIMAGE2DPROC>(LoadEntry("glCopyTexSubImage2D"));
|
||||
glDeleteBuffers = reinterpret_cast<PFNGLDELETEBUFFERSPROC>(LoadEntry("glDeleteBuffers"));
|
||||
glDeleteFramebuffers = reinterpret_cast<PFNGLDELETEFRAMEBUFFERSPROC>(LoadEntry("glDeleteFramebuffers"));
|
||||
glDeleteQueries = reinterpret_cast<PFNGLDELETEQUERIESPROC>(LoadEntry("glDeleteQueries"));
|
||||
glDeleteProgram = reinterpret_cast<PFNGLDELETEPROGRAMPROC>(LoadEntry("glDeleteProgram"));
|
||||
glDeleteRenderbuffers = reinterpret_cast<PFNGLDELETERENDERBUFFERSPROC>(LoadEntry("glDeleteRenderbuffers"));
|
||||
glDeleteSamplers = reinterpret_cast<PFNGLDELETESAMPLERSPROC>(LoadEntry("glDeleteSamplers"));
|
||||
glDeleteShader = reinterpret_cast<PFNGLDELETESHADERPROC>(LoadEntry("glDeleteShader"));
|
||||
glDeleteTextures = reinterpret_cast<PFNGLDELETETEXTURESPROC>(LoadEntry("glDeleteTextures"));
|
||||
glDeleteVertexArrays = reinterpret_cast<PFNGLDELETEVERTEXARRAYSPROC>(LoadEntry("glDeleteVertexArrays"));
|
||||
glDepthFunc = reinterpret_cast<PFNGLDEPTHFUNCPROC>(LoadEntry("glDepthFunc"));
|
||||
glDepthMask = reinterpret_cast<PFNGLDEPTHMASKPROC>(LoadEntry("glDepthMask"));
|
||||
glDisable = reinterpret_cast<PFNGLDISABLEPROC>(LoadEntry("glDisable"));
|
||||
glDisableVertexAttribArray = reinterpret_cast<PFNGLDISABLEVERTEXATTRIBARRAYPROC>(LoadEntry("glDisableVertexAttribArray"));
|
||||
glDrawArrays = reinterpret_cast<PFNGLDRAWARRAYSPROC>(LoadEntry("glDrawArrays"));
|
||||
glDrawArraysInstanced = reinterpret_cast<PFNGLDRAWARRAYSINSTANCEDPROC>(LoadEntry("glDrawArraysInstanced"));
|
||||
glDrawBuffer = reinterpret_cast<PFNGLDRAWBUFFERPROC>(LoadEntry("glDrawBuffer"));
|
||||
glDrawBuffers = reinterpret_cast<PFNGLDRAWBUFFERSPROC>(LoadEntry("glDrawBuffers"));
|
||||
glDrawElements = reinterpret_cast<PFNGLDRAWELEMENTSPROC>(LoadEntry("glDrawElements"));
|
||||
glDrawElementsInstanced = reinterpret_cast<PFNGLDRAWELEMENTSINSTANCEDPROC>(LoadEntry("glDrawElementsInstanced"));
|
||||
glEnable = reinterpret_cast<PFNGLENABLEPROC>(LoadEntry("glEnable"));
|
||||
glEnableVertexAttribArray = reinterpret_cast<PFNGLENABLEVERTEXATTRIBARRAYPROC>(LoadEntry("glEnableVertexAttribArray"));
|
||||
glEndConditionalRender = reinterpret_cast<PFNGLENDCONDITIONALRENDERPROC>(LoadEntry("glEndConditionalRender"));
|
||||
glEndQuery = reinterpret_cast<PFNGLENDQUERYPROC>(LoadEntry("glEndQuery"));
|
||||
glFlush = reinterpret_cast<PFNGLFLUSHPROC>(LoadEntry("glFlush"));
|
||||
glFramebufferRenderbuffer = reinterpret_cast<PFNGLFRAMEBUFFERRENDERBUFFERPROC>(LoadEntry("glFramebufferRenderbuffer"));
|
||||
glFramebufferTexture = reinterpret_cast<PFNGLFRAMEBUFFERTEXTUREPROC>(LoadEntry("glFramebufferTexture"));
|
||||
glFramebufferTexture1D = reinterpret_cast<PFNGLFRAMEBUFFERTEXTURE1DPROC>(LoadEntry("glFramebufferTexture1D"));
|
||||
glFramebufferTexture2D = reinterpret_cast<PFNGLFRAMEBUFFERTEXTURE2DPROC>(LoadEntry("glFramebufferTexture2D"));
|
||||
glFramebufferTexture3D = reinterpret_cast<PFNGLFRAMEBUFFERTEXTURE3DPROC>(LoadEntry("glFramebufferTexture3D"));
|
||||
glFramebufferTextureLayer = reinterpret_cast<PFNGLFRAMEBUFFERTEXTURELAYERPROC>(LoadEntry("glFramebufferTextureLayer"));
|
||||
glGenerateMipmap = reinterpret_cast<PFNGLGENERATEMIPMAPPROC>(LoadEntry("glGenerateMipmap"));
|
||||
glGenBuffers = reinterpret_cast<PFNGLGENBUFFERSPROC>(LoadEntry("glGenBuffers"));
|
||||
glGenFramebuffers = reinterpret_cast<PFNGLGENFRAMEBUFFERSPROC>(LoadEntry("glGenFramebuffers"));
|
||||
glGenQueries = reinterpret_cast<PFNGLGENQUERIESPROC>(LoadEntry("glGenQueries"));
|
||||
glGenRenderbuffers = reinterpret_cast<PFNGLGENRENDERBUFFERSPROC>(LoadEntry("glGenRenderbuffers"));
|
||||
glGenSamplers = reinterpret_cast<PFNGLGENSAMPLERSPROC>(LoadEntry("glGenSamplers"));
|
||||
glGenTextures = reinterpret_cast<PFNGLGENTEXTURESPROC>(LoadEntry("glGenTextures"));
|
||||
glGenVertexArrays = reinterpret_cast<PFNGLGENVERTEXARRAYSPROC>(LoadEntry("glGenVertexArrays"));
|
||||
glGetActiveUniform = reinterpret_cast<PFNGLGETACTIVEUNIFORMPROC>(LoadEntry("glGetActiveUniform"));
|
||||
glGetBooleanv = reinterpret_cast<PFNGLGETBOOLEANVPROC>(LoadEntry("glGetBooleanv"));
|
||||
glGetBufferParameteriv = reinterpret_cast<PFNGLGETBUFFERPARAMETERIVPROC>(LoadEntry("glGetBufferParameteriv"));
|
||||
|
|
@ -909,6 +933,7 @@ bool NzOpenGL::Initialize()
|
|||
glGetShaderInfoLog = reinterpret_cast<PFNGLGETSHADERINFOLOGPROC>(LoadEntry("glGetShaderInfoLog"));
|
||||
glGetShaderiv = reinterpret_cast<PFNGLGETSHADERIVPROC>(LoadEntry("glGetShaderiv"));
|
||||
glGetShaderSource = reinterpret_cast<PFNGLGETSHADERSOURCEPROC>(LoadEntry("glGetShaderSource"));
|
||||
glGetStringi = reinterpret_cast<PFNGLGETSTRINGIPROC>(LoadEntry("glGetStringi"));
|
||||
glGetTexImage = reinterpret_cast<PFNGLGETTEXIMAGEPROC>(LoadEntry("glGetTexImage"));
|
||||
glGetTexLevelParameterfv = reinterpret_cast<PFNGLGETTEXLEVELPARAMETERFVPROC>(LoadEntry("glGetTexLevelParameterfv"));
|
||||
glGetTexLevelParameteriv = reinterpret_cast<PFNGLGETTEXLEVELPARAMETERIVPROC>(LoadEntry("glGetTexLevelParameteriv"));
|
||||
|
|
@ -919,10 +944,14 @@ bool NzOpenGL::Initialize()
|
|||
glLineWidth = reinterpret_cast<PFNGLLINEWIDTHPROC>(LoadEntry("glLineWidth"));
|
||||
glLinkProgram = reinterpret_cast<PFNGLLINKPROGRAMPROC>(LoadEntry("glLinkProgram"));
|
||||
glMapBuffer = reinterpret_cast<PFNGLMAPBUFFERPROC>(LoadEntry("glMapBuffer"));
|
||||
glMapBufferRange = reinterpret_cast<PFNGLMAPBUFFERRANGEPROC>(LoadEntry("glMapBufferRange"));
|
||||
glPixelStorei = reinterpret_cast<PFNGLPIXELSTOREIPROC>(LoadEntry("glPixelStorei"));
|
||||
glPointSize = reinterpret_cast<PFNGLPOINTSIZEPROC>(LoadEntry("glPointSize"));
|
||||
glPolygonMode = reinterpret_cast<PFNGLPOLYGONMODEPROC>(LoadEntry("glPolygonMode"));
|
||||
glReadPixels = reinterpret_cast<PFNGLREADPIXELSPROC>(LoadEntry("glReadPixels"));
|
||||
glRenderbufferStorage = reinterpret_cast<PFNGLRENDERBUFFERSTORAGEPROC>(LoadEntry("glRenderbufferStorage"));
|
||||
glSamplerParameterf = reinterpret_cast<PFNGLSAMPLERPARAMETERFPROC>(LoadEntry("glSamplerParameterf"));
|
||||
glSamplerParameteri = reinterpret_cast<PFNGLSAMPLERPARAMETERIPROC>(LoadEntry("glSamplerParameteri"));
|
||||
glScissor = reinterpret_cast<PFNGLSCISSORPROC>(LoadEntry("glScissor"));
|
||||
glShaderSource = reinterpret_cast<PFNGLSHADERSOURCEPROC>(LoadEntry("glShaderSource"));
|
||||
glStencilFunc = reinterpret_cast<PFNGLSTENCILFUNCPROC>(LoadEntry("glStencilFunc"));
|
||||
|
|
@ -949,7 +978,9 @@ bool NzOpenGL::Initialize()
|
|||
glUnmapBuffer = reinterpret_cast<PFNGLUNMAPBUFFERPROC>(LoadEntry("glUnmapBuffer"));
|
||||
glUseProgram = reinterpret_cast<PFNGLUSEPROGRAMPROC>(LoadEntry("glUseProgram"));
|
||||
glVertexAttrib4f = reinterpret_cast<PFNGLVERTEXATTRIB4FPROC>(LoadEntry("glVertexAttrib4f"));
|
||||
glVertexAttribDivisor = reinterpret_cast<PFNGLVERTEXATTRIBDIVISORPROC>(LoadEntry("glVertexAttribDivisor"));
|
||||
glVertexAttribPointer = reinterpret_cast<PFNGLVERTEXATTRIBPOINTERPROC>(LoadEntry("glVertexAttribPointer"));
|
||||
glVertexAttribIPointer = reinterpret_cast<PFNGLVERTEXATTRIBIPOINTERPROC>(LoadEntry("glVertexAttribIPointer"));
|
||||
glViewport = reinterpret_cast<PFNGLVIEWPORTPROC>(LoadEntry("glViewport"));
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
|
|
@ -961,16 +992,10 @@ bool NzOpenGL::Initialize()
|
|||
/****************************************Extensions****************************************/
|
||||
|
||||
// Fonctions optionnelles
|
||||
glBindFragDataLocation = reinterpret_cast<PFNGLBINDFRAGDATALOCATIONPROC>(LoadEntry("glBindFragDataLocation", false));
|
||||
if (!glBindFragDataLocation)
|
||||
glBindFragDataLocation = reinterpret_cast<PFNGLBINDFRAGDATALOCATIONEXTPROC>(LoadEntry("glBindFragDataLocationEXT", false));
|
||||
glBindFragDataLocation = reinterpret_cast<PFNGLBINDFRAGDATALOCATIONPROC>(LoadEntry("glBindFragDataLocation"));
|
||||
|
||||
glDrawTexture = reinterpret_cast<PFNGLDRAWTEXTURENVPROC>(LoadEntry("glDrawTextureNV", false));
|
||||
glFramebufferTexture = reinterpret_cast<PFNGLFRAMEBUFFERTEXTUREPROC>(LoadEntry("glFramebufferTexture", false));
|
||||
glGetStringi = reinterpret_cast<PFNGLGETSTRINGIPROC>(LoadEntry("glGetStringi", false));
|
||||
glInvalidateBufferData = reinterpret_cast<PFNGLINVALIDATEBUFFERDATAPROC>(LoadEntry("glInvalidateBufferData", false));
|
||||
glMapBufferRange = reinterpret_cast<PFNGLMAPBUFFERRANGEPROC>(LoadEntry("glMapBufferRange", false));
|
||||
glVertexAttribIPointer = reinterpret_cast<PFNGLVERTEXATTRIBIPOINTERPROC>(LoadEntry("glVertexAttribIPointer", false));
|
||||
glVertexAttribLPointer = reinterpret_cast<PFNGLVERTEXATTRIBLPOINTERPROC>(LoadEntry("glVertexAttribLPointer", false));
|
||||
|
||||
#if defined(NAZARA_PLATFORM_WINDOWS)
|
||||
|
|
@ -985,8 +1010,7 @@ bool NzOpenGL::Initialize()
|
|||
|
||||
if (!glGetStringi || !LoadExtensions3())
|
||||
{
|
||||
if (s_openglVersion >= 300) // Dans le cas contraire c'est normal
|
||||
NazaraWarning("Failed to load OpenGL 3 extension system, switching to OpenGL 2 extension system...");
|
||||
NazaraWarning("Failed to load OpenGL 3 extension system, falling back to OpenGL 2 extension system...");
|
||||
|
||||
if (!LoadExtensionsString(reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS))))
|
||||
NazaraWarning("Failed to load extension system");
|
||||
|
|
@ -1010,37 +1034,6 @@ bool NzOpenGL::Initialize()
|
|||
// AnisotropicFilter
|
||||
s_openGLextensions[nzOpenGLExtension_AnisotropicFilter] = IsSupported("GL_EXT_texture_filter_anisotropic");
|
||||
|
||||
// ConditionalRender
|
||||
if (s_openglVersion >= 300)
|
||||
{
|
||||
try
|
||||
{
|
||||
glBeginConditionalRender = reinterpret_cast<PFNGLBEGINCONDITIONALRENDERPROC>(LoadEntry("glBeginConditionalRender"));
|
||||
glEndConditionalRender = reinterpret_cast<PFNGLENDCONDITIONALRENDERPROC>(LoadEntry("glEndConditionalRender"));
|
||||
|
||||
s_openGLextensions[nzOpenGLExtension_ConditionalRender] = true;
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
NazaraWarning("Failed to load Conditional Render: " + NzString(e.what()));
|
||||
}
|
||||
}
|
||||
|
||||
if (!s_openGLextensions[nzOpenGLExtension_ConditionalRender] && IsSupported("GL_NV_conditional_render"))
|
||||
{
|
||||
try
|
||||
{
|
||||
glBeginConditionalRender = reinterpret_cast<PFNGLBEGINCONDITIONALRENDERPROC>(LoadEntry("glBeginConditionalRenderNV"));
|
||||
glEndConditionalRender = reinterpret_cast<PFNGLENDCONDITIONALRENDERPROC>(LoadEntry("glEndConditionalRenderNV"));
|
||||
|
||||
s_openGLextensions[nzOpenGLExtension_ConditionalRender] = true;
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
NazaraWarning("Failed to load GL_NV_conditional_render: " + NzString(e.what()));
|
||||
}
|
||||
}
|
||||
|
||||
// DebugOutput
|
||||
if (s_openglVersion >= 430 || IsSupported("GL_KHR_debug"))
|
||||
{
|
||||
|
|
@ -1076,37 +1069,6 @@ bool NzOpenGL::Initialize()
|
|||
}
|
||||
}
|
||||
|
||||
// DrawInstanced
|
||||
if (s_openglVersion >= 310)
|
||||
{
|
||||
try
|
||||
{
|
||||
glDrawArraysInstanced = reinterpret_cast<PFNGLDRAWARRAYSINSTANCEDPROC>(LoadEntry("glDrawArraysInstanced"));
|
||||
glDrawElementsInstanced = reinterpret_cast<PFNGLDRAWELEMENTSINSTANCEDPROC>(LoadEntry("glDrawElementsInstanced"));
|
||||
|
||||
s_openGLextensions[nzOpenGLExtension_DrawInstanced] = true;
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
NazaraWarning("Failed to load Draw Instanced: " + NzString(e.what()));
|
||||
}
|
||||
}
|
||||
|
||||
if (!s_openGLextensions[nzOpenGLExtension_DrawInstanced] && IsSupported("GL_ARB_draw_instanced"))
|
||||
{
|
||||
try
|
||||
{
|
||||
glDrawArraysInstanced = reinterpret_cast<PFNGLDRAWARRAYSINSTANCEDARBPROC>(LoadEntry("glDrawArraysInstancedARB"));
|
||||
glDrawElementsInstanced = reinterpret_cast<PFNGLDRAWELEMENTSINSTANCEDARBPROC>(LoadEntry("glDrawElementsInstancedARB"));
|
||||
|
||||
s_openGLextensions[nzOpenGLExtension_DrawInstanced] = true;
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
NazaraWarning("Failed to load GL_ARB_draw_instanced: " + NzString(e.what()));
|
||||
}
|
||||
}
|
||||
|
||||
// FP64
|
||||
if (s_openglVersion >= 400 || IsSupported("GL_ARB_gpu_shader_fp64"))
|
||||
{
|
||||
|
|
@ -1126,35 +1088,6 @@ bool NzOpenGL::Initialize()
|
|||
}
|
||||
}
|
||||
|
||||
// FrameBufferObject
|
||||
if (s_openglVersion >= 300 || IsSupported("GL_ARB_framebuffer_object"))
|
||||
{
|
||||
try
|
||||
{
|
||||
glBindFramebuffer = reinterpret_cast<PFNGLBINDFRAMEBUFFERPROC>(LoadEntry("glBindFramebuffer"));
|
||||
glBindRenderbuffer = reinterpret_cast<PFNGLBINDRENDERBUFFERPROC>(LoadEntry("glBindRenderbuffer"));
|
||||
glBlitFramebuffer = reinterpret_cast<PFNGLBLITFRAMEBUFFERPROC>(LoadEntry("glBlitFramebuffer"));
|
||||
glCheckFramebufferStatus = reinterpret_cast<PFNGLCHECKFRAMEBUFFERSTATUSPROC>(LoadEntry("glCheckFramebufferStatus"));
|
||||
glDeleteFramebuffers = reinterpret_cast<PFNGLDELETEFRAMEBUFFERSPROC>(LoadEntry("glDeleteFramebuffers"));
|
||||
glDeleteRenderbuffers = reinterpret_cast<PFNGLDELETERENDERBUFFERSPROC>(LoadEntry("glDeleteRenderbuffers"));
|
||||
glFramebufferRenderbuffer = reinterpret_cast<PFNGLFRAMEBUFFERRENDERBUFFERPROC>(LoadEntry("glFramebufferRenderbuffer"));
|
||||
glFramebufferTexture1D = reinterpret_cast<PFNGLFRAMEBUFFERTEXTURE1DPROC>(LoadEntry("glFramebufferTexture1D"));
|
||||
glFramebufferTexture2D = reinterpret_cast<PFNGLFRAMEBUFFERTEXTURE2DPROC>(LoadEntry("glFramebufferTexture2D"));
|
||||
glFramebufferTexture3D = reinterpret_cast<PFNGLFRAMEBUFFERTEXTURE3DPROC>(LoadEntry("glFramebufferTexture3D"));
|
||||
glFramebufferTextureLayer = reinterpret_cast<PFNGLFRAMEBUFFERTEXTURELAYERPROC>(LoadEntry("glFramebufferTextureLayer"));
|
||||
glGenerateMipmap = reinterpret_cast<PFNGLGENERATEMIPMAPPROC>(LoadEntry("glGenerateMipmap"));
|
||||
glGenFramebuffers = reinterpret_cast<PFNGLGENFRAMEBUFFERSPROC>(LoadEntry("glGenFramebuffers"));
|
||||
glGenRenderbuffers = reinterpret_cast<PFNGLGENRENDERBUFFERSPROC>(LoadEntry("glGenRenderbuffers"));
|
||||
glRenderbufferStorage = reinterpret_cast<PFNGLRENDERBUFFERSTORAGEPROC>(LoadEntry("glRenderbufferStorage"));
|
||||
|
||||
s_openGLextensions[nzOpenGLExtension_FrameBufferObject] = true;
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
NazaraWarning("Failed to load ARB_framebuffer_object: (" + NzString(e.what()) + ")");
|
||||
}
|
||||
}
|
||||
|
||||
// GetProgramBinary
|
||||
if (s_openglVersion >= 410 || IsSupported("GL_ARB_get_program_binary"))
|
||||
{
|
||||
|
|
@ -1172,57 +1105,6 @@ bool NzOpenGL::Initialize()
|
|||
}
|
||||
}
|
||||
|
||||
// InstancedArray
|
||||
if (s_openglVersion >= 330)
|
||||
{
|
||||
try
|
||||
{
|
||||
glVertexAttribDivisor = reinterpret_cast<PFNGLVERTEXATTRIBDIVISORPROC>(LoadEntry("glVertexAttribDivisor"));
|
||||
|
||||
s_openGLextensions[nzOpenGLExtension_InstancedArray] = true;
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
NazaraWarning("Failed to load Instanced Array: " + NzString(e.what()));
|
||||
}
|
||||
}
|
||||
|
||||
if (!s_openGLextensions[nzOpenGLExtension_InstancedArray] && IsSupported("GL_ARB_instanced_arrays"))
|
||||
{
|
||||
try
|
||||
{
|
||||
glVertexAttribDivisor = reinterpret_cast<PFNGLVERTEXATTRIBDIVISORARBPROC>(LoadEntry("glVertexAttribDivisorARB"));
|
||||
|
||||
s_openGLextensions[nzOpenGLExtension_InstancedArray] = true;
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
NazaraWarning("Failed to load GL_ARB_instanced_arrays: " + NzString(e.what()));
|
||||
}
|
||||
}
|
||||
|
||||
// PixelBufferObject
|
||||
s_openGLextensions[nzOpenGLExtension_PixelBufferObject] = (s_openglVersion >= 210 || IsSupported("GL_ARB_pixel_buffer_object"));
|
||||
|
||||
// SamplerObjects
|
||||
if (s_openglVersion >= 330 || IsSupported("GL_ARB_sampler_objects"))
|
||||
{
|
||||
try
|
||||
{
|
||||
glBindSampler = reinterpret_cast<PFNGLBINDSAMPLERPROC>(LoadEntry("glBindSampler"));
|
||||
glDeleteSamplers = reinterpret_cast<PFNGLDELETESAMPLERSPROC>(LoadEntry("glDeleteSamplers"));
|
||||
glGenSamplers = reinterpret_cast<PFNGLGENSAMPLERSPROC>(LoadEntry("glGenSamplers"));
|
||||
glSamplerParameterf = reinterpret_cast<PFNGLSAMPLERPARAMETERFPROC>(LoadEntry("glSamplerParameterf"));
|
||||
glSamplerParameteri = reinterpret_cast<PFNGLSAMPLERPARAMETERIPROC>(LoadEntry("glSamplerParameteri"));
|
||||
|
||||
s_openGLextensions[nzOpenGLExtension_SamplerObjects] = true;
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
NazaraWarning("Failed to load ARB_sampler_objects: (" + NzString(e.what()) + ")");
|
||||
}
|
||||
}
|
||||
|
||||
// SeparateShaderObjects
|
||||
if (s_openglVersion >= 400 || IsSupported("GL_ARB_separate_shader_objects"))
|
||||
{
|
||||
|
|
@ -1262,9 +1144,6 @@ bool NzOpenGL::Initialize()
|
|||
// Shader_ImageLoadStore
|
||||
s_openGLextensions[nzOpenGLExtension_Shader_ImageLoadStore] = (s_openglVersion >= 420 || IsSupported("GL_ARB_shader_image_load_store"));
|
||||
|
||||
// TextureArray
|
||||
s_openGLextensions[nzOpenGLExtension_TextureArray] = (s_openglVersion >= 300 || IsSupported("GL_EXT_texture_array"));
|
||||
|
||||
// TextureCompression_s3tc
|
||||
s_openGLextensions[nzOpenGLExtension_TextureCompression_s3tc] = IsSupported("GL_EXT_texture_compression_s3tc");
|
||||
|
||||
|
|
@ -1285,27 +1164,6 @@ bool NzOpenGL::Initialize()
|
|||
}
|
||||
}
|
||||
|
||||
// VertexArrayObject
|
||||
if (s_openglVersion >= 300 || IsSupported("GL_ARB_vertex_array_object"))
|
||||
{
|
||||
try
|
||||
{
|
||||
glBindVertexArray = reinterpret_cast<PFNGLBINDVERTEXARRAYPROC>(LoadEntry("glBindVertexArray"));
|
||||
glDeleteVertexArrays = reinterpret_cast<PFNGLDELETEVERTEXARRAYSPROC>(LoadEntry("glDeleteVertexArrays"));
|
||||
glGenVertexArrays = reinterpret_cast<PFNGLGENVERTEXARRAYSPROC>(LoadEntry("glGenVertexArrays"));
|
||||
|
||||
s_openGLextensions[nzOpenGLExtension_VertexArrayObjects] = true;
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
NazaraWarning("Failed to load ARB_vertex_array_object: " + NzString(e.what()));
|
||||
}
|
||||
}
|
||||
|
||||
// Fonctions de substitut
|
||||
if (!glGenerateMipmap)
|
||||
glGenerateMipmap = reinterpret_cast<PFNGLGENERATEMIPMAPEXTPROC>(LoadEntry("glGenerateMipmapEXT", false));
|
||||
|
||||
/******************************Initialisation*****************************/
|
||||
|
||||
s_contextStates = nullptr;
|
||||
|
|
|
|||
|
|
@ -111,11 +111,6 @@ bool NzRenderBuffer::IsValid() const
|
|||
return m_id != 0;
|
||||
}
|
||||
|
||||
bool NzRenderBuffer::IsSupported()
|
||||
{
|
||||
return NzOpenGL::IsSupported(nzOpenGLExtension_FrameBufferObject);
|
||||
}
|
||||
|
||||
bool NzRenderBuffer::Initialize()
|
||||
{
|
||||
if (!NzRenderBufferLibrary::Initialize())
|
||||
|
|
|
|||
|
|
@ -299,12 +299,6 @@ bool NzRenderTexture::AttachTexture(nzAttachmentPoint attachmentPoint, nzUInt8 i
|
|||
|
||||
bool NzRenderTexture::Create(bool lock)
|
||||
{
|
||||
if (!IsSupported())
|
||||
{
|
||||
NazaraError("Render textures not supported");
|
||||
return false;
|
||||
}
|
||||
|
||||
Destroy();
|
||||
|
||||
#if NAZARA_RENDERER_SAFE
|
||||
|
|
@ -655,11 +649,6 @@ bool NzRenderTexture::HasContext() const
|
|||
return false;
|
||||
}
|
||||
|
||||
bool NzRenderTexture::IsSupported()
|
||||
{
|
||||
return NzOpenGL::IsSupported(nzOpenGLExtension_FrameBufferObject);
|
||||
}
|
||||
|
||||
void NzRenderTexture::Blit(NzRenderTexture* src, NzRectui srcRect, NzRenderTexture* dst, NzRectui dstRect, nzUInt32 buffers, bool bilinearFilter)
|
||||
{
|
||||
NazaraAssert(src && src->IsValid(), "Invalid source render texture");
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@
|
|||
#include <vector>
|
||||
#include <Nazara/Renderer/Debug.hpp>
|
||||
|
||||
///TODO: Manager les VAO (permettre plusieurs draw calls sans rebinder le VAO)
|
||||
|
||||
namespace
|
||||
{
|
||||
const nzUInt8 r_coreFragmentShader[] = {
|
||||
|
|
@ -43,14 +45,6 @@ namespace
|
|||
#include <Nazara/Renderer/Resources/Shaders/Debug/core.vert.h>
|
||||
};
|
||||
|
||||
const nzUInt8 r_compatibilityFragmentShader[] = {
|
||||
#include <Nazara/Renderer/Resources/Shaders/Debug/compatibility.frag.h>
|
||||
};
|
||||
|
||||
const nzUInt8 r_compatibilityVertexShader[] = {
|
||||
#include <Nazara/Renderer/Resources/Shaders/Debug/compatibility.vert.h>
|
||||
};
|
||||
|
||||
enum ObjectType
|
||||
{
|
||||
ObjectType_Context,
|
||||
|
|
@ -122,8 +116,6 @@ namespace
|
|||
const NzVertexBuffer* s_vertexBuffer;
|
||||
bool s_capabilities[nzRendererCap_Max+1];
|
||||
bool s_instancing;
|
||||
bool s_useSamplerObjects;
|
||||
bool s_useVertexArrayObjects;
|
||||
unsigned int s_maxColorAttachments;
|
||||
unsigned int s_maxRenderTarget;
|
||||
unsigned int s_maxTextureSize;
|
||||
|
|
@ -141,14 +133,6 @@ void NzRenderer::BeginCondition(const NzGpuQuery& query, nzGpuQueryCondition con
|
|||
}
|
||||
#endif
|
||||
|
||||
#if NAZARA_RENDERER_SAFE
|
||||
if (!s_capabilities[nzRendererCap_ConditionalRendering])
|
||||
{
|
||||
NazaraError("Conditional rendering is not supported");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
glBeginConditionalRender(query.GetOpenGLID(), NzOpenGL::QueryCondition[condition]);
|
||||
}
|
||||
|
||||
|
|
@ -205,8 +189,6 @@ void NzRenderer::DrawFullscreenQuad()
|
|||
}
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
|
||||
if (s_useVertexArrayObjects)
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
||||
|
|
@ -257,8 +239,6 @@ void NzRenderer::DrawIndexedPrimitives(nzPrimitiveMode mode, unsigned int firstI
|
|||
}
|
||||
|
||||
glDrawElements(NzOpenGL::PrimitiveMode[mode], indexCount, type, offset);
|
||||
|
||||
if (s_useVertexArrayObjects)
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
||||
|
|
@ -279,12 +259,6 @@ void NzRenderer::DrawIndexedPrimitivesInstanced(unsigned int instanceCount, nzPr
|
|||
#endif
|
||||
|
||||
#if NAZARA_RENDERER_SAFE
|
||||
if (!s_capabilities[nzRendererCap_Instancing])
|
||||
{
|
||||
NazaraError("Instancing not supported");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!s_indexBuffer)
|
||||
{
|
||||
NazaraError("No index buffer");
|
||||
|
|
@ -328,8 +302,6 @@ void NzRenderer::DrawIndexedPrimitivesInstanced(unsigned int instanceCount, nzPr
|
|||
}
|
||||
|
||||
glDrawElementsInstanced(NzOpenGL::PrimitiveMode[mode], indexCount, type, offset, instanceCount);
|
||||
|
||||
if (s_useVertexArrayObjects)
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
||||
|
|
@ -358,8 +330,6 @@ void NzRenderer::DrawPrimitives(nzPrimitiveMode mode, unsigned int firstVertex,
|
|||
}
|
||||
|
||||
glDrawArrays(NzOpenGL::PrimitiveMode[mode], firstVertex, vertexCount);
|
||||
|
||||
if (s_useVertexArrayObjects)
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
||||
|
|
@ -380,12 +350,6 @@ void NzRenderer::DrawPrimitivesInstanced(unsigned int instanceCount, nzPrimitive
|
|||
#endif
|
||||
|
||||
#if NAZARA_RENDERER_SAFE
|
||||
if (!s_capabilities[nzRendererCap_Instancing])
|
||||
{
|
||||
NazaraError("Instancing not supported");
|
||||
return;
|
||||
}
|
||||
|
||||
if (instanceCount == 0)
|
||||
{
|
||||
NazaraError("Instance count must be over zero");
|
||||
|
|
@ -409,8 +373,6 @@ void NzRenderer::DrawPrimitivesInstanced(unsigned int instanceCount, nzPrimitive
|
|||
}
|
||||
|
||||
glDrawArraysInstanced(NzOpenGL::PrimitiveMode[mode], firstVertex, vertexCount, instanceCount);
|
||||
|
||||
if (s_useVertexArrayObjects)
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
||||
|
|
@ -443,14 +405,6 @@ void NzRenderer::EndCondition()
|
|||
}
|
||||
#endif
|
||||
|
||||
#if NAZARA_RENDERER_SAFE
|
||||
if (!s_capabilities[nzRendererCap_ConditionalRendering])
|
||||
{
|
||||
NazaraError("Conditional rendering is not supported");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
glEndConditionalRender();
|
||||
}
|
||||
|
||||
|
|
@ -474,14 +428,6 @@ nzRendererComparison NzRenderer::GetDepthFunc()
|
|||
|
||||
NzVertexBuffer* NzRenderer::GetInstanceBuffer()
|
||||
{
|
||||
#if NAZARA_RENDERER_SAFE
|
||||
if (!s_capabilities[nzRendererCap_Instancing])
|
||||
{
|
||||
NazaraError("Instancing not supported");
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
s_updateFlags |= Update_VAO;
|
||||
return &s_instanceBuffer;
|
||||
}
|
||||
|
|
@ -630,18 +576,8 @@ bool NzRenderer::Initialize()
|
|||
|
||||
// Récupération des capacités d'OpenGL
|
||||
s_capabilities[nzRendererCap_AnisotropicFilter] = NzOpenGL::IsSupported(nzOpenGLExtension_AnisotropicFilter);
|
||||
s_capabilities[nzRendererCap_ConditionalRendering] = NzOpenGL::IsSupported(nzOpenGLExtension_ConditionalRender);
|
||||
s_capabilities[nzRendererCap_FP64] = NzOpenGL::IsSupported(nzOpenGLExtension_FP64);
|
||||
s_capabilities[nzRendererCap_HardwareBuffer] = true; // Natif depuis OpenGL 1.5
|
||||
s_capabilities[nzRendererCap_Instancing] = NzOpenGL::IsSupported(nzOpenGLExtension_DrawInstanced) && NzOpenGL::IsSupported(nzOpenGLExtension_InstancedArray);
|
||||
s_capabilities[nzRendererCap_MultipleRenderTargets] = (glBindFragDataLocation != nullptr); // Natif depuis OpenGL 2.0 mais inutile sans glBindFragDataLocation
|
||||
s_capabilities[nzRendererCap_OcclusionQuery] = true; // Natif depuis OpenGL 1.5
|
||||
s_capabilities[nzRendererCap_PixelBufferObject] = NzOpenGL::IsSupported(nzOpenGLExtension_PixelBufferObject);
|
||||
s_capabilities[nzRendererCap_RenderTexture] = NzOpenGL::IsSupported(nzOpenGLExtension_FrameBufferObject);
|
||||
s_capabilities[nzRendererCap_Texture3D] = true; // Natif depuis OpenGL 1.2
|
||||
s_capabilities[nzRendererCap_TextureCubemap] = true; // Natif depuis OpenGL 1.3
|
||||
s_capabilities[nzRendererCap_TextureMulti] = true; // Natif depuis OpenGL 1.3
|
||||
s_capabilities[nzRendererCap_TextureNPOT] = true; // Natif depuis OpenGL 2.0
|
||||
s_capabilities[nzRendererCap_Instancing] = true; // Supporté par OpenGL 3.3
|
||||
|
||||
NzContext::EnsureContext();
|
||||
|
||||
|
|
@ -655,39 +591,21 @@ bool NzRenderer::Initialize()
|
|||
else
|
||||
s_maxAnisotropyLevel = 1;
|
||||
|
||||
if (s_capabilities[nzRendererCap_RenderTexture])
|
||||
{
|
||||
GLint maxColorAttachments;
|
||||
glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &maxColorAttachments);
|
||||
|
||||
s_maxColorAttachments = static_cast<unsigned int>(maxColorAttachments);
|
||||
}
|
||||
else
|
||||
s_maxColorAttachments = 1;
|
||||
|
||||
if (s_capabilities[nzRendererCap_MultipleRenderTargets])
|
||||
{
|
||||
GLint maxDrawBuffers;
|
||||
glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
|
||||
|
||||
s_maxRenderTarget = static_cast<unsigned int>(maxDrawBuffers);
|
||||
}
|
||||
else
|
||||
s_maxRenderTarget = 1;
|
||||
|
||||
if (s_capabilities[nzRendererCap_TextureMulti])
|
||||
{
|
||||
GLint maxTextureUnits;
|
||||
glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxTextureUnits);
|
||||
|
||||
s_maxTextureUnit = static_cast<unsigned int>(maxTextureUnits);
|
||||
}
|
||||
else
|
||||
s_maxTextureUnit = 1;
|
||||
|
||||
GLint maxTextureSize;
|
||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
|
||||
s_maxTextureSize = maxTextureSize;
|
||||
s_maxTextureSize = static_cast<unsigned int>(maxTextureSize);
|
||||
|
||||
GLint maxVertexAttribs;
|
||||
glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs);
|
||||
|
|
@ -700,8 +618,6 @@ bool NzRenderer::Initialize()
|
|||
s_target = nullptr;
|
||||
s_targetSize.Set(0U);
|
||||
s_textureUnits.resize(s_maxTextureUnit);
|
||||
s_useSamplerObjects = NzOpenGL::IsSupported(nzOpenGLExtension_SamplerObjects);
|
||||
s_useVertexArrayObjects = NzOpenGL::IsSupported(nzOpenGLExtension_VertexArrayObjects);
|
||||
s_updateFlags = Update_Matrices | Update_Shader | Update_VAO;
|
||||
s_vertexBuffer = nullptr;
|
||||
|
||||
|
|
@ -775,32 +691,13 @@ bool NzRenderer::Initialize()
|
|||
return false;
|
||||
}
|
||||
|
||||
const char* fragmentShader;
|
||||
const char* vertexShader;
|
||||
unsigned int fragmentShaderLength;
|
||||
unsigned int vertexShaderLength;
|
||||
if (NzOpenGL::GetGLSLVersion() >= 140)
|
||||
{
|
||||
fragmentShader = reinterpret_cast<const char*>(r_coreFragmentShader);
|
||||
fragmentShaderLength = sizeof(r_coreFragmentShader);
|
||||
vertexShader = reinterpret_cast<const char*>(r_coreVertexShader);
|
||||
vertexShaderLength = sizeof(r_coreVertexShader);
|
||||
}
|
||||
else
|
||||
{
|
||||
fragmentShader = reinterpret_cast<const char*>(r_compatibilityFragmentShader);
|
||||
fragmentShaderLength = sizeof(r_compatibilityFragmentShader);
|
||||
vertexShader = reinterpret_cast<const char*>(r_compatibilityVertexShader);
|
||||
vertexShaderLength = sizeof(r_compatibilityVertexShader);
|
||||
}
|
||||
|
||||
if (!debugShader->AttachStageFromSource(nzShaderStage_Fragment, fragmentShader, fragmentShaderLength))
|
||||
if (!debugShader->AttachStageFromSource(nzShaderStage_Fragment, reinterpret_cast<const char*>(r_coreFragmentShader), sizeof(r_coreFragmentShader)))
|
||||
{
|
||||
NazaraError("Failed to attach fragment stage");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!debugShader->AttachStageFromSource(nzShaderStage_Vertex, vertexShader, vertexShaderLength))
|
||||
if (!debugShader->AttachStageFromSource(nzShaderStage_Vertex, reinterpret_cast<const char*>(r_coreVertexShader), sizeof(r_coreVertexShader)))
|
||||
{
|
||||
NazaraError("Failed to attach vertex stage");
|
||||
return false;
|
||||
|
|
@ -1548,8 +1445,6 @@ bool NzRenderer::EnsureStateUpdate()
|
|||
if (s_updateFlags != Update_None)
|
||||
{
|
||||
if (s_updateFlags & Update_Textures)
|
||||
{
|
||||
if (s_useSamplerObjects)
|
||||
{
|
||||
for (unsigned int i : s_dirtyTextureUnits)
|
||||
{
|
||||
|
|
@ -1561,21 +1456,6 @@ bool NzRenderer::EnsureStateUpdate()
|
|||
unit.samplerUpdated = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (unsigned int i : s_dirtyTextureUnits)
|
||||
{
|
||||
TextureUnit& unit = s_textureUnits[i];
|
||||
|
||||
if (unit.texture && !unit.samplerUpdated)
|
||||
{
|
||||
NzOpenGL::BindTextureUnit(i);
|
||||
unit.sampler.Apply(unit.texture);
|
||||
unit.samplerUpdated = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
s_dirtyTextureUnits.clear(); // Ne change pas la capacité
|
||||
s_updateFlags &= ~Update_Textures;
|
||||
|
|
@ -1608,12 +1488,6 @@ bool NzRenderer::EnsureStateUpdate()
|
|||
}
|
||||
#endif
|
||||
|
||||
bool update;
|
||||
VAO_Map::iterator vaoIt;
|
||||
|
||||
// Si les VAOs sont supportés, on entoure nos appels par ceux-ci
|
||||
if (s_useVertexArrayObjects)
|
||||
{
|
||||
// Note: Les VAOs ne sont pas partagés entre les contextes, nous avons donc un tableau de VAOs par contexte
|
||||
const NzContext* context = NzContext::GetCurrent();
|
||||
|
||||
|
|
@ -1634,7 +1508,7 @@ bool NzRenderer::EnsureStateUpdate()
|
|||
VAO_Key key(s_indexBuffer, s_vertexBuffer, vertexDeclaration, instancingDeclaration);
|
||||
|
||||
// On recherche un VAO existant avec notre configuration
|
||||
vaoIt = vaoMap.find(key);
|
||||
auto vaoIt = vaoMap.find(key);
|
||||
if (vaoIt == vaoMap.end())
|
||||
{
|
||||
// On créé notre VAO
|
||||
|
|
@ -1657,24 +1531,9 @@ bool NzRenderer::EnsureStateUpdate()
|
|||
|
||||
vaoIt = vaoMap.insert(std::make_pair(key, std::move(entry))).first;
|
||||
|
||||
// Et on indique qu'on veut le programmer
|
||||
update = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Notre VAO existe déjà, il est donc inutile de le reprogrammer
|
||||
s_currentVAO = vaoIt->second.vao;
|
||||
|
||||
update = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
update = true; // Fallback si les VAOs ne sont pas supportés
|
||||
|
||||
// And begin to program it
|
||||
bool updateFailed = false;
|
||||
|
||||
if (update)
|
||||
{
|
||||
// Pour éviter la duplication de code, on va utiliser une astuce via une boucle for
|
||||
for (unsigned int i = 0; i < (s_instancing ? 2U : 1U); ++i)
|
||||
{
|
||||
|
|
@ -1772,6 +1631,7 @@ bool NzRenderer::EnsureStateUpdate()
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Les attributs d'instancing ont un diviseur spécifique (pour dépendre de l'instance en cours)
|
||||
if (i == 1)
|
||||
glVertexAttribDivisor(NzOpenGL::VertexComponentIndex[j], 1);
|
||||
|
|
@ -1801,12 +1661,7 @@ bool NzRenderer::EnsureStateUpdate()
|
|||
// On invalide les bindings des buffers (car nous les avons défini manuellement)
|
||||
NzOpenGL::SetBuffer(nzBufferType_Index, 0);
|
||||
NzOpenGL::SetBuffer(nzBufferType_Vertex, 0);
|
||||
}
|
||||
|
||||
if (s_useVertexArrayObjects)
|
||||
{
|
||||
if (update)
|
||||
{
|
||||
if (updateFailed)
|
||||
{
|
||||
// La création de notre VAO a échoué, libérons-le et marquons-le comme problématique
|
||||
|
|
@ -1817,21 +1672,21 @@ bool NzRenderer::EnsureStateUpdate()
|
|||
else
|
||||
glBindVertexArray(0); // On marque la fin de la construction du VAO en le débindant
|
||||
}
|
||||
else
|
||||
// Notre VAO existe déjà, il est donc inutile de le reprogrammer
|
||||
s_currentVAO = vaoIt->second.vao;
|
||||
|
||||
// En cas de non-support des VAOs, les attributs doivent être respécifiés à chaque frame
|
||||
s_updateFlags &= ~Update_VAO;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef NAZARA_DEBUG
|
||||
if (s_updateFlags != Update_None && !s_useVertexArrayObjects && s_updateFlags != Update_VAO)
|
||||
if (s_updateFlags != Update_None && s_updateFlags != Update_VAO)
|
||||
NazaraWarning("Update flags not fully cleared");
|
||||
#endif
|
||||
}
|
||||
|
||||
// On bind notre VAO
|
||||
if (s_useVertexArrayObjects)
|
||||
{
|
||||
if (!s_currentVAO)
|
||||
{
|
||||
NazaraError("Failed to create VAO");
|
||||
|
|
@ -1839,7 +1694,6 @@ bool NzRenderer::EnsureStateUpdate()
|
|||
}
|
||||
|
||||
glBindVertexArray(s_currentVAO);
|
||||
}
|
||||
|
||||
// On vérifie que les textures actuellement bindées sont bien nos textures
|
||||
// Ceci à cause du fait qu'il est possible que des opérations sur les textures aient eu lieu
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
#version 110
|
||||
|
||||
/********************Uniformes********************/
|
||||
uniform vec4 Color;
|
||||
|
||||
/********************Fonctions********************/
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = Color;
|
||||
}
|
||||
|
|
@ -1 +0,0 @@
|
|||
35,118,101,114,115,105,111,110,32,49,49,48,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,67,111,108,111,114,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,118,111,105,100,32,109,97,105,110,40,41,13,10,123,13,10,9,103,108,95,70,114,97,103,67,111,108,111,114,32,61,32,67,111,108,111,114,59,13,10,125,
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
#version 110
|
||||
|
||||
/********************Entrant********************/
|
||||
varying vec3 VertexPosition;
|
||||
|
||||
/********************Uniformes********************/
|
||||
uniform mat4 WorldViewProjMatrix;
|
||||
|
||||
/********************Fonctions********************/
|
||||
void main()
|
||||
{
|
||||
gl_Position = WorldViewProjMatrix * vec4(VertexPosition, 1.0);
|
||||
}
|
||||
|
|
@ -1 +0,0 @@
|
|||
35,118,101,114,115,105,111,110,32,49,49,48,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,69,110,116,114,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,118,97,114,121,105,110,103,32,118,101,99,51,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,87,111,114,108,100,86,105,101,119,80,114,111,106,77,97,116,114,105,120,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,118,111,105,100,32,109,97,105,110,40,41,13,10,123,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,87,111,114,108,100,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,13,10,125,13,10,
|
||||
|
|
@ -157,8 +157,6 @@ bool NzShader::Create()
|
|||
glBindAttribLocation(m_program, NzOpenGL::VertexComponentIndex[nzVertexComponent_Userdata3], "VertexUserdata3");
|
||||
glBindAttribLocation(m_program, NzOpenGL::VertexComponentIndex[nzVertexComponent_Userdata4], "VertexUserdata4");
|
||||
|
||||
if (NzRenderer::HasCapability(nzRendererCap_MultipleRenderTargets))
|
||||
{
|
||||
NzString uniform;
|
||||
uniform = "RenderTarget";
|
||||
|
||||
|
|
@ -168,7 +166,6 @@ bool NzShader::Create()
|
|||
NzString uniformName = uniform + NzString::Number(i);
|
||||
glBindFragDataLocation(m_program, i, uniformName.GetConstBuffer());
|
||||
}
|
||||
}
|
||||
|
||||
if (NzOpenGL::IsSupported(nzOpenGLExtension_GetProgramBinary))
|
||||
glProgramParameteri(m_program, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, GL_TRUE);
|
||||
|
|
|
|||
|
|
@ -220,12 +220,10 @@ bool NzShaderStage::IsSupported(nzShaderStage stage)
|
|||
switch (stage)
|
||||
{
|
||||
case nzShaderStage_Fragment:
|
||||
case nzShaderStage_Geometry:
|
||||
case nzShaderStage_Vertex:
|
||||
return true;
|
||||
|
||||
case nzShaderStage_Geometry:
|
||||
return NzOpenGL::GetVersion() >= 320;
|
||||
|
||||
default:
|
||||
NazaraError("Shader stage not handled (0x" + NzString::Number(stage, 16) + ')');
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -165,12 +165,12 @@ bool NzTexture::Create(nzImageType type, nzPixelFormat format, unsigned int widt
|
|||
}
|
||||
|
||||
m_impl = new NzTextureImpl;
|
||||
m_impl->depth = GetValidSize(depth);
|
||||
m_impl->depth = depth;
|
||||
m_impl->format = format;
|
||||
m_impl->height = GetValidSize(height);
|
||||
m_impl->height = height;
|
||||
m_impl->levelCount = levelCount;
|
||||
m_impl->type = type;
|
||||
m_impl->width = GetValidSize(width);
|
||||
m_impl->width = width;
|
||||
|
||||
glGenTextures(1, &m_impl->id);
|
||||
NzOpenGL::BindTexture(m_impl->type, m_impl->id);
|
||||
|
|
@ -1035,20 +1035,6 @@ unsigned int NzTexture::GetOpenGLID() const
|
|||
return m_impl->id;
|
||||
}
|
||||
|
||||
unsigned int NzTexture::GetValidSize(unsigned int size)
|
||||
{
|
||||
if (NzRenderer::HasCapability(nzRendererCap_TextureNPOT))
|
||||
return size;
|
||||
else
|
||||
{
|
||||
unsigned int pot = 1;
|
||||
while (pot < size)
|
||||
pot <<= 1;
|
||||
|
||||
return pot;
|
||||
}
|
||||
}
|
||||
|
||||
bool NzTexture::IsFormatSupported(nzPixelFormat format)
|
||||
{
|
||||
switch (format)
|
||||
|
|
@ -1101,14 +1087,14 @@ bool NzTexture::IsFormatSupported(nzPixelFormat format)
|
|||
case nzPixelFormat_RGBA32F:
|
||||
case nzPixelFormat_RGBA32I:
|
||||
case nzPixelFormat_RGBA32UI:
|
||||
return NzOpenGL::GetVersion() >= 300;
|
||||
return true;
|
||||
|
||||
// Formats de profondeur (Supportés avec les FBOs)
|
||||
case nzPixelFormat_Depth16:
|
||||
case nzPixelFormat_Depth24:
|
||||
case nzPixelFormat_Depth32:
|
||||
case nzPixelFormat_Depth24Stencil8:
|
||||
return NzOpenGL::IsSupported(nzOpenGLExtension_FrameBufferObject);
|
||||
return true;
|
||||
|
||||
// Formats de stencil (Non supportés pour les textures)
|
||||
case nzPixelFormat_Stencil1:
|
||||
|
|
@ -1141,14 +1127,12 @@ bool NzTexture::IsTypeSupported(nzImageType type)
|
|||
switch (type)
|
||||
{
|
||||
case nzImageType_1D:
|
||||
case nzImageType_1D_Array:
|
||||
case nzImageType_2D:
|
||||
case nzImageType_2D_Array:
|
||||
case nzImageType_3D:
|
||||
case nzImageType_Cubemap:
|
||||
return true; // Tous supportés nativement dans OpenGL 2
|
||||
|
||||
case nzImageType_1D_Array:
|
||||
case nzImageType_2D_Array:
|
||||
return NzOpenGL::IsSupported(nzOpenGLExtension_TextureArray);
|
||||
return true; // Tous supportés nativement dans OpenGL 3
|
||||
}
|
||||
|
||||
NazaraError("Image type not handled (0x" + NzString::Number(type, 16) + ')');
|
||||
|
|
|
|||
Loading…
Reference in New Issue