*/}}
YimingWu 6 місяців тому
батько
коміт
0d4a8648fa
8 змінених файлів з 115 додано та 70 видалено
  1. 19 8
      CMakeLists.txt
  2. 1 1
      la_animation.c
  3. 8 8
      la_controllers.c
  4. 4 4
      la_data.c
  5. 24 17
      la_interface.h
  6. 38 28
      la_kernel.c
  7. 20 3
      la_util.h
  8. 1 1
      nanovg/nanovg_gl.h

+ 19 - 8
CMakeLists.txt

@@ -17,23 +17,29 @@ endif()
 
 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR})
 
-find_package(OpenGL REQUIRED)
-find_package(X11 REQUIRED)
-find_package(Freetype REQUIRED)
-find_package(GLEW REQUIRED)
-find_package(LuaJIT)
-find_package(PNG)
+if(${LAGUI_ANDROID} EQUAL True)
+    find_package(OpenGL REQUIRED)
+    find_package(X11 REQUIRED)
+    find_package(Freetype REQUIRED)
+    find_package(GLEW REQUIRED)
+    find_package(LuaJIT)
+    find_package(PNG)
+endif()
 
 SET(LAGUI_USE_LUAJIT true CACHE BOOL "Whether to use LuaJIT in LaGUI")
-if(${LuaJIT_FOUND} AND ${LAGUI_USE_LUAJIT})
+if((${LuaJIT_FOUND}) AND (${LAGUI_USE_LUAJIT}))
     add_definitions(-DLA_WITH_LUAJIT)
 endif()
 
 SET(LAGUI_USE_PNG true CACHE BOOL "Whether to use PNG in LaGUI")
-if(${PNG_FOUND} AND ${LAGUI_USE_PNG})
+if((${PNG_FOUND}) AND (${LAGUI_USE_PNG}))
     add_definitions(-DLA_WITH_PNG)
 endif()
 
+if(${LAGUI_ANDROID})
+    add_definitions(-DLAGUI_ANDROID)
+endif()
+
 set(CMAKE_THREAD_PREFER_PTHREAD ON)
 set(THREADS_PREFER_PTHREAD_FLAG ON)
 find_package(Threads REQUIRED)
