Permalink
Browse files

ecere: Various tweaks in preparation for Android support

  • Loading branch information...
jerstlouis committed Sep 13, 2012
1 parent 9d2d69f commit 72ff7a2706aa9cf206f2e907dc93c3d18849a90b
@@ -1898,14 +1898,23 @@ public char * PrintLnString(typed_object object, ...)
return string;
}
+#if defined(__ANDROID__)
+#include <android/log.h>
+#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "ecere-app", __VA_ARGS__))
+#endif
+
public void PrintLn(typed_object object, ...)
{
va_list args;
char buffer[4096];
va_start(args, object);
PrintStdArgsToBuffer(buffer, sizeof(buffer), object, args);
va_end(args);
+#if defined(__ANDROID__)
+ LOGI("%s", buffer);
+#else
puts(buffer);
+#endif
}
public void Print(typed_object object, ...)
View
@@ -289,7 +289,11 @@ void * Instance_Module_Load(char * name, void ** Load, void ** Unload)
FreeLibrary(library);
}
#elif defined(__unix__) || defined(__APPLE__)
+#if defined(__ANDROID__)
+ sprintf(fileName, "/data/data/com.ecere.%s/lib/lib", name);
+#else
strcpy(fileName, "lib");
+#endif
strcat(fileName, name);
GetExtension(fileName, extension);
if(!extension[0])
View
@@ -1123,7 +1123,7 @@ private:
DisplaySystem displaySystem;
void * window;
public int width, height;
-
+
Mutex mutex { };
int current;
@@ -60,8 +60,7 @@ class PNGFormat : BitmapFormat
{
bool result = false;
- png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
- null, null, null);
+ png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, null, null, null);
if(png_ptr)
{
@@ -2874,7 +2874,7 @@ public class LFBDisplayDriver : DisplayDriver
}
ReleaseDC(0, hdc);
}
- #else
+ #elif !defined(ECERE_NOFONTCONFIG)
{
char * fileName2;
FcResult result = 0;
@@ -3086,7 +3086,7 @@ public class LFBDisplayDriver : DisplayDriver
GetWindowsDirectory(fileName, MAX_LOCATION);
PathCat(fileName, "fonts");
PathCat(fileName, fontName);
-#elif defined(ECERE_NOFONTCONFIG)
+#elif !defined(ECERE_NOFONTCONFIG)
if(getenv("ECERE_FONTS"))
{
strcpy(fileName, ecereFonts);
@@ -3335,7 +3335,7 @@ public class LFBDisplayDriver : DisplayDriver
if(fontEntryNum == MAX_FONT_LINK_ENTRIES)
{
-#if !defined(__WIN32__)
+#if !defined(__WIN32__) && !defined(ECERE_NOFONTCONFIG)
int fontID = 0;
double fontSize = font.size;
FcResult result = 0;
@@ -3353,7 +3353,7 @@ public class LFBDisplayDriver : DisplayDriver
#endif
continue;
-#if !defined(__WIN32__)
+#if !defined(__WIN32__) && !defined(ECERE_NOFONTCONFIG)
{
charSet = FcCharSetCreate();
FcCharSetAddChar(charSet, testChar);
@@ -16,6 +16,10 @@ namespace gfx::drivers;
#else
+#if defined(__ANDROID__)
+
+#else
+
#define property _property
#define new _new
#define class _class
@@ -54,6 +58,8 @@ namespace gfx::drivers;
#endif
+#endif
+
#if defined(__APPLE__)
#include <OpenGl/gl.h>
#endif
@@ -66,15 +72,28 @@ namespace gfx::drivers;
#include <windows.h>
#endif
+#if defined(__ANDROID__)
+
+#include <GLES/gl.h>
+#include <EGL/egl.h>
+
+#else
+
#include <GL/gl.h>
#include <GL/glext.h>
+#endif
+
import "Display"
#if defined(__unix__)
+
+#ifndef __ANDROID__
import "XInterface"
#endif
+#endif
+
#define glLoadMatrix glLoadMatrixd
#define glMultMatrix glMultMatrixd
#define glGetMatrix glGetDoublev
@@ -452,7 +471,10 @@ class OpenGLDisplayDriver : DisplayDriver
/*#if defined(__APPLE__)
//glXMakeCurrent(xGlobalDisplay, displaySystem.window, oglSystem.glContext);
#else*/
+ #if defined(__ANDROID__)
+ #else
glXMakeCurrent(xGlobalDisplay, oglSystem.dummyGLXPixmap /*displaySystem.window /*DefaultRootWindow(xGlobalDisplay)*/, oglSystem.glContext);
+ #endif
//#endif
//previous = oglSystem.glContext;
#endif
@@ -466,7 +488,10 @@ class OpenGLDisplayDriver : DisplayDriver
wglMakeCurrent(null, null);
#elif defined(__unix__)
// printf("Making NULL current\n");
+ #if defined(__ANDROID__)
+ #else
glXMakeCurrent(xGlobalDisplay, None, null);
+ #endif
// previous = null;
#endif
}
@@ -482,7 +507,10 @@ class OpenGLDisplayDriver : DisplayDriver
#elif defined(__unix__)
// if(previous) glXMakeCurrent(xGlobalDisplay, None, null);
// printf(" Making DISPLAY current\n");
+ #if defined(__ANDROID__)
+ #else
glXMakeCurrent(xGlobalDisplay, (int)display.window, oglDisplay.glContext);
+ #endif
#endif
return true;
}
@@ -521,6 +549,8 @@ class OpenGLDisplayDriver : DisplayDriver
if(oglDisplay.memBitmap) DeleteObject(oglDisplay.memBitmap);
#elif defined(__unix__)
+ #if defined(__ANDROID__)
+ #else
if(oglDisplay.shapePixmap)
XFreePixmap(xGlobalDisplay, oglDisplay.shapePixmap);
if(oglDisplay.pixmap)
@@ -552,6 +582,7 @@ class OpenGLDisplayDriver : DisplayDriver
if(oglDisplay.glContext)
glXDestroyContext(xGlobalDisplay, oglDisplay.glContext);
+ #endif
#endif
delete oglDisplay.flippingBuffer;
delete oglDisplay;
@@ -683,6 +714,9 @@ class OpenGLDisplayDriver : DisplayDriver
}
}
#elif defined(__unix__)
+ #if defined(__ANDROID__)
+ result = true;
+ #else
int attrList[] =
{
#ifndef ECERE_MINIGLX
@@ -714,6 +748,7 @@ class OpenGLDisplayDriver : DisplayDriver
result = true;
}
}
+ #endif
#endif
displaySystem.flags.alpha = true;
@@ -737,7 +772,8 @@ class OpenGLDisplayDriver : DisplayDriver
DestroyWindow(oglSystem.hwnd);
#elif defined(__unix__)
-
+ #if defined(__ANDROID__)
+ #else
if(oglSystem.visualInfo)
{
#ifdef ECERE_MINIGLX
@@ -751,6 +787,7 @@ class OpenGLDisplayDriver : DisplayDriver
glXDestroyGLXPixmap(xGlobalDisplay, oglSystem.dummyGLXPixmap);
if(oglSystem.dummyPixmap);
XFreePixmap(xGlobalDisplay, oglSystem.dummyPixmap);
+ #endif
#endif
delete oglSystem;
}
@@ -780,6 +817,8 @@ class OpenGLDisplayDriver : DisplayDriver
else
ReleaseDC(display.window, oglDisplay.hdc);
#elif defined(__unix__)
+ #if defined(__ANDROID__)
+ #else
XVisualInfo * visualInfo = null;
/*
int attrib[] =
@@ -843,6 +882,7 @@ class OpenGLDisplayDriver : DisplayDriver
glXMakeCurrent(xGlobalDisplay, (int)display.window, oglDisplay.glContext);
result = true;
}
+ #endif
#endif
}
#if defined(__WIN32__) || defined(USEPBUFFER)
@@ -881,7 +921,11 @@ class OpenGLDisplayDriver : DisplayDriver
#if defined(__WIN32__)
wglMakeCurrent(null, null);
#elif defined(__unix__)
+ #if defined(__ANDROID__)
+ result = true;
+ #else
glXMakeCurrent(xGlobalDisplay, None, null);
+ #endif
#endif
return result;
@@ -1053,6 +1097,9 @@ class OpenGLDisplayDriver : DisplayDriver
ReleaseDC(display.window, hdc);
}
#elif defined(__unix__)
+ #if defined(__ANDROID__)
+ result = true;
+ #else
int attrib[] =
{
GLX_DOUBLEBUFFER, True,
@@ -1208,12 +1255,18 @@ class OpenGLDisplayDriver : DisplayDriver
}
XFree(config);
}
+ #endif
#endif
CreateDisplay(display);
#if defined(__WIN32__)
wglMakeCurrent(oglDisplay.hdc, oglDisplay.glrc);
#elif defined(__unix__)
+ #if defined(__ANDROID__)
+ width = eglWidth;
+ height = eglHeight;
+ #else
glXMakeCurrent(xGlobalDisplay, (int)display.window, oglDisplay.glContext);
+ #endif
#endif
}
else
@@ -1340,6 +1393,8 @@ class OpenGLDisplayDriver : DisplayDriver
ReleaseDC(0, hdc);
#elif defined(__unix__)
+ #if defined(__ANDROID__)
+ #else
XTransform transform =
{
{
@@ -1357,6 +1412,7 @@ class OpenGLDisplayDriver : DisplayDriver
XShapeCombineMask(xGlobalDisplay, display.window, 2, 0, 0, oglDisplay.shapePixmap, ShapeSet);
#endif
XFlush(xGlobalDisplay);
+ #endif
#endif
}
}
@@ -1367,7 +1423,11 @@ class OpenGLDisplayDriver : DisplayDriver
//wglSwapLayerBuffers(oglDisplay.hdc,WGL_SWAP_MAIN_PLANE);
SwapBuffers(oglDisplay.hdc);
#elif defined(__unix__)
+ #if defined(__ANDROID__)
+ eglSwapBuffers(eglDisplay, eglSurface);
+ #else
glXSwapBuffers(xGlobalDisplay, (int)display.window);
+ #endif
#endif
}
//Logf("Out of DisplayScreen\n");
Oops, something went wrong.

0 comments on commit 72ff7a2

Please sign in to comment.