GLES2 for android devices by default

This commit is contained in:
Lucas Baudin 2016-02-25 12:06:54 +01:00
parent d4d3817d63
commit 02808cdfd0
8 changed files with 33 additions and 5 deletions

Binary file not shown.

View File

@ -233,6 +233,8 @@ define out. */
#ifndef IRR_OGLES2_SHADER_PATH #ifndef IRR_OGLES2_SHADER_PATH
#ifdef _IRR_COMPILE_WITH_IPHONE_DEVICE_ #ifdef _IRR_COMPILE_WITH_IPHONE_DEVICE_
#define IRR_OGLES2_SHADER_PATH "" #define IRR_OGLES2_SHADER_PATH ""
#elif defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_)
#define IRR_OGLES2_SHADER_PATH "media/Shaders/"
#else #else
#define IRR_OGLES2_SHADER_PATH "../../media/Shaders/" #define IRR_OGLES2_SHADER_PATH "../../media/Shaders/"
#endif #endif

Binary file not shown.

View File

@ -24,6 +24,7 @@ namespace io
CAndroidAssetReader::CAndroidAssetReader(const io::path &filename) CAndroidAssetReader::CAndroidAssetReader(const io::path &filename)
{ {
__android_log_print(ANDROID_LOG_VERBOSE, "native-activity", "path %s", core::stringc(filename).c_str());
AssetManager = CIrrDeviceAndroid::getAndroidApp()->activity->assetManager; AssetManager = CIrrDeviceAndroid::getAndroidApp()->activity->assetManager;
Asset = AAssetManager_open(AssetManager, Asset = AAssetManager_open(AssetManager,
core::stringc(filename).c_str(), core::stringc(filename).c_str(),

View File

@ -92,15 +92,15 @@ CIrrDeviceAndroid::CIrrDeviceAndroid(const SIrrlichtCreationParameters& param)
// Create cursor control // Create cursor control
CursorControl = new CCursorControl(this); CursorControl = new CCursorControl(this);
io::CAndroidAssetFileArchive *assets = io::createAndroidAssetFileArchive(false, false);
assets->addDirectory("media");
FileSystem->addFileArchive(assets);
// Create the driver. // Create the driver.
createDriver(); createDriver();
if (VideoDriver) if (VideoDriver)
createGUIAndScene(); createGUIAndScene();
io::CAndroidAssetFileArchive *assets = io::createAndroidAssetFileArchive(false, false);
assets->addDirectory("media");
FileSystem->addFileArchive(assets);
// TODO // TODO
// //
// if engine->app->savedState is not NULL then use postEventFromUser() // if engine->app->savedState is not NULL then use postEventFromUser()

View File

@ -68,6 +68,9 @@ namespace video
EglDisplay = eglGetDisplay((NativeDisplayType)ExposedData.OpenGLLinux.X11Display); EglDisplay = eglGetDisplay((NativeDisplayType)ExposedData.OpenGLLinux.X11Display);
#elif defined(_IRR_COMPILE_WITH_IPHONE_DEVICE_) #elif defined(_IRR_COMPILE_WITH_IPHONE_DEVICE_)
Device = device; Device = device;
#elif defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_)
EglWindow = ((struct android_app *)(params.PrivateData))->window;
EglDisplay = EGL_NO_DISPLAY;
#endif #endif
#ifdef EGL_VERSION_1_0 #ifdef EGL_VERSION_1_0
if (EglDisplay == EGL_NO_DISPLAY) if (EglDisplay == EGL_NO_DISPLAY)
@ -94,6 +97,14 @@ namespace video
EGLint attribs[] = 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_RED_SIZE, 5,
EGL_GREEN_SIZE, 5, EGL_GREEN_SIZE, 5,
EGL_BLUE_SIZE, 5, EGL_BLUE_SIZE, 5,
@ -109,6 +120,7 @@ namespace video
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
#endif #endif
EGL_NONE, 0 EGL_NONE, 0
#endif
}; };
EGLint contextAttrib[] = EGLint contextAttrib[] =
{ {
@ -196,6 +208,16 @@ namespace video
os::Printer::log("No full depth buffer."); os::Printer::log("No full depth buffer.");
if (params.Bits > attribs[9]) if (params.Bits > attribs[9])
os::Printer::log("No full color buffer."); 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, config, EGL_NATIVE_VISUAL_ID, &format);
ANativeWindow_setBuffersGeometry(EglWindow, 0, 0, format);
#endif
os::Printer::log(" Creating EglSurface with nativeWindow..."); os::Printer::log(" Creating EglSurface with nativeWindow...");
EglSurface = eglCreateWindowSurface(EglDisplay, config, EglWindow, NULL); EglSurface = eglCreateWindowSurface(EglDisplay, config, EglWindow, NULL);
if (EGL_NO_SURFACE == EglSurface) if (EGL_NO_SURFACE == EglSurface)
@ -406,6 +428,7 @@ namespace video
core::stringc FPVSPath = IRR_OGLES2_SHADER_PATH; core::stringc FPVSPath = IRR_OGLES2_SHADER_PATH;
FPVSPath += "COGLES2FixedPipeline.vsh"; FPVSPath += "COGLES2FixedPipeline.vsh";
os::Printer::log(FPVSPath.c_str());
core::stringc FPFSPath = IRR_OGLES2_SHADER_PATH; core::stringc FPFSPath = IRR_OGLES2_SHADER_PATH;
FPFSPath += "COGLES2FixedPipeline.fsh"; FPFSPath += "COGLES2FixedPipeline.fsh";

View File

@ -29,6 +29,10 @@
#if defined(_IRR_COMPILE_WITH_IPHONE_DEVICE_) #if defined(_IRR_COMPILE_WITH_IPHONE_DEVICE_)
#include <OpenGLES/ES2/gl.h> #include <OpenGLES/ES2/gl.h>
#include <OpenGLES/ES2/glext.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 #else
#include <EGL/eglplatform.h> #include <EGL/eglplatform.h>
#endif #endif

View File

@ -43,8 +43,6 @@ COGLES1Driver::COGLES1Driver(const SIrrlichtCreationParameters& params,
,ViewDepthRenderbuffer(0) ,ViewDepthRenderbuffer(0)
#endif #endif
{ {
__android_log_print(ANDROID_LOG_VERBOSE, "native-activity", "frame %d", __LINE__);
__android_log_print(ANDROID_LOG_VERBOSE, "native-activity", "frame %s %d", __FILE__, __LINE__);
#ifdef _DEBUG #ifdef _DEBUG
setDebugName("COGLESDriver"); setDebugName("COGLESDriver");
#endif #endif