Move EGL context to separate class.
It will allow to use it for OpenGL + Wayland.
This commit is contained in:
parent
9bde708155
commit
3961a9a3b7
@ -67,6 +67,7 @@ source/Irrlicht/CAttributes.cpp
|
||||
source/Irrlicht/CBillboardSceneNode.cpp
|
||||
source/Irrlicht/CBoneSceneNode.cpp
|
||||
source/Irrlicht/CCameraSceneNode.cpp
|
||||
source/Irrlicht/CContextEGL.cpp
|
||||
source/Irrlicht/CColorConverter.cpp
|
||||
source/Irrlicht/CCubeSceneNode.cpp
|
||||
source/Irrlicht/CDefaultGUIElementFactory.cpp
|
||||
@ -199,6 +200,7 @@ source/Irrlicht/CBillboardSceneNode.h
|
||||
source/Irrlicht/CBlit.h
|
||||
source/Irrlicht/CBoneSceneNode.h
|
||||
source/Irrlicht/CCameraSceneNode.h
|
||||
source/Irrlicht/CContextEGL.h
|
||||
source/Irrlicht/CColorConverter.h
|
||||
source/Irrlicht/CCubeSceneNode.h
|
||||
source/Irrlicht/CDefaultGUIElementFactory.h
|
||||
|
@ -117,6 +117,10 @@
|
||||
#define _IRR_COMPILE_ANDROID_ASSET_READER_
|
||||
#endif
|
||||
|
||||
#if defined(_IRR_COMPILE_WITH_OGLES2_) && !defined(_IRR_COMPILE_WITH_IPHONE_DEVICE_)
|
||||
#define _IRR_COMPILE_WITH_EGL_
|
||||
#endif
|
||||
|
||||
#if !defined(_IRR_WINDOWS_API_) && !defined(_IRR_OSX_PLATFORM_) && !defined(_IRR_ANDROID_PLATFORM_)
|
||||
#ifndef _IRR_SOLARIS_PLATFORM_
|
||||
#define _IRR_LINUX_PLATFORM_
|
||||
|
394
lib/irrlicht/source/Irrlicht/CContextEGL.cpp
Normal file
394
lib/irrlicht/source/Irrlicht/CContextEGL.cpp
Normal file
@ -0,0 +1,394 @@
|
||||
// Copyright (C) 2013 Patryk Nadrowski
|
||||
// Copyright (C) 2016-2017 Dawid Gan
|
||||
// Heavily based on the OpenGL driver implemented by Nikolaus Gebhardt
|
||||
// OpenGL ES driver implemented by Christian Stehno and first OpenGL ES 2.0
|
||||
// driver implemented by Amundis.
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Irrlicht.h
|
||||
|
||||
#include "CContextEGL.h"
|
||||
#include "os.h"
|
||||
#include "fast_atof.h"
|
||||
|
||||
#if defined(_IRR_COMPILE_WITH_EGL_)
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
|
||||
ContextEGL::ContextEGL(const SIrrlichtCreationParameters& params,
|
||||
const SExposedVideoData& data)
|
||||
{
|
||||
EglDisplay = EGL_NO_DISPLAY;
|
||||
IsCoreContext = true;
|
||||
|
||||
#if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_)
|
||||
HDc = 0;
|
||||
#endif
|
||||
|
||||
#if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_)
|
||||
EglWindow = (NativeWindowType)data.OpenGLWin32.HWnd;
|
||||
HDc = GetDC((HWND)EglWindow);
|
||||
EglDisplay = eglGetDisplay((NativeDisplayType)HDc);
|
||||
#elif defined(_IRR_COMPILE_WITH_X11_DEVICE_)
|
||||
EglWindow = (NativeWindowType)data.OpenGLLinux.X11Window;
|
||||
EglDisplay = eglGetDisplay((NativeDisplayType)data.OpenGLLinux.X11Display);
|
||||
#elif defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_)
|
||||
EglWindow = ((struct android_app *)(params.PrivateData))->window;
|
||||
EglDisplay = EGL_NO_DISPLAY;
|
||||
#endif
|
||||
|
||||
if (EglDisplay == EGL_NO_DISPLAY)
|
||||
{
|
||||
os::Printer::log("Getting OpenGL-ES2 display.");
|
||||
EglDisplay = eglGetDisplay((NativeDisplayType) EGL_DEFAULT_DISPLAY);
|
||||
}
|
||||
if (EglDisplay == EGL_NO_DISPLAY)
|
||||
{
|
||||
os::Printer::log("Could not get OpenGL-ES2 display.");
|
||||
}
|
||||
|
||||
EGLint majorVersion, minorVersion;
|
||||
if (!eglInitialize(EglDisplay, &majorVersion, &minorVersion))
|
||||
{
|
||||
os::Printer::log("Could not initialize OpenGL-ES2 display.");
|
||||
}
|
||||
else
|
||||
{
|
||||
char text[64];
|
||||
sprintf(text, "EglDisplay initialized. Egl version %d.%d\n", majorVersion, minorVersion);
|
||||
os::Printer::log(text);
|
||||
}
|
||||
|
||||
EGLint attribs[] =
|
||||
{
|
||||
#if defined( _IRR_COMPILE_WITH_ANDROID_DEVICE_ )
|
||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
||||
EGL_BLUE_SIZE, 8,
|
||||
EGL_GREEN_SIZE, 8,
|
||||
EGL_RED_SIZE, 8,
|
||||
EGL_DEPTH_SIZE, 16,
|
||||
EGL_NONE
|
||||
#else
|
||||
EGL_RED_SIZE, 5,
|
||||
EGL_GREEN_SIZE, 5,
|
||||
EGL_BLUE_SIZE, 5,
|
||||
EGL_ALPHA_SIZE, params.WithAlphaChannel ? 1 : 0,
|
||||
EGL_BUFFER_SIZE, params.Bits,
|
||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
||||
//EGL_COLOR_BUFFER_TYPE, EGL_RGB_BUFFER,
|
||||
EGL_DEPTH_SIZE, params.ZBufferBits,
|
||||
EGL_STENCIL_SIZE, params.Stencilbuffer,
|
||||
EGL_SAMPLE_BUFFERS, params.AntiAlias ? 1 : 0,
|
||||
EGL_SAMPLES, params.AntiAlias,
|
||||
#ifdef EGL_VERSION_1_3
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
||||
#endif
|
||||
EGL_NONE, 0
|
||||
#endif
|
||||
};
|
||||
|
||||
EGLint num_configs;
|
||||
u32 steps=5;
|
||||
while (!eglChooseConfig(EglDisplay, attribs, &EglConfig, 1, &num_configs) || !num_configs)
|
||||
{
|
||||
switch (steps)
|
||||
{
|
||||
case 5: // samples
|
||||
if (attribs[19]>2)
|
||||
{
|
||||
--attribs[19];
|
||||
}
|
||||
else
|
||||
{
|
||||
attribs[17]=0;
|
||||
attribs[19]=0;
|
||||
--steps;
|
||||
}
|
||||
break;
|
||||
case 4: // alpha
|
||||
if (attribs[7])
|
||||
{
|
||||
attribs[7]=0;
|
||||
if (params.AntiAlias)
|
||||
{
|
||||
attribs[17]=1;
|
||||
attribs[19]=params.AntiAlias;
|
||||
steps=5;
|
||||
}
|
||||
}
|
||||
else
|
||||
--steps;
|
||||
break;
|
||||
case 3: // stencil
|
||||
if (attribs[15])
|
||||
{
|
||||
attribs[15]=0;
|
||||
if (params.AntiAlias)
|
||||
{
|
||||
attribs[17]=1;
|
||||
attribs[19]=params.AntiAlias;
|
||||
steps=5;
|
||||
}
|
||||
}
|
||||
else
|
||||
--steps;
|
||||
break;
|
||||
case 2: // depth size
|
||||
if (attribs[13]>16)
|
||||
{
|
||||
attribs[13]-=8;
|
||||
}
|
||||
else
|
||||
--steps;
|
||||
break;
|
||||
case 1: // buffer size
|
||||
if (attribs[9]>16)
|
||||
{
|
||||
attribs[9]-=8;
|
||||
}
|
||||
else
|
||||
--steps;
|
||||
break;
|
||||
default:
|
||||
os::Printer::log("Could not get config for OpenGL-ES2 display.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (params.AntiAlias && !attribs[17])
|
||||
os::Printer::log("No multisampling.");
|
||||
if (params.WithAlphaChannel && !attribs[7])
|
||||
os::Printer::log("No alpha.");
|
||||
if (params.Stencilbuffer && !attribs[15])
|
||||
os::Printer::log("No stencil buffer.");
|
||||
if (params.ZBufferBits > attribs[13])
|
||||
os::Printer::log("No full depth buffer.");
|
||||
if (params.Bits > attribs[9])
|
||||
os::Printer::log("No full color buffer.");
|
||||
#if defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_)
|
||||
/* EGL_NATIVE_VISUAL_ID is an attribute of the EGLConfig that is
|
||||
* guaranteed to be accepted by ANativeWindow_setBuffersGeometry().
|
||||
* As soon as we picked a EGLConfig, we can safely reconfigure the
|
||||
* ANativeWindow buffers to match, using EGL_NATIVE_VISUAL_ID. */
|
||||
EGLint format;
|
||||
eglGetConfigAttrib(EglDisplay, EglConfig, EGL_NATIVE_VISUAL_ID, &format);
|
||||
|
||||
ANativeWindow_setBuffersGeometry(EglWindow, 0, 0, format);
|
||||
#endif
|
||||
os::Printer::log(" Creating EglSurface with nativeWindow...");
|
||||
EglSurface = eglCreateWindowSurface(EglDisplay, EglConfig, EglWindow, NULL);
|
||||
if (EGL_NO_SURFACE == EglSurface)
|
||||
{
|
||||
os::Printer::log("FAILED\n");
|
||||
EglSurface = eglCreateWindowSurface(EglDisplay, EglConfig, 0, NULL);
|
||||
os::Printer::log("Creating EglSurface without nativeWindows...");
|
||||
}
|
||||
else
|
||||
os::Printer::log("SUCCESS\n");
|
||||
if (EGL_NO_SURFACE == EglSurface)
|
||||
{
|
||||
os::Printer::log("FAILED\n");
|
||||
os::Printer::log("Could not create surface for OpenGL-ES2 display.");
|
||||
}
|
||||
else
|
||||
os::Printer::log("SUCCESS\n");
|
||||
|
||||
#ifdef EGL_VERSION_1_2
|
||||
if (minorVersion>1)
|
||||
eglBindAPI(EGL_OPENGL_ES_API);
|
||||
#endif
|
||||
os::Printer::log("Creating EglContext...");
|
||||
EglContext = EGL_NO_CONTEXT;
|
||||
|
||||
if (!params.ForceLegacyDevice)
|
||||
{
|
||||
os::Printer::log("Trying to create Context for OpenGL-ES3.");
|
||||
|
||||
EGLint contextAttrib[] =
|
||||
{
|
||||
#ifdef EGL_VERSION_1_3
|
||||
EGL_CONTEXT_CLIENT_VERSION, 3,
|
||||
#endif
|
||||
EGL_NONE, 0
|
||||
};
|
||||
|
||||
EglContext = eglCreateContext(EglDisplay, EglConfig, EGL_NO_CONTEXT, contextAttrib);
|
||||
}
|
||||
|
||||
if (EGL_NO_CONTEXT == EglContext)
|
||||
{
|
||||
os::Printer::log("Trying to create Context for OpenGL-ES2.");
|
||||
IsCoreContext = false;
|
||||
|
||||
EGLint contextAttrib[] =
|
||||
{
|
||||
#ifdef EGL_VERSION_1_3
|
||||
EGL_CONTEXT_CLIENT_VERSION, 2,
|
||||
#endif
|
||||
EGL_NONE, 0
|
||||
};
|
||||
|
||||
EglContext = eglCreateContext(EglDisplay, EglConfig, EGL_NO_CONTEXT, contextAttrib);
|
||||
if (EGL_NO_CONTEXT == EglContext)
|
||||
{
|
||||
os::Printer::log("FAILED\n");
|
||||
os::Printer::log("Could not create Context for OpenGL-ES2 display.");
|
||||
}
|
||||
}
|
||||
|
||||
eglMakeCurrent(EglDisplay, EglSurface, EglSurface, EglContext);
|
||||
if (testEGLError())
|
||||
{
|
||||
os::Printer::log("Could not make Context current for OpenGL-ES2 display.");
|
||||
}
|
||||
|
||||
//~ #ifdef _IRR_COMPILE_WITH_ANDROID_DEVICE_
|
||||
//~ int backingWidth;
|
||||
//~ int backingHeight;
|
||||
//~ eglQuerySurface(EglDisplay, EglSurface, EGL_WIDTH, &backingWidth);
|
||||
//~ eglQuerySurface(EglDisplay, EglSurface, EGL_HEIGHT, &backingHeight);
|
||||
//~ core::dimension2d<u32> WindowSize(backingWidth, backingHeight);
|
||||
//~ CNullDriver::ScreenSize = WindowSize;
|
||||
//~ #endif
|
||||
|
||||
|
||||
// set vsync
|
||||
if (params.Vsync)
|
||||
eglSwapInterval(EglDisplay, 1);
|
||||
|
||||
|
||||
|
||||
const f32 egl_ver = core::fast_atof(reinterpret_cast<const c8*>(eglQueryString(EglDisplay, EGL_VERSION)));
|
||||
EGLVersion = static_cast<u16>(core::floor32(egl_ver)*100+core::round32(core::fract(egl_ver)*10.0f));
|
||||
core::stringc eglExtensions = eglQueryString(EglDisplay, EGL_EXTENSIONS);
|
||||
os::Printer::log(eglExtensions.c_str());
|
||||
|
||||
os::Printer::log(eglQueryString(EglDisplay, EGL_CLIENT_APIS));
|
||||
}
|
||||
|
||||
|
||||
ContextEGL::~ContextEGL()
|
||||
{
|
||||
eglMakeCurrent(EglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
|
||||
if (EglContext != EGL_NO_CONTEXT)
|
||||
{
|
||||
eglDestroyContext(EglDisplay, EglContext);
|
||||
EglContext = EGL_NO_CONTEXT;
|
||||
}
|
||||
|
||||
if (EglSurface != EGL_NO_SURFACE)
|
||||
{
|
||||
eglDestroySurface(EglDisplay, EglSurface);
|
||||
EglSurface = EGL_NO_SURFACE;
|
||||
}
|
||||
|
||||
if (EglDisplay != EGL_NO_DISPLAY)
|
||||
{
|
||||
eglTerminate(EglDisplay);
|
||||
EglDisplay = EGL_NO_DISPLAY;
|
||||
}
|
||||
|
||||
#if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_)
|
||||
if (HDc)
|
||||
ReleaseDC((HWND)EglWindow, HDc);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
bool ContextEGL::swapBuffers()
|
||||
{
|
||||
eglSwapBuffers(EglDisplay, EglSurface);
|
||||
EGLint g = eglGetError();
|
||||
|
||||
return g == EGL_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
void ContextEGL::reloadEGLSurface(void* window)
|
||||
{
|
||||
os::Printer::log("Reload EGL surface.");
|
||||
|
||||
#if defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_)
|
||||
EglWindow = (ANativeWindow*)window;
|
||||
#endif
|
||||
|
||||
if (!EglWindow)
|
||||
os::Printer::log("Invalid Egl window.");
|
||||
|
||||
eglMakeCurrent(EglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
|
||||
eglDestroySurface(EglDisplay, EglSurface);
|
||||
|
||||
EglSurface = eglCreateWindowSurface(EglDisplay, EglConfig, EglWindow, 0);
|
||||
|
||||
if (EGL_NO_SURFACE == EglSurface)
|
||||
os::Printer::log("Could not create EGL surface.");
|
||||
|
||||
eglMakeCurrent(EglDisplay, EglSurface, EglSurface, EglContext);
|
||||
}
|
||||
|
||||
|
||||
bool ContextEGL::testEGLError()
|
||||
{
|
||||
#if defined(_DEBUG)
|
||||
EGLint g = eglGetError();
|
||||
switch (g)
|
||||
{
|
||||
case EGL_SUCCESS:
|
||||
return false;
|
||||
case EGL_NOT_INITIALIZED :
|
||||
os::Printer::log("Not Initialized", ELL_ERROR);
|
||||
break;
|
||||
case EGL_BAD_ACCESS:
|
||||
os::Printer::log("Bad Access", ELL_ERROR);
|
||||
break;
|
||||
case EGL_BAD_ALLOC:
|
||||
os::Printer::log("Bad Alloc", ELL_ERROR);
|
||||
break;
|
||||
case EGL_BAD_ATTRIBUTE:
|
||||
os::Printer::log("Bad Attribute", ELL_ERROR);
|
||||
break;
|
||||
case EGL_BAD_CONTEXT:
|
||||
os::Printer::log("Bad Context", ELL_ERROR);
|
||||
break;
|
||||
case EGL_BAD_CONFIG:
|
||||
os::Printer::log("Bad Config", ELL_ERROR);
|
||||
break;
|
||||
case EGL_BAD_CURRENT_SURFACE:
|
||||
os::Printer::log("Bad Current Surface", ELL_ERROR);
|
||||
break;
|
||||
case EGL_BAD_DISPLAY:
|
||||
os::Printer::log("Bad Display", ELL_ERROR);
|
||||
break;
|
||||
case EGL_BAD_SURFACE:
|
||||
os::Printer::log("Bad Surface", ELL_ERROR);
|
||||
break;
|
||||
case EGL_BAD_MATCH:
|
||||
os::Printer::log("Bad Match", ELL_ERROR);
|
||||
break;
|
||||
case EGL_BAD_PARAMETER:
|
||||
os::Printer::log("Bad Parameter", ELL_ERROR);
|
||||
break;
|
||||
case EGL_BAD_NATIVE_PIXMAP:
|
||||
os::Printer::log("Bad Native Pixmap", ELL_ERROR);
|
||||
break;
|
||||
case EGL_BAD_NATIVE_WINDOW:
|
||||
os::Printer::log("Bad Native Window", ELL_ERROR);
|
||||
break;
|
||||
case EGL_CONTEXT_LOST:
|
||||
os::Printer::log("Context Lost", ELL_ERROR);
|
||||
break;
|
||||
};
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
76
lib/irrlicht/source/Irrlicht/CContextEGL.h
Normal file
76
lib/irrlicht/source/Irrlicht/CContextEGL.h
Normal file
@ -0,0 +1,76 @@
|
||||
// Copyright (C) 2013 Patryk Nadrowski
|
||||
// Copyright (C) 2016-2017 Dawid Gan
|
||||
// Heavily based on the OpenGL driver implemented by Nikolaus Gebhardt
|
||||
// OpenGL ES driver implemented by Christian Stehno and first OpenGL ES 2.0
|
||||
// driver implemented by Amundis.
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Irrlicht.h
|
||||
|
||||
#ifndef __C_CONTEXT_EGL_H_INCLUDED__
|
||||
#define __C_CONTEXT_EGL_H_INCLUDED__
|
||||
|
||||
#include "IrrCompileConfig.h"
|
||||
|
||||
#if defined(_IRR_COMPILE_WITH_EGL_)
|
||||
|
||||
#include "SIrrCreationParameters.h"
|
||||
#include "SExposedVideoData.h"
|
||||
|
||||
#if defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_)
|
||||
#include <EGL/egl.h>
|
||||
#else
|
||||
#include <EGL/egl.h>
|
||||
#include <EGL/eglplatform.h>
|
||||
#endif
|
||||
|
||||
#if defined(_IRR_WINDOWS_API_)
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma comment(lib, "libEGL.lib")
|
||||
#endif
|
||||
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
|
||||
class ContextEGL
|
||||
{
|
||||
private:
|
||||
NativeWindowType EglWindow;
|
||||
void* EglDisplay;
|
||||
void* EglSurface;
|
||||
void* EglContext;
|
||||
EGLConfig EglConfig;
|
||||
u16 EGLVersion;
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_
|
||||
HDC HDc;
|
||||
#endif
|
||||
|
||||
bool IsCoreContext;
|
||||
|
||||
bool testEGLError();
|
||||
|
||||
public:
|
||||
ContextEGL(const SIrrlichtCreationParameters& params,
|
||||
const SExposedVideoData& data);
|
||||
~ContextEGL();
|
||||
|
||||
void reloadEGLSurface(void* window);
|
||||
bool swapBuffers();
|
||||
bool isCoreContext() {return IsCoreContext;}
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
@ -17,6 +17,7 @@
|
||||
#include "COGLES2NormalMapRenderer.h"
|
||||
#include "COGLES2ParallaxMapRenderer.h"
|
||||
#include "COGLES2Renderer2D.h"
|
||||
#include "CContextEGL.h"
|
||||
#include "CImage.h"
|
||||
#include "os.h"
|
||||
|
||||
@ -24,7 +25,6 @@
|
||||
#include <OpenGLES/ES2/gl.h>
|
||||
#include <OpenGLES/ES2/glext.h>
|
||||
#else
|
||||
#include <EGL/egl.h>
|
||||
#include <GLES2/gl2.h>
|
||||
#endif
|
||||
|
||||
@ -45,11 +45,8 @@ namespace video
|
||||
BridgeCalls(0), CurrentRenderMode(ERM_NONE), ResetRenderStates(true),
|
||||
Transformation3DChanged(true), AntiAlias(params.AntiAlias),
|
||||
RenderTargetTexture(0), CurrentRendertargetSize(0, 0), ColorFormat(ECF_R8G8B8)
|
||||
#ifdef EGL_VERSION_1_0
|
||||
, EglDisplay(EGL_NO_DISPLAY)
|
||||
#endif
|
||||
#if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_)
|
||||
, HDc(0)
|
||||
#if defined(_IRR_COMPILE_WITH_EGL_)
|
||||
, EglContext(0)
|
||||
#elif defined(_IRR_COMPILE_WITH_IPHONE_DEVICE_)
|
||||
, ViewFramebuffer(0)
|
||||
, ViewRenderbuffer(0)
|
||||
@ -61,248 +58,22 @@ namespace video
|
||||
setDebugName("COGLES2Driver");
|
||||
#endif
|
||||
ExposedData = data;
|
||||
#if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_)
|
||||
EglWindow = (NativeWindowType)data.OpenGLWin32.HWnd;
|
||||
HDc = GetDC((HWND)EglWindow);
|
||||
EglDisplay = eglGetDisplay((NativeDisplayType)HDc);
|
||||
#elif defined(_IRR_COMPILE_WITH_X11_DEVICE_)
|
||||
EglWindow = (NativeWindowType)ExposedData.OpenGLLinux.X11Window;
|
||||
EglDisplay = eglGetDisplay((NativeDisplayType)ExposedData.OpenGLLinux.X11Display);
|
||||
#elif defined(_IRR_COMPILE_WITH_IPHONE_DEVICE_)
|
||||
Device = device;
|
||||
#elif defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_)
|
||||
EglWindow = ((struct android_app *)(params.PrivateData))->window;
|
||||
EglDisplay = EGL_NO_DISPLAY;
|
||||
#endif
|
||||
#ifdef EGL_VERSION_1_0
|
||||
if (EglDisplay == EGL_NO_DISPLAY)
|
||||
{
|
||||
os::Printer::log("Getting OpenGL-ES2 display.");
|
||||
EglDisplay = eglGetDisplay((NativeDisplayType) EGL_DEFAULT_DISPLAY);
|
||||
}
|
||||
if (EglDisplay == EGL_NO_DISPLAY)
|
||||
{
|
||||
os::Printer::log("Could not get OpenGL-ES2 display.");
|
||||
}
|
||||
|
||||
EGLint majorVersion, minorVersion;
|
||||
if (!eglInitialize(EglDisplay, &majorVersion, &minorVersion))
|
||||
{
|
||||
os::Printer::log("Could not initialize OpenGL-ES2 display.");
|
||||
}
|
||||
else
|
||||
{
|
||||
char text[64];
|
||||
sprintf(text, "EglDisplay initialized. Egl version %d.%d\n", majorVersion, minorVersion);
|
||||
os::Printer::log(text);
|
||||
}
|
||||
|
||||
EGLint attribs[] =
|
||||
{
|
||||
#if defined( _IRR_COMPILE_WITH_ANDROID_DEVICE_ )
|
||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
||||
EGL_BLUE_SIZE, 8,
|
||||
EGL_GREEN_SIZE, 8,
|
||||
EGL_RED_SIZE, 8,
|
||||
EGL_DEPTH_SIZE, 16,
|
||||
EGL_NONE
|
||||
#else
|
||||
EGL_RED_SIZE, 5,
|
||||
EGL_GREEN_SIZE, 5,
|
||||
EGL_BLUE_SIZE, 5,
|
||||
EGL_ALPHA_SIZE, params.WithAlphaChannel ? 1 : 0,
|
||||
EGL_BUFFER_SIZE, params.Bits,
|
||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
||||
//EGL_COLOR_BUFFER_TYPE, EGL_RGB_BUFFER,
|
||||
EGL_DEPTH_SIZE, params.ZBufferBits,
|
||||
EGL_STENCIL_SIZE, params.Stencilbuffer,
|
||||
EGL_SAMPLE_BUFFERS, params.AntiAlias ? 1 : 0,
|
||||
EGL_SAMPLES, params.AntiAlias,
|
||||
#ifdef EGL_VERSION_1_3
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
||||
#endif
|
||||
EGL_NONE, 0
|
||||
#endif
|
||||
};
|
||||
|
||||
EGLint num_configs;
|
||||
u32 steps=5;
|
||||
while (!eglChooseConfig(EglDisplay, attribs, &EglConfig, 1, &num_configs) || !num_configs)
|
||||
{
|
||||
switch (steps)
|
||||
{
|
||||
case 5: // samples
|
||||
if (attribs[19]>2)
|
||||
{
|
||||
--attribs[19];
|
||||
}
|
||||
else
|
||||
{
|
||||
attribs[17]=0;
|
||||
attribs[19]=0;
|
||||
--steps;
|
||||
}
|
||||
break;
|
||||
case 4: // alpha
|
||||
if (attribs[7])
|
||||
{
|
||||
attribs[7]=0;
|
||||
if (params.AntiAlias)
|
||||
{
|
||||
attribs[17]=1;
|
||||
attribs[19]=params.AntiAlias;
|
||||
steps=5;
|
||||
}
|
||||
}
|
||||
else
|
||||
--steps;
|
||||
break;
|
||||
case 3: // stencil
|
||||
if (attribs[15])
|
||||
{
|
||||
attribs[15]=0;
|
||||
if (params.AntiAlias)
|
||||
{
|
||||
attribs[17]=1;
|
||||
attribs[19]=params.AntiAlias;
|
||||
steps=5;
|
||||
}
|
||||
}
|
||||
else
|
||||
--steps;
|
||||
break;
|
||||
case 2: // depth size
|
||||
if (attribs[13]>16)
|
||||
{
|
||||
attribs[13]-=8;
|
||||
}
|
||||
else
|
||||
--steps;
|
||||
break;
|
||||
case 1: // buffer size
|
||||
if (attribs[9]>16)
|
||||
{
|
||||
attribs[9]-=8;
|
||||
}
|
||||
else
|
||||
--steps;
|
||||
break;
|
||||
default:
|
||||
os::Printer::log("Could not get config for OpenGL-ES2 display.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (params.AntiAlias && !attribs[17])
|
||||
os::Printer::log("No multisampling.");
|
||||
if (params.WithAlphaChannel && !attribs[7])
|
||||
os::Printer::log("No alpha.");
|
||||
if (params.Stencilbuffer && !attribs[15])
|
||||
os::Printer::log("No stencil buffer.");
|
||||
if (params.ZBufferBits > attribs[13])
|
||||
os::Printer::log("No full depth buffer.");
|
||||
if (params.Bits > attribs[9])
|
||||
os::Printer::log("No full color buffer.");
|
||||
#if defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_)
|
||||
/* EGL_NATIVE_VISUAL_ID is an attribute of the EGLConfig that is
|
||||
* guaranteed to be accepted by ANativeWindow_setBuffersGeometry().
|
||||
* As soon as we picked a EGLConfig, we can safely reconfigure the
|
||||
* ANativeWindow buffers to match, using EGL_NATIVE_VISUAL_ID. */
|
||||
EGLint format;
|
||||
eglGetConfigAttrib(EglDisplay, EglConfig, EGL_NATIVE_VISUAL_ID, &format);
|
||||
|
||||
ANativeWindow_setBuffersGeometry(EglWindow, 0, 0, format);
|
||||
#endif
|
||||
os::Printer::log(" Creating EglSurface with nativeWindow...");
|
||||
EglSurface = eglCreateWindowSurface(EglDisplay, EglConfig, EglWindow, NULL);
|
||||
if (EGL_NO_SURFACE == EglSurface)
|
||||
{
|
||||
os::Printer::log("FAILED\n");
|
||||
EglSurface = eglCreateWindowSurface(EglDisplay, EglConfig, 0, NULL);
|
||||
os::Printer::log("Creating EglSurface without nativeWindows...");
|
||||
}
|
||||
else
|
||||
os::Printer::log("SUCCESS\n");
|
||||
if (EGL_NO_SURFACE == EglSurface)
|
||||
{
|
||||
os::Printer::log("FAILED\n");
|
||||
os::Printer::log("Could not create surface for OpenGL-ES2 display.");
|
||||
}
|
||||
else
|
||||
os::Printer::log("SUCCESS\n");
|
||||
|
||||
#ifdef EGL_VERSION_1_2
|
||||
if (minorVersion>1)
|
||||
eglBindAPI(EGL_OPENGL_ES_API);
|
||||
#endif
|
||||
os::Printer::log("Creating EglContext...");
|
||||
EglContext = EGL_NO_CONTEXT;
|
||||
|
||||
if (!Params.ForceLegacyDevice)
|
||||
{
|
||||
os::Printer::log("Trying to create Context for OpenGL-ES3.");
|
||||
|
||||
EGLint contextAttrib[] =
|
||||
{
|
||||
#ifdef EGL_VERSION_1_3
|
||||
EGL_CONTEXT_CLIENT_VERSION, 3,
|
||||
#endif
|
||||
EGL_NONE, 0
|
||||
};
|
||||
|
||||
EglContext = eglCreateContext(EglDisplay, EglConfig, EGL_NO_CONTEXT, contextAttrib);
|
||||
}
|
||||
|
||||
if (EGL_NO_CONTEXT == EglContext)
|
||||
{
|
||||
os::Printer::log("Trying to create Context for OpenGL-ES2.");
|
||||
useCoreContext = false;
|
||||
|
||||
EGLint contextAttrib[] =
|
||||
{
|
||||
#ifdef EGL_VERSION_1_3
|
||||
EGL_CONTEXT_CLIENT_VERSION, 2,
|
||||
#endif
|
||||
EGL_NONE, 0
|
||||
};
|
||||
|
||||
EglContext = eglCreateContext(EglDisplay, EglConfig, EGL_NO_CONTEXT, contextAttrib);
|
||||
if (EGL_NO_CONTEXT == EglContext)
|
||||
{
|
||||
os::Printer::log("FAILED\n");
|
||||
os::Printer::log("Could not create Context for OpenGL-ES2 display.");
|
||||
}
|
||||
}
|
||||
|
||||
eglMakeCurrent(EglDisplay, EglSurface, EglSurface, EglContext);
|
||||
if (testEGLError())
|
||||
{
|
||||
os::Printer::log("Could not make Context current for OpenGL-ES2 display.");
|
||||
}
|
||||
#if defined(_IRR_COMPILE_WITH_EGL_)
|
||||
EglContext = new ContextEGL(params, data);
|
||||
useCoreContext = EglContext->isCoreContext();
|
||||
|
||||
genericDriverInit(params.WindowSize, params.Stencilbuffer);
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_ANDROID_DEVICE_
|
||||
int backingWidth;
|
||||
int backingHeight;
|
||||
eglQuerySurface(EglDisplay, EglSurface, EGL_WIDTH, &backingWidth);
|
||||
eglQuerySurface(EglDisplay, EglSurface, EGL_HEIGHT, &backingHeight);
|
||||
core::dimension2d<u32> WindowSize(backingWidth, backingHeight);
|
||||
CNullDriver::ScreenSize = WindowSize;
|
||||
#endif
|
||||
#elif defined(_IRR_COMPILE_WITH_IPHONE_DEVICE_)
|
||||
Device = device;
|
||||
|
||||
|
||||
// set vsync
|
||||
if (params.Vsync)
|
||||
eglSwapInterval(EglDisplay, 1);
|
||||
#elif defined(GL_ES_VERSION_2_0)
|
||||
glGenFramebuffers(1, &ViewFramebuffer);
|
||||
glGenRenderbuffers(1, &ViewRenderbuffer);
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, ViewRenderbuffer);
|
||||
|
||||
#if defined(_IRR_COMPILE_WITH_IPHONE_DEVICE_)
|
||||
ExposedData.OGLESIPhone.AppDelegate = Device;
|
||||
Device->displayInitialize(&ExposedData.OGLESIPhone.Context, &ExposedData.OGLESIPhone.View);
|
||||
#endif
|
||||
|
||||
GLint backingWidth;
|
||||
GLint backingHeight;
|
||||
@ -342,32 +113,11 @@ namespace video
|
||||
if (BridgeCalls)
|
||||
delete BridgeCalls;
|
||||
|
||||
#if defined(EGL_VERSION_1_0)
|
||||
eglMakeCurrent(EglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
#if defined(_IRR_COMPILE_WITH_EGL_)
|
||||
delete EglContext;
|
||||
|
||||
if (EglContext != EGL_NO_CONTEXT)
|
||||
{
|
||||
eglDestroyContext(EglDisplay, EglContext);
|
||||
EglContext = EGL_NO_CONTEXT;
|
||||
}
|
||||
|
||||
if (EglSurface != EGL_NO_SURFACE)
|
||||
{
|
||||
eglDestroySurface(EglDisplay, EglSurface);
|
||||
EglSurface = EGL_NO_SURFACE;
|
||||
}
|
||||
|
||||
if (EglDisplay != EGL_NO_DISPLAY)
|
||||
{
|
||||
eglTerminate(EglDisplay);
|
||||
EglDisplay = EGL_NO_DISPLAY;
|
||||
}
|
||||
|
||||
#if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_)
|
||||
if (HDc)
|
||||
ReleaseDC((HWND)EglWindow, HDc);
|
||||
#endif
|
||||
#elif defined(GL_ES_VERSION_2_0)
|
||||
#elif defined(_IRR_COMPILE_WITH_IPHONE_DEVICE_)
|
||||
if (0 != ViewFramebuffer)
|
||||
{
|
||||
glDeleteFramebuffers(1,&ViewFramebuffer);
|
||||
@ -390,41 +140,12 @@ namespace video
|
||||
// METHODS
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
void COGLES2Driver::reloadEGLSurface(void* window)
|
||||
{
|
||||
os::Printer::log("Reload EGL surface.");
|
||||
|
||||
#ifdef EGL_VERSION_1_0
|
||||
#if defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_)
|
||||
EglWindow = (ANativeWindow*)window;
|
||||
#endif
|
||||
|
||||
if (!EglWindow)
|
||||
os::Printer::log("Invalid Egl window.");
|
||||
|
||||
eglMakeCurrent(EglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
|
||||
eglDestroySurface(EglDisplay, EglSurface);
|
||||
|
||||
EglSurface = eglCreateWindowSurface(EglDisplay, EglConfig, EglWindow, 0);
|
||||
|
||||
if (EGL_NO_SURFACE == EglSurface)
|
||||
os::Printer::log("Could not create EGL surface.");
|
||||
|
||||
eglMakeCurrent(EglDisplay, EglSurface, EglSurface, EglContext);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
bool COGLES2Driver::genericDriverInit(const core::dimension2d<u32>& screenSize, bool stencilBuffer)
|
||||
{
|
||||
Name = glGetString(GL_VERSION);
|
||||
printVersion();
|
||||
|
||||
#if defined(EGL_VERSION_1_0)
|
||||
os::Printer::log(eglQueryString(EglDisplay, EGL_CLIENT_APIS));
|
||||
#endif
|
||||
|
||||
// print renderer information
|
||||
vendorName = glGetString(GL_VENDOR);
|
||||
os::Printer::log(vendorName.c_str(), ELL_INFORMATION);
|
||||
@ -433,11 +154,7 @@ namespace video
|
||||
for (i = 0; i < MATERIAL_MAX_TEXTURES; ++i)
|
||||
CurrentTexture[i] = 0;
|
||||
// load extensions
|
||||
initExtensions(this,
|
||||
#if defined(EGL_VERSION_1_0)
|
||||
EglDisplay,
|
||||
#endif
|
||||
stencilBuffer);
|
||||
initExtensions(this, stencilBuffer);
|
||||
|
||||
if (!BridgeCalls)
|
||||
BridgeCalls = new COGLES2CallBridge(this);
|
||||
@ -713,26 +430,20 @@ namespace video
|
||||
{
|
||||
CNullDriver::endScene();
|
||||
|
||||
#if defined(EGL_VERSION_1_0)
|
||||
eglSwapBuffers(EglDisplay, EglSurface);
|
||||
EGLint g = eglGetError();
|
||||
if (EGL_SUCCESS != g)
|
||||
#if defined(_IRR_COMPILE_WITH_EGL_)
|
||||
|
||||
bool res = EglContext->swapBuffers();
|
||||
|
||||
if (!res)
|
||||
{
|
||||
if (EGL_CONTEXT_LOST == g)
|
||||
{
|
||||
// o-oh, ogl-es has lost contexts...
|
||||
os::Printer::log("Context lost, please restart your app.");
|
||||
}
|
||||
else
|
||||
os::Printer::log("Could not swap buffers for OpenGL-ES2 driver.");
|
||||
os::Printer::log("Could not swap buffers for OpenGL-ES2 driver.");
|
||||
return false;
|
||||
}
|
||||
#elif defined(GL_ES_VERSION_2_0)
|
||||
|
||||
#elif defined(_IRR_COMPILE_WITH_IPHONE_DEVICE_)
|
||||
glFlush();
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, ViewRenderbuffer);
|
||||
#if defined(_IRR_COMPILE_WITH_IPHONE_DEVICE_)
|
||||
Device->displayEnd();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return true;
|
||||
@ -1896,65 +1607,6 @@ namespace video
|
||||
#endif
|
||||
}
|
||||
|
||||
//! prints error if an error happened.
|
||||
bool COGLES2Driver::testEGLError()
|
||||
{
|
||||
#if defined(EGL_VERSION_1_0) && defined(_DEBUG)
|
||||
EGLint g = eglGetError();
|
||||
switch (g)
|
||||
{
|
||||
case EGL_SUCCESS:
|
||||
return false;
|
||||
case EGL_NOT_INITIALIZED :
|
||||
os::Printer::log("Not Initialized", ELL_ERROR);
|
||||
break;
|
||||
case EGL_BAD_ACCESS:
|
||||
os::Printer::log("Bad Access", ELL_ERROR);
|
||||
break;
|
||||
case EGL_BAD_ALLOC:
|
||||
os::Printer::log("Bad Alloc", ELL_ERROR);
|
||||
break;
|
||||
case EGL_BAD_ATTRIBUTE:
|
||||
os::Printer::log("Bad Attribute", ELL_ERROR);
|
||||
break;
|
||||
case EGL_BAD_CONTEXT:
|
||||
os::Printer::log("Bad Context", ELL_ERROR);
|
||||
break;
|
||||
case EGL_BAD_CONFIG:
|
||||
os::Printer::log("Bad Config", ELL_ERROR);
|
||||
break;
|
||||
case EGL_BAD_CURRENT_SURFACE:
|
||||
os::Printer::log("Bad Current Surface", ELL_ERROR);
|
||||
break;
|
||||
case EGL_BAD_DISPLAY:
|
||||
os::Printer::log("Bad Display", ELL_ERROR);
|
||||
break;
|
||||
case EGL_BAD_SURFACE:
|
||||
os::Printer::log("Bad Surface", ELL_ERROR);
|
||||
break;
|
||||
case EGL_BAD_MATCH:
|
||||
os::Printer::log("Bad Match", ELL_ERROR);
|
||||
break;
|
||||
case EGL_BAD_PARAMETER:
|
||||
os::Printer::log("Bad Parameter", ELL_ERROR);
|
||||
break;
|
||||
case EGL_BAD_NATIVE_PIXMAP:
|
||||
os::Printer::log("Bad Native Pixmap", ELL_ERROR);
|
||||
break;
|
||||
case EGL_BAD_NATIVE_WINDOW:
|
||||
os::Printer::log("Bad Native Window", ELL_ERROR);
|
||||
break;
|
||||
case EGL_CONTEXT_LOST:
|
||||
os::Printer::log("Context Lost", ELL_ERROR);
|
||||
break;
|
||||
};
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void COGLES2Driver::setRenderStates3DMode()
|
||||
{
|
||||
if (useCoreContext)
|
||||
|
@ -10,13 +10,7 @@
|
||||
|
||||
#include "IrrCompileConfig.h"
|
||||
|
||||
#if defined(_IRR_WINDOWS_API_)
|
||||
// include windows headers for HWND
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#elif defined(_IRR_COMPILE_WITH_OSX_DEVICE_)
|
||||
#if defined(_IRR_COMPILE_WITH_OSX_DEVICE_)
|
||||
#include "MacOSX/CIrrDeviceMacOSX.h"
|
||||
#elif defined(_IRR_COMPILE_WITH_IPHONE_DEVICE_)
|
||||
#include "iOS/CIrrDeviceiOS.h"
|
||||
@ -30,11 +24,8 @@
|
||||
#include <OpenGLES/ES2/gl.h>
|
||||
#include <OpenGLES/ES2/glext.h>
|
||||
#elif defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_)
|
||||
#include <EGL/egl.h>
|
||||
#include <GLES2/gl2.h>
|
||||
#include "android_native_app_glue.h"
|
||||
#else
|
||||
#include <EGL/eglplatform.h>
|
||||
#endif
|
||||
|
||||
#include "CNullDriver.h"
|
||||
@ -43,7 +34,6 @@
|
||||
#include "fast_atof.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma comment(lib, "libEGL.lib")
|
||||
#pragma comment(lib, "libGLESv2.lib")
|
||||
#endif
|
||||
#include "COGLES2ExtensionHandler.h"
|
||||
@ -58,6 +48,7 @@ namespace video
|
||||
class COGLES2Renderer2D;
|
||||
class COGLES2NormalMapRenderer;
|
||||
class COGLES2ParallaxMapRenderer;
|
||||
class ContextEGL;
|
||||
|
||||
class COGLES2Driver : public CNullDriver, public IMaterialRendererServices, public COGLES2ExtensionHandler
|
||||
{
|
||||
@ -340,9 +331,6 @@ namespace video
|
||||
//! checks if an OpenGL error has happend and prints it
|
||||
bool testGLError();
|
||||
|
||||
//! checks if an OGLES1 error has happend and prints it
|
||||
bool testEGLError();
|
||||
|
||||
//! Set/unset a clipping plane.
|
||||
virtual bool setClipPlane(u32 index, const core::plane3df& plane, bool enable = false);
|
||||
|
||||
@ -382,8 +370,6 @@ namespace video
|
||||
//! Get bridge calls.
|
||||
COGLES2CallBridge* getBridgeCalls() const;
|
||||
|
||||
void reloadEGLSurface(void* window);
|
||||
|
||||
private:
|
||||
// Bridge calls.
|
||||
COGLES2CallBridge* BridgeCalls;
|
||||
@ -466,21 +452,15 @@ namespace video
|
||||
SColorf AmbientLight;
|
||||
|
||||
COGLES2Renderer2D* MaterialRenderer2D;
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_
|
||||
HDC HDc;
|
||||
|
||||
#if defined(_IRR_COMPILE_WITH_EGL_)
|
||||
ContextEGL* EglContext;
|
||||
#endif
|
||||
#if defined(_IRR_COMPILE_WITH_IPHONE_DEVICE_)
|
||||
CIrrDeviceIPhone* Device;
|
||||
GLuint ViewFramebuffer;
|
||||
GLuint ViewRenderbuffer;
|
||||
GLuint ViewDepthRenderbuffer;
|
||||
#else
|
||||
NativeWindowType EglWindow;
|
||||
void* EglDisplay;
|
||||
void* EglSurface;
|
||||
void* EglContext;
|
||||
EGLConfig EglConfig;
|
||||
#endif
|
||||
|
||||
SIrrlichtCreationParameters Params;
|
||||
|
@ -158,7 +158,7 @@ namespace video
|
||||
};
|
||||
|
||||
COGLES2ExtensionHandler::COGLES2ExtensionHandler() :
|
||||
EGLVersion(0), Version(0), MaxTextureUnits(0), MaxSupportedTextures(0),
|
||||
Version(0), MaxTextureUnits(0), MaxSupportedTextures(0),
|
||||
MaxAnisotropy(1), MaxIndices(0xffff), MaxTextureSize(1),
|
||||
MaxTextureLODBias(0.f),
|
||||
StencilBuffer(false)
|
||||
@ -176,17 +176,8 @@ namespace video
|
||||
|
||||
|
||||
void COGLES2ExtensionHandler::initExtensions(COGLES2Driver* driver,
|
||||
#ifdef EGL_VERSION_1_0
|
||||
EGLDisplay display,
|
||||
#endif
|
||||
bool withStencil)
|
||||
{
|
||||
#ifdef EGL_VERSION_1_0
|
||||
const f32 egl_ver = core::fast_atof(reinterpret_cast<const c8*>(eglQueryString(display, EGL_VERSION)));
|
||||
EGLVersion = static_cast<u16>(core::floor32(egl_ver)*100+core::round32(core::fract(egl_ver)*10.0f));
|
||||
core::stringc eglExtensions = eglQueryString(display, EGL_EXTENSIONS);
|
||||
os::Printer::log(eglExtensions.c_str());
|
||||
#endif
|
||||
const core::stringc stringVer(glGetString(GL_VERSION));
|
||||
const f32 ogl_ver = core::fast_atof(stringVer.c_str() + 10);
|
||||
Version = static_cast<u16>(core::floor32(ogl_ver) * 100 + core::round32(core::fract(ogl_ver) * 10.0f));
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include <OpenGLES/ES2/gl.h>
|
||||
#include <OpenGLES/ES2/glext.h>
|
||||
#else
|
||||
#include <EGL/egl.h>
|
||||
#include <GLES2/gl2.h>
|
||||
// seems to be missing...
|
||||
typedef char GLchar;
|
||||
@ -232,13 +231,9 @@ namespace video
|
||||
void dump() const;
|
||||
|
||||
void initExtensions(COGLES2Driver* driver,
|
||||
#ifdef EGL_VERSION_1_0
|
||||
EGLDisplay display,
|
||||
#endif
|
||||
bool withStencil);
|
||||
|
||||
protected:
|
||||
u16 EGLVersion;
|
||||
u16 Version;
|
||||
u8 MaxTextureUnits;
|
||||
u8 MaxSupportedTextures;
|
||||
|
Loading…
x
Reference in New Issue
Block a user