mirror of
https://github.com/minetest/minetest.git
synced 2024-11-20 14:43:45 +01:00
Minor corrections in gl3/gles2 drivers
This commit is contained in:
parent
cc8c3d501c
commit
8d2e770361
@ -936,9 +936,10 @@ void CNullDriver::setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, bool enab
|
||||
setTextureCreationFlag(ETCF_OPTIMIZED_FOR_SPEED, false);
|
||||
}
|
||||
|
||||
// set flag
|
||||
TextureCreationFlags = (TextureCreationFlags & (~flag)) |
|
||||
((((u32)!enabled) - 1) & flag);
|
||||
if (enabled)
|
||||
TextureCreationFlags |= flag;
|
||||
else
|
||||
TextureCreationFlags &= ~flag;
|
||||
}
|
||||
|
||||
//! Returns if a texture creation flag is enabled or disabled.
|
||||
|
@ -144,7 +144,7 @@ void COpenGL3DriverBase::debugCb(GLenum source, GLenum type, GLuint id, GLenum s
|
||||
ll = ELL_ERROR;
|
||||
else if (severity == GL_DEBUG_SEVERITY_MEDIUM)
|
||||
ll = ELL_WARNING;
|
||||
char buf[256];
|
||||
char buf[300];
|
||||
snprintf_irr(buf, sizeof(buf), "%04x %04x %.*s", source, type, length, message);
|
||||
os::Printer::log("GL", buf, ll);
|
||||
}
|
||||
@ -700,15 +700,7 @@ void COpenGL3DriverBase::drawVertexPrimitiveList(const void *vertices, u32 verte
|
||||
break;
|
||||
}
|
||||
case (EIT_32BIT): {
|
||||
#ifdef GL_OES_element_index_uint
|
||||
#ifndef GL_UNSIGNED_INT
|
||||
#define GL_UNSIGNED_INT 0x1405
|
||||
#endif
|
||||
if (FeatureAvailable[COGLESCoreExtensionHandler::IRR_GL_OES_element_index_uint])
|
||||
indexSize = GL_UNSIGNED_INT;
|
||||
else
|
||||
#endif
|
||||
indexSize = GL_UNSIGNED_SHORT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1683,7 +1675,7 @@ ITexture *COpenGL3DriverBase::addRenderTargetTextureCubemap(const irr::u32 sideL
|
||||
//! Returns the maximum amount of primitives
|
||||
u32 COpenGL3DriverBase::getMaximalPrimitiveCount() const
|
||||
{
|
||||
return 65535;
|
||||
return Version.Spec == OpenGLSpec::ES ? 65535 : 0x7fffffff;
|
||||
}
|
||||
|
||||
bool COpenGL3DriverBase::setRenderTargetEx(IRenderTarget *target, u16 clearFlag, SColor clearColor, f32 clearDepth, u8 clearStencil)
|
||||
|
@ -411,7 +411,7 @@ bool COpenGL3MaterialRenderer::setPixelShaderConstant(s32 index, const s32 *ints
|
||||
|
||||
bool COpenGL3MaterialRenderer::setPixelShaderConstant(s32 index, const u32 *ints, int count)
|
||||
{
|
||||
os::Printer::log("Unsigned int support needs at least GLES 3.0", ELL_WARNING);
|
||||
os::Printer::log("Unsigned int support is unimplemented", ELL_WARNING);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include "Driver.h"
|
||||
#include <cassert>
|
||||
#include <stdexcept>
|
||||
#include "mt_opengl.h"
|
||||
|
||||
namespace irr
|
||||
@ -18,7 +19,7 @@ E_DRIVER_TYPE COpenGL3Driver::getDriverType() const
|
||||
|
||||
OpenGLVersion COpenGL3Driver::getVersionFromOpenGL() const
|
||||
{
|
||||
GLint major, minor, profile;
|
||||
GLint major = 0, minor = 0, profile = 0;
|
||||
GL.GetIntegerv(GL_MAJOR_VERSION, &major);
|
||||
GL.GetIntegerv(GL_MINOR_VERSION, &minor);
|
||||
GL.GetIntegerv(GL_CONTEXT_PROFILE_MASK, &profile);
|
||||
@ -35,18 +36,21 @@ OpenGLVersion COpenGL3Driver::getVersionFromOpenGL() const
|
||||
void COpenGL3Driver::initFeatures()
|
||||
{
|
||||
if (Version.Spec != OpenGLSpec::Compat) {
|
||||
os::Printer::log("OpenGL 3 driver requires Compatibility Mode", ELL_ERROR);
|
||||
throw std::exception();
|
||||
auto msg = "OpenGL 3 driver requires Compatibility context";
|
||||
os::Printer::log(msg, ELL_ERROR);
|
||||
throw std::runtime_error(msg);
|
||||
}
|
||||
if (!isVersionAtLeast(3, 2)) {
|
||||
os::Printer::log("OpenGL 3 driver requires OpenGL >= 3.2 ", ELL_ERROR);
|
||||
throw std::exception();
|
||||
auto msg = "OpenGL 3 driver requires OpenGL >= 3.2";
|
||||
os::Printer::log(msg, ELL_ERROR);
|
||||
throw std::runtime_error(msg);
|
||||
}
|
||||
initExtensions();
|
||||
|
||||
TextureFormats[ECF_A1R5G5B5] = {GL_RGB5_A1, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV}; // WARNING: may not be renderable
|
||||
TextureFormats[ECF_R5G6B5] = {GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5}; // GL_RGB565 is an extension until 4.1
|
||||
TextureFormats[ECF_R8G8B8] = {GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE}; // WARNING: may not be renderable
|
||||
// FIXME: shouldn't this simply be GL_UNSIGNED_BYTE?
|
||||
TextureFormats[ECF_A8R8G8B8] = {GL_RGBA8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV};
|
||||
TextureFormats[ECF_R16F] = {GL_R16F, GL_RED, GL_HALF_FLOAT};
|
||||
TextureFormats[ECF_G16R16F] = {GL_RG16F, GL_RG, GL_HALF_FLOAT};
|
||||
|
@ -3,8 +3,10 @@
|
||||
// For conditions of distribution and use, see copyright notice in Irrlicht.h
|
||||
|
||||
#include "Driver.h"
|
||||
#include <stdexcept>
|
||||
#include <cassert>
|
||||
#include <CColorConverter.h>
|
||||
#include "mt_opengl.h"
|
||||
#include "CColorConverter.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
@ -19,7 +21,7 @@ E_DRIVER_TYPE COpenGLES2Driver::getDriverType() const
|
||||
OpenGLVersion COpenGLES2Driver::getVersionFromOpenGL() const
|
||||
{
|
||||
auto version_string = reinterpret_cast<const char *>(GL.GetString(GL_VERSION));
|
||||
int major, minor;
|
||||
int major = 0, minor = 0;
|
||||
if (sscanf(version_string, "OpenGL ES %d.%d", &major, &minor) != 2) {
|
||||
os::Printer::log("Failed to parse OpenGL ES version string", version_string, ELL_ERROR);
|
||||
return {OpenGLSpec::ES, 0, 0, 0};
|
||||
@ -29,8 +31,16 @@ OpenGLVersion COpenGLES2Driver::getVersionFromOpenGL() const
|
||||
|
||||
void COpenGLES2Driver::initFeatures()
|
||||
{
|
||||
assert(Version.Spec == OpenGLSpec::ES);
|
||||
assert(Version.Major >= 2);
|
||||
if (Version.Spec != OpenGLSpec::ES) {
|
||||
auto msg = "Context isn't OpenGL ES";
|
||||
os::Printer::log(msg, ELL_ERROR);
|
||||
throw std::runtime_error(msg);
|
||||
}
|
||||
if (!isVersionAtLeast(2, 0)) {
|
||||
auto msg = "Open GL ES 2.0 is required";
|
||||
os::Printer::log(msg, ELL_ERROR);
|
||||
throw std::runtime_error(msg);
|
||||
}
|
||||
initExtensions();
|
||||
|
||||
static const GLenum BGRA8_EXT = 0x93A1;
|
||||
|
Loading…
Reference in New Issue
Block a user