irrlicht/source/Irrlicht/OpenGL/ExtensionHandler.h

180 lines
4.6 KiB
C
Raw Normal View History

2023-03-25 09:11:09 +01:00
// Copyright (C) 2023 Vitaliy Lobachevskiy
// Copyright (C) 2015 Patryk Nadrowski
// Copyright (C) 2009-2010 Amundis
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in Irrlicht.h
#pragma once
2023-04-20 16:37:15 +02:00
#include <unordered_set>
2023-03-25 09:11:09 +01:00
#include "EDriverFeatures.h"
#include "irrTypes.h"
#include "os.h"
#include <mt_opengl.h>
2023-03-25 09:11:09 +01:00
#include "Common.h"
#include "COGLESCoreExtensionHandler.h"
namespace irr
{
namespace video
{
class COpenGL3ExtensionHandler : public COGLESCoreExtensionHandler
{
public:
COpenGL3ExtensionHandler() : COGLESCoreExtensionHandler() {}
void initExtensionsOld();
void initExtensionsNew();
2023-03-25 09:11:09 +01:00
2023-04-20 16:37:15 +02:00
/// Checks whether a named extension is present
bool queryExtension(const std::string &name) const noexcept;
2023-03-25 09:11:09 +01:00
bool queryFeature(video::E_VIDEO_DRIVER_FEATURE feature) const
{
switch (feature)
{
case EVDF_RENDER_TO_TARGET:
case EVDF_HARDWARE_TL:
case EVDF_MULTITEXTURE:
case EVDF_BILINEAR_FILTER:
case EVDF_MIP_MAP:
case EVDF_MIP_MAP_AUTO_UPDATE:
case EVDF_VERTEX_SHADER_1_1:
case EVDF_PIXEL_SHADER_1_1:
case EVDF_PIXEL_SHADER_1_2:
case EVDF_PIXEL_SHADER_2_0:
case EVDF_VERTEX_SHADER_2_0:
case EVDF_ARB_GLSL:
case EVDF_TEXTURE_NSQUARE:
case EVDF_TEXTURE_NPOT:
case EVDF_FRAMEBUFFER_OBJECT:
case EVDF_VERTEX_BUFFER_OBJECT:
case EVDF_COLOR_MASK:
case EVDF_ALPHA_TO_COVERAGE:
case EVDF_POLYGON_OFFSET:
case EVDF_BLEND_OPERATIONS:
case EVDF_BLEND_SEPARATE:
case EVDF_TEXTURE_MATRIX:
case EVDF_TEXTURE_CUBEMAP:
return true;
case EVDF_ARB_VERTEX_PROGRAM_1:
case EVDF_ARB_FRAGMENT_PROGRAM_1:
case EVDF_GEOMETRY_SHADER:
case EVDF_MULTIPLE_RENDER_TARGETS:
case EVDF_MRT_BLEND:
case EVDF_MRT_COLOR_MASK:
case EVDF_MRT_BLEND_FUNC:
case EVDF_OCCLUSION_QUERY:
return false;
case EVDF_TEXTURE_COMPRESSED_DXT:
return false; // NV Tegra need improvements here
case EVDF_TEXTURE_COMPRESSED_PVRTC:
return FeatureAvailable[IRR_GL_IMG_texture_compression_pvrtc];
case EVDF_TEXTURE_COMPRESSED_PVRTC2:
return FeatureAvailable[IRR_GL_IMG_texture_compression_pvrtc2];
case EVDF_TEXTURE_COMPRESSED_ETC1:
return FeatureAvailable[IRR_GL_OES_compressed_ETC1_RGB8_texture];
case EVDF_TEXTURE_COMPRESSED_ETC2:
return false;
case EVDF_STENCIL_BUFFER:
return StencilBuffer;
default:
return false;
};
}
static GLint GetInteger(GLenum key) {
GLint val = 0;
glGetIntegerv(key, &val);
return val;
};
2023-03-25 09:11:09 +01:00
inline void irrGlActiveTexture(GLenum texture)
{
glActiveTexture(texture);
}
inline void irrGlCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border,
GLsizei imageSize, const void* data)
{
glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data);
}
inline void irrGlCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
GLenum format, GLsizei imageSize, const void* data)
{
glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data);
}
inline void irrGlUseProgram(GLuint prog)
{
glUseProgram(prog);
}
inline void irrGlBindFramebuffer(GLenum target, GLuint framebuffer)
{
glBindFramebuffer(target, framebuffer);
}
inline void irrGlDeleteFramebuffers(GLsizei n, const GLuint *framebuffers)
{
glDeleteFramebuffers(n, framebuffers);
}
inline void irrGlGenFramebuffers(GLsizei n, GLuint *framebuffers)
{
glGenFramebuffers(n, framebuffers);
}
inline GLenum irrGlCheckFramebufferStatus(GLenum target)
{
return glCheckFramebufferStatus(target);
}
inline void irrGlFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
{
glFramebufferTexture2D(target, attachment, textarget, texture, level);
}
inline void irrGlGenerateMipmap(GLenum target)
{
glGenerateMipmap(target);
}
inline void irrGlDrawBuffer(GLenum mode)
{
GL.DrawBuffer(mode);
2023-03-25 09:11:09 +01:00
}
inline void irrGlDrawBuffers(GLsizei n, const GLenum *bufs)
{
GL.DrawBuffers(n, bufs);
2023-03-25 09:11:09 +01:00
}
inline void irrGlBlendFuncSeparate(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha)
{
glBlendFuncSeparate(sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha);
}
inline void irrGlBlendEquation(GLenum mode)
{
glBlendEquation(mode);
}
2023-04-20 16:37:15 +02:00
bool AnisotropicFilterSupported = false;
2023-04-20 16:44:14 +02:00
bool BlendMinMaxSupported = false;
2023-04-20 16:37:15 +02:00
private:
2023-04-20 16:37:15 +02:00
void addExtension(std::string name);
void updateLegacyExtensionList();
std::unordered_set<std::string> Extensions;
2023-03-25 09:11:09 +01:00
};
}
}