@@ -50,6 +56,11 @@ file(GLOB HEADER_FILES
 add_definitions(-DLAGUI_FONT_CUSTOM_PATH=\"${LAGUI_FONT_CUSTOM_PATH}\")
 add_definitions(-w)
 
+if(${LAGUI_ANDROID})
+    INCLUDE_DIRECTORIES(${FREETYPE_SRC_DIR}/include)
+    INCLUDE_DIRECTORIES(${ANDROID_NDK}/sources/android/native_app_glue)
+endif()
+
 include_directories(
 	${CMAKE_SOURCE_DIR}
 	${X11_INCLUDE_DIR}

+ 1 - 1
la_animation.c

@@ -137,7 +137,7 @@ laActionKey* laAnimationInsertKeyFrame(laAction* aa, void* hyper1, laProp* p, in
             if(error) *error=2; return 0;
         }
     }
-    laActionChannel* ac=laAnimationEnsureChannel(aa,hyper1,p); if(!ac || !ac->AP || !ac->AP->For) return;
+    laActionChannel* ac=laAnimationEnsureChannel(aa,hyper1,p); if(!ac || !ac->AP || !ac->AP->For) return 0;
     int frame=LA_ACTION_FRAME(aa,-1);
     laActionKey* ak=laAnimationEnsureFrame(ac,frame);
     laAnimationStoreKeyValue(ac,ak);

+ 8 - 8
la_controllers.c

@@ -20,7 +20,7 @@
 
 #include <math.h>
 
-#ifdef __linux__
+#ifdef LA_LINUX
 #include <fcntl.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -61,7 +61,7 @@ int la_IdentifyControllerInternalType(char* name){
 
 void la_EnsureControllerNames(laController* c){
     laPropContainer*pc=la_EnsureSubTarget(LA_PROP_CONTROLLER,c);
-    if(!pc){ return c; }
+    if(!pc){ return; }
     for(laProp* p=pc->Props.pFirst;p;p=p->Item.pNext){
         if(p->PropertyType & LA_PROP_INT && p->Offset){ int off=p->Offset;
             if(off >= offsetof(laController,AxisValues[0]) && off <= offsetof(laController,AxisValues[LA_JS_MAX_AXES-1])){
@@ -109,7 +109,7 @@ void la_ReadControllerAxisLimit(laController* c, int i, int Min, int Max){
 }
 
 int la_ControllerButtonToMap(int btn){
-#ifdef __linux__
+#ifdef LA_LINUX
     if(btn<BTN_MISC) return -1;
     if(btn<=BTN_GEAR_UP) return btn-BTN_MISC;
     if(btn<BTN_DPAD_UP) return -1;
@@ -126,7 +126,7 @@ int la_ControllerButtonToIndex(laController* c,int btn){
     int map=la_ControllerButtonToMap(btn); if(map<0) return -1; return c->ButtonsMap[map];
 }
 int la_ControllerAxisToMap(int abs){
-#ifdef __linux__
+#ifdef LA_LINUX
     if(abs<ABS_X) return -1; if(abs>ABS_MAX) return -1;
     return abs;
 #endif
@@ -155,7 +155,7 @@ int laControllerIDGetButton(int id, char* name){
 }
 
 void la_InitControllers(){
-#ifdef __linux__
+#ifdef LA_LINUX
     char path[32]="/dev/input/js";
     char name[128]={0};
     int numpos=strlen(path);
@@ -203,7 +203,7 @@ void la_InitControllers(){
 }
 
 void la_UpdateControllerStatus(){
-#ifdef __linux__
+#ifdef LA_LINUX
     struct input_event event; int HasEvent=0;
     for(laController* c=MAIN.Controllers.pFirst;c;c=c->Item.pNext){ if(c->Error) continue;
         if(!c->Error && !c->fd){ c->fd=open(SSTR(c->Path), O_RDWR | O_NONBLOCK); if(c->fd<0){ c->Error=1; } continue; }
@@ -260,7 +260,7 @@ void la_RefreshControllers(){
 }
 int OPINV_RefreshControllers(laOperator* a, laEvent* e){
     la_RefreshControllers();
-#ifdef __linux__
+#ifdef LA_LINUX
     la_ScanWacomDevices(MAIN.dpy,XIAllDevices);
 #endif
 #ifdef _WIN32
@@ -288,7 +288,7 @@ int OPMOD_RemoveController(laOperator* a, laEvent* e){
 
 void lapost_Controller(laController* c){
     c->InternalType = la_IdentifyControllerInternalType(SSTR(c->Name));
-#ifdef __linux__
+#ifdef LA_LINUX
     c->fd=open(SSTR(c->Path),O_RDWR | O_NONBLOCK); if(c->fd<0){ c->Error=1; }
 #endif
 }

+ 4 - 4
la_data.c

@@ -1341,7 +1341,7 @@ int laSetIntArraySingle(laPropPack *pp, int index, int n){
     if (p->Base.DetachedPP.LastPs){
         p->Detached[index] = n;
         laNotifyUsersPP(pp);
-        return;
+        return 1;
     }
     if (!pp->LastPs->UseInstance) return 0;
     if (pp->LastPs->p->PropertyType & LA_PROP_INT){
@@ -2074,7 +2074,7 @@ int laTryGetInstanceIdentifier(void* Instance, laPropContainer* pc, char* identi
         elif(p->PropertyType&LA_PROP_INT){ int r[16]={0}; laGetIntArray(&PP,r); sprintf("(%s=%d)",p->Identifier,r[0]); }
         elif(p->PropertyType&LA_PROP_FLOAT){ real r[16]={0}; laGetFloatArray(&PP,r); sprintf("(%s=%lf)",p->Identifier,r[0]); }
         elif(p->PropertyType&LA_PROP_ENUM){  laEnumItem *r[16]={0}; laGetEnumArray(&PP,r); sprintf("(%s=%lf)",p->Identifier,r[0]?r[0]->Identifier:"?"); }
-        else{ sprintf("(%.6x)",identifier); }
+        else{ sprintf("(%.6x)",identifier,Instance); }
         return 1;
     }
     return 0;
@@ -2216,7 +2216,7 @@ int laValidateProperties(){
         pc->validated=1;
     }
     if(!pass){
-        printf("laValidateHyper2 Failed:\n"); printf(errors->Ptr);
+        printf("laValidateHyper2 Failed:\n"); printf("%s",SSTR(errors));
     }
     return pass;
 }
@@ -3646,7 +3646,7 @@ void la_MakeDummyManagedUDF(){
     }
 }
 laManagedSaveProp* laSaveProp(char* path){
-    if(!path || !path[0]) return; laManagedSaveProp* msp=0;
+    if(!path || !path[0]) return 0; laManagedSaveProp* msp=0;
     for(laManagedSaveProp* m=MAIN.ManagedSaveProps.pFirst;m;m=m->Item.pNext){
         if(!strcmp(m->Path->Ptr,path)){ msp=m; break; }
     }

+ 24 - 17
la_interface.h

@@ -18,23 +18,30 @@
 
 #pragma once
 
-#ifdef LA_USE_GLES
-#include <EGL/egl.h>
-#include <GL/gl.h>
+#ifdef LAGUI_ANDROID
+    #include <GLES3/gl3.h>
+    #include <EGL/egl.h>
 #else
-#include <GL/glew.h>
-#include <GL/gl.h>
+    #ifdef LA_USE_GLES
+    #include <EGL/egl.h>
+    #include <GL/gl.h>
+    #else
+    #include <GL/glew.h>
+    #include <GL/gl.h>
+    #endif
 #endif
 
 #ifdef __linux__
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include <X11/Xresource.h>
-#include <X11/Xlocale.h>
-#include <X11/XKBlib.h>
-#include <X11/Xatom.h>
-#include <GL/glx.h>
-#include <GL/glext.h>
+#ifndef LAGUI_ANDROID
+    #include <X11/Xlib.h>
+    #include <X11/Xutil.h>
+    #include <X11/Xresource.h>
+    #include <X11/Xlocale.h>
+    #include <X11/XKBlib.h>
+    #include <X11/Xatom.h>
+    #include <GL/glx.h>
+    #include <GL/glext.h>
+#endif
 #endif
 #ifdef _WIN32
 #include <GL/wglew.h>
@@ -299,7 +306,7 @@ STRUCTURE(laExtraPreferencePage){
 STRUCTURE(laProgressDisplay){
     char String[256];
     SYSWINDOW w;
-#ifdef __linux__
+#ifdef LA_LINUX
     GC gc;
     XGCValues gc_values;
 #endif
@@ -374,7 +381,7 @@ STRUCTURE(LA){
 
     char *InputBuf; int InputBufNext, InputBufMax;
     int32_t *InputBufU; int InputBufUNext, InputBufUMax;
-#ifdef __linux__
+#ifdef LA_LINUX
     Atom MsgDelWindow;
     Atom bufid;
     Atom fmtid;
@@ -397,7 +404,7 @@ STRUCTURE(LA){
     HDC hdc;
     int WinTabAvailable, WinTabOpened, WinTabMaxPenPressure, WinTabMaxEraserPressure, WinTabMaxHover;
 #endif
-#ifdef __linux__
+#ifdef LA_LINUX
     Window* win;
     XVisualInfo* xvi;
 #ifdef LA_USE_GLES
@@ -2252,7 +2259,7 @@ void la_NotifyGLDebugChanges();
 void laSetWindowCursor(int id);
 void laRenameWindow(laWindow* wnd, char* name);
 
-#ifdef __linux__
+#ifdef LA_LINUX
 int la_GetDPI(Window* root_win);
 void la_ScanWacomDevices(SYSTEMDISPLAY *display, int deviceid);
 #endif

+ 38 - 28
la_kernel.c

@@ -28,7 +28,7 @@
 #include <math.h>
 #include <time.h>
 
-#ifdef __linux__
+#ifdef LA_LINUX
 #include <execinfo.h>
 #include <signal.h>
 #include <sys/time.h>
@@ -50,6 +50,9 @@
 #include <GL/wgl.h>
 #include <shellscalingapi.h>
 #endif
+#ifdef LAGUI_ANDROID
+#include <GLES3/gl3.h>
+#endif
 
 LA MAIN;
 
@@ -66,14 +69,14 @@ laColumn *DEBUG_C;
 #define LA_GUI_WNDCLASS_NAME "NUL4_GUI_CLASS"
 #endif
 
-#ifdef __linux__
+#ifdef LA_LINUX
 typedef GLXContext (*glXCreateContextAttribsARBProc)(Display*, GLXFBConfig, GLXContext, Bool, const int*);\
 typedef void (*glXSwapIntervalEXTProc)(Display *dpy, GLXDrawable drawable, int interval);
 glXCreateContextAttribsARBProc glXCreateContextAttribsF;
 glXSwapIntervalEXTProc glXSwapIntervalEXTF;
 #endif
 
-#ifdef __linux__
+#ifdef LA_LINUX
 static void la_PrintWacomValuators(Display *display, XIAnyClassInfo **classes, int num_classes){
     int i;
     for (i = 0; i < num_classes; i++) {
@@ -440,7 +443,7 @@ void la_DestroySystemWindowWin32(laWindow* w) {
 };
 #endif
 
-#ifdef __linux__
+#ifdef LA_LINUX
 void la_HandlerSIGSEGV(int sig) {
     void *array[30];
     size_t sz;
@@ -454,6 +457,7 @@ void la_HandlerSIGSEGV(int sig) {
 
 void la_glDebugOutput(GLenum source, GLenum type, unsigned int id,
     GLenum severity, GLsizei length, const char* message, const void* userParam) {
+#ifndef LAGUI_ANDROID
     // ignore non-significant error/warning codes
     if (id==131169 || id==131185 || id==131218 || id==131204 || id==131076) return;
 
@@ -489,9 +493,11 @@ void la_glDebugOutput(GLenum source, GLenum type, unsigned int id,
     case GL_DEBUG_SEVERITY_NOTIFICATION: strseverity = "Notification"; break;
     }
     logPrint("%s | %s | %s\n\n", strsource,strtype,strseverity);
+#endif
 }
 
 void la_SetCurrentGLContextDebug(){
+#ifndef LAGUI_ANDROID
     int force=MAIN.InitArgs.GLDebug;
     if(MAIN.EnableGLDebug || force){ glEnable(GL_DEBUG_OUTPUT); }else{ glDisable(GL_DEBUG_OUTPUT); }
     if(MAIN.GLDebugSync || force){ glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS); }else{ glDisable(GL_DEBUG_OUTPUT_SYNCHRONOUS); }
@@ -507,6 +513,7 @@ void la_SetCurrentGLContextDebug(){
         }
     }
     glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, sev, 0, 0, GL_TRUE);
+#endif
 }
 void la_NotifyGLDebugChanges(){
     MAIN.GLDebugNeedsUpdate=1; for(laWindow* w=MAIN.Windows.pFirst;w;w=w->Item.pNext){ w->GLDebugNeedsUpdate=1; }
@@ -522,13 +529,16 @@ void la_SetupWindowGLStates(laWindow* w){
 
 int la_CreateSystemWindow(laWindow *window, int SyncToVBlank){
     SYSGLCONTEXT glc;
-#ifdef __linux__
+#ifdef LA_LINUX
     void* egl_surf=0;
 #ifdef LA_USE_GLES
     egl_surf=&window->egl_surf;
 #endif
     SYSWINDOW hwnd = la_CreateWindowX11(window->X, window->Y, window->W, window->H, window->Title->Ptr, SyncToVBlank, &glc, egl_surf);
 #endif
+#ifdef _WIN32
+    SYSWINDOW hwnd = la_CreateWindowWin32(window->X, window->Y, window->W, window->H, window->Title->Ptr, SyncToVBlank, &glc);
+#endif
 #ifdef _WIN32
     SYSWINDOW hwnd = la_CreateWindowWin32(window->X, window->Y, window->W, window->H, window->Title->Ptr, SyncToVBlank, &glc);
 #endif
@@ -542,7 +552,7 @@ int la_CreateSystemWindow(laWindow *window, int SyncToVBlank){
     window->CW = rc.right - rc.left;
     window->CH = rc.bottom - rc.top;
 #endif
-#ifdef __linux__
+#ifdef LA_LINUX
     XWindowAttributes attr;
     XGetWindowAttributes(MAIN.dpy, window->win, &attr);
     window->CW =attr.width;
@@ -571,7 +581,7 @@ int la_DestroySystemWindow(laWindow* wnd){
 #else
     nvgDeleteGL3(wnd->nvg);
 #endif
-#ifdef __linux__
+#ifdef LA_LINUX
     la_DestroySystemWindowX11(wnd);
 #endif
 #ifdef _WIN32
@@ -615,7 +625,7 @@ void laRenameWindow(laWindow* wnd, char* name){
     if((!wnd)||MAIN.IsReadingUDF) return;
     strSafeSet(&wnd->Title, name);
     if(!wnd->win) return;
-#ifdef __linux__
+#ifdef LA_LINUX
     XStoreName(MAIN.dpy, wnd->win, name);
 #endif
 #ifdef _WIN32
@@ -624,7 +634,7 @@ void laRenameWindow(laWindow* wnd, char* name){
 #endif
 }
 
-#ifdef __linux__
+#ifdef LA_LINUX
 const char* la_ConvertCursorID(int id){
     switch (id) {
     case LA_ARROW: return "arrow";
@@ -731,7 +741,7 @@ laScreen* laGetWindowScreen(laWindow* w){
     return maxs;
 }
 
-#ifdef __linux__
+#ifdef LA_LINUX
 int la_GetDPI(Window* root_win){
     XRRScreenResources *screen;
     XRROutputInfo *info;
@@ -793,7 +803,7 @@ void laShowProgress(real p1, real p2){
         memcpy(&MAIN.Progress.TimeCalled,&tm,sizeof(laTimeRecorder));
         if(!MAIN.Progress.Shown){
              int ww=PROGRESSW+LA_RH*2;
-#ifdef __linux__
+#ifdef LA_LINUX
             int w=XDisplayWidth(MAIN.dpy, 0),h=XDisplayHeight(MAIN.dpy, 0);
             XMoveResizeWindow(MAIN.dpy,MAIN.Progress.w,w/2-ww/2,h/2-LA_RH*2/2,ww,LA_RH*2);
             long a=LA_COLOR3_TO_HEX(bg);
@@ -812,7 +822,7 @@ void laShowProgress(real p1, real p2){
         }
     }
     if(p1>=0) MAIN.Progress.p1=p1; if(p2>=0) MAIN.Progress.p2=p2;
-#ifdef __linux__
+#ifdef LA_LINUX
     XClearWindow(MAIN.dpy,MAIN.Progress.w);
     XFillRectangle(MAIN.dpy,MAIN.Progress.w,MAIN.Progress.gc,LA_RH*2,0,PROGRESSW*MAIN.Progress.p1,LA_RH);
     XFillRectangle(MAIN.dpy,MAIN.Progress.w,MAIN.Progress.gc,LA_RH*2,LA_RH,PROGRESSW*MAIN.Progress.p2,LA_RH);
@@ -850,7 +860,7 @@ void laHideProgress(){
     real t=laTimeElapsedSecondsf(&tm,&MAIN.Progress.TimeCalled);
     if(t<0.2){ usleep((TNS_MIN2(0.2-t,0.2))*1000000); }
     MAIN.Progress.Called = MAIN.Progress.Shown = 0;
-#ifdef __linux__
+#ifdef LA_LINUX
     XUnmapWindow(MAIN.dpy,MAIN.Progress.w); XSync(MAIN.dpy, 1); XFlush(MAIN.dpy);
 #endif
 #ifdef _WIN32
@@ -863,7 +873,7 @@ void laHideProgress(){
 //=======================
 
 void la_InitProgressWindow(){
-#ifdef __linux__
+#ifdef LA_LINUX
     MAIN.Progress.w=XCreateSimpleWindow(MAIN.dpy, RootWindow(MAIN.dpy, 0), 0, 0, PROGRESSW+LA_RH*2, LA_RH*2, 0, BlackPixel(MAIN.dpy, 0), WhitePixel(MAIN.dpy, 0));
     if(!MAIN.Progress.w) return;
     Atom window_type = XInternAtom(MAIN.dpy, "_NET_WM_WINDOW_TYPE", False); long value = XInternAtom(MAIN.dpy, "_NET_WM_WINDOW_TYPE_DOCK", False);
@@ -938,7 +948,7 @@ void laProcessInitArguments(int argc, char* argv[],laInitArguments* ia) {
     }
 }
 int laGetReadyWith(laInitArguments* ia){
-#ifdef __linux__
+#ifdef LA_LINUX
     //signal(SIGSEGV,la_HandlerSIGSEGV);
 #endif
 
@@ -952,7 +962,7 @@ int laGetReadyWith(laInitArguments* ia){
 
     tnsInit();
 
-#ifdef __linux__
+#ifdef LA_LINUX
     SYSWINDOW root, win;
     GLint att[] = {GLX_RGBA, GLX_DEPTH_SIZE, 24, GLX_DOUBLEBUFFER, None};
     XSetWindowAttributes swa={0};
@@ -1189,7 +1199,7 @@ int laGetReadyWith(laInitArguments* ia){
 #ifdef _WIN32
     int dpi=la_GetDPI(hwnd);
 #endif
-#ifdef __linux__
+#ifdef LA_LINUX
     int dpi = la_GetDPI(DefaultRootWindow(MAIN.dpy));
 #endif
     if((!dpi) || dpi<144){ dpi=144; } if(dpi>300){ dpi=300; }
@@ -1360,7 +1370,7 @@ void laShutoff(int SavePrefereces){
 
     tnsBindVertexArray(0); glDeleteVertexArrays(1,&MAIN.TempVAO);
 
-#ifdef __linux__
+#ifdef LA_LINUX
     tnsContextMakeCurrent(0,0,0);
     tnsDeleteContext(MAIN.glc);
     #ifdef LA_USE_GLES
@@ -1723,7 +1733,7 @@ void la_CommandResizeWindow(SYSWINDOW hwnd, int x, int y, int w, int h){
         if (s) { window->OutputColorSpace = s->ColorSpace; }
     }
 #endif
-#ifdef __linux__
+#ifdef LA_LINUX
     XWindowAttributes attr;
     XGetWindowAttributes(MAIN.dpy, window->win, &attr);
     window->CW = w; window->CH = h;
@@ -1755,7 +1765,7 @@ int la_OnWindowDestroy(SYSWINDOW wnd){
     la_DestroyWindow(w);
 
     int done=0; for(laWindow* w=MAIN.Windows.pFirst;w;w=w->Item.pNext){
-#ifdef __linux__
+#ifdef LA_LINUX
         if(done) glXSwapIntervalEXTF(MAIN.dpy, w->win, 0);
         else { glXSwapIntervalEXTF(MAIN.dpy, w->win, 1); done = 1; }
 #endif
@@ -1769,7 +1779,7 @@ void la_MakeSpecialKeyBit(SYSWINDOW hwnd,laWindow*wnd,laEvent *e,int use_last_po
     laListHandle *el = &wnd->EventList;
     laEvent* last_e=el->pLast;
     SYSWINDOW root_ret, win_ret; int rrx=0,rry=0,rx=e->x,ry=e->y,rmask=0;
-#ifdef __linux__
+#ifdef LA_LINUX
     XQueryPointer(MAIN.dpy, wnd->win, &root_ret,&win_ret,&rrx,&rry,&rx,&ry,&rmask);
     e->SpecialKeyBit = ((rmask&ShiftMask)?LA_KEY_SHIFT:0)|((rmask&ControlMask)?LA_KEY_CTRL:0)|((rmask&Mod1Mask)?LA_KEY_ALT:0);
 #endif
@@ -1819,7 +1829,7 @@ void laSendOperatorTriggerEvent(){
     MAIN.ReTriggerOperators = 0;
 }
 int la_TranslateSpecialKey(int keysym){
-#ifdef __linux__
+#ifdef LA_LINUX
     switch(keysym){
     case XK_Return:    return LA_KEY_ENTER;
     case XK_BackSpace: return LA_KEY_BACKSPACE;
@@ -2990,7 +3000,7 @@ void la_WindowDefDraw(laWindow *w, laBoxedTheme *bt){
     }
 }
 int laStartWindow(laWindow *w){
-#ifdef __linux__
+#ifdef LA_LINUX
     XMapWindow(MAIN.dpy,w->win);
     tnsContextMakeWindowCurrent(w);
 #endif
@@ -3031,7 +3041,7 @@ laWindow *laDesignWindow(int X, int Y, int W, int H){
 }
 void laSetWindowCursor(int id){
     MAIN.CurrentCursor = id;
-#ifdef __linux__
+#ifdef LA_LINUX
     Cursor c = XcursorLibraryLoadCursor(MAIN.dpy, la_ConvertCursorID(id));
     XDefineCursor(MAIN.dpy, MAIN.CurrentWindow->win, c);
 #endif
@@ -7421,7 +7431,7 @@ void laFinalizeOperators(){
 
 //=================
 
-#ifdef __linux__
+#ifdef LA_LINUX
 static void la_RecordWacomMotions(XIRawEvent *event)
 {
     double *valuator = event->valuators.values;
@@ -7765,7 +7775,7 @@ int la_AllowInput(uint32_t ch){
     return 0;
 }
 int laCopyToClipboard(unsigned char * text){
-#ifdef __linux__
+#ifdef LA_LINUX
 	XEvent event; SYSWINDOW owner, window=MAIN.CurrentWindow->win;
 	XSetSelectionOwner(MAIN.dpy, MAIN.selection, window, 0);
 	if (XGetSelectionOwner (MAIN.dpy, MAIN.selection) != window) return 0;
@@ -7776,7 +7786,7 @@ int la_ProcessSysMessage(){
     int SendDelay = 0, SendIdle = 0;
     if (!MAIN.DelayTriggered && MAIN.TimeAccum - MAIN.DelayStart > MAIN.DelayTime) SendDelay = 1;
     if (!MAIN.IdleTriggered && MAIN.TimeAccum - MAIN.IdleStart > MAIN.IdleTime) SendIdle = 1;
-#ifdef __linux__
+#ifdef LA_LINUX
     XEvent e;
     int type;
 
@@ -7990,7 +8000,7 @@ void laMainLoop(){
         }
         for(w=MAIN.Windows.pFirst;w;w=w->Item.pNext){
             if(!w->RedrawTouched) continue; w->RedrawTouched=0;
-#ifdef __linux__
+#ifdef LA_LINUX
     #ifdef LA_USE_GLES
             eglSwapBuffers(MAIN.egl_dpy, w->egl_surf);
     #else

+ 20 - 3
la_util.h

@@ -23,13 +23,19 @@
 
 #include <time.h>
 
+#if defined(__linux__) && !defined(LAGUI_ANDROID)
+#define LA_LINUX
+#endif
+
 #ifdef LA_USE_GLES
 #include <EGL/egl.h>
-#include <GL/gl.h>
-	#ifdef LA_ANDROID
+	#ifdef LAGUI_ANDROID
 	#include <android/window.h>             // Required for: AWINDOW_FLAG_FULLSCREEN definition and others
     #include <android_native_app_glue.h>    // Required for: android_app struct and activity management
     #include <jni.h>                        // Required for: JNIEnv and JavaVM [Used in OpenURL()]
+	#include <GLES3/gl3.h>
+	#else
+	#include <GL/gl.h>
 	#endif
 #else
 #include <GL/glew.h>
@@ -42,7 +48,8 @@
 #include <stddef.h>
 #include <stdint.h>
 #include <ctype.h>
-#ifdef __linux__
+
+#ifdef LA_LINUX
 #include <fcntl.h>
 #include <unistd.h>
 #include <errno.h>
@@ -58,6 +65,7 @@
 #define SYSTEMDISPLAY Display
 #define SYSLOCK pthread_spinlock_t
 #endif
+
 #ifdef _WIN32
 #include <Windows.h>
 #include "Shlwapi.h"
@@ -73,6 +81,15 @@ typedef long off_t;
 #endif
 #endif
 
+#ifdef LAGUI_ANDROID
+#define SYSWINDOW ANativeWindow*
+#define SYSGLCONTEXT EGLContext
+#define SYSTEMDC EGLSurface
+#define SYSTEMRC EGLDevice
+#define SYSTEMDISPLAY EGLDisplay
+#define SYSLOCK int
+#endif
+
 #ifdef LA_WITH_LUAJIT
 
 #define luajit_c

+ 1 - 1
nanovg/nanovg_gl.h

@@ -1534,7 +1534,7 @@ static void glnvg__renderDelete(void* uptr)
 
 	glnvg__deleteShader(&gl->shader);
 
-#if NANOVG_GL3
+#ifdef NANOVG_GL3
 #if NANOVG_GL_USE_UNIFORMBUFFER
 	if (gl->fragBuf != 0)
 		glDeleteBuffers(1, &gl->fragBuf);