summaryrefslogtreecommitdiff
path: root/src/drivers/PicoAndroid/Fl_PicoAndroid_Graphics_Driver.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/drivers/PicoAndroid/Fl_PicoAndroid_Graphics_Driver.cxx')
-rw-r--r--src/drivers/PicoAndroid/Fl_PicoAndroid_Graphics_Driver.cxx147
1 files changed, 131 insertions, 16 deletions
diff --git a/src/drivers/PicoAndroid/Fl_PicoAndroid_Graphics_Driver.cxx b/src/drivers/PicoAndroid/Fl_PicoAndroid_Graphics_Driver.cxx
index 81fa3efab..fd042bef4 100644
--- a/src/drivers/PicoAndroid/Fl_PicoAndroid_Graphics_Driver.cxx
+++ b/src/drivers/PicoAndroid/Fl_PicoAndroid_Graphics_Driver.cxx
@@ -20,10 +20,19 @@
#include "../../config_lib.h"
#include "Fl_PicoAndroid_Graphics_Driver.h"
+#include <jni.h>
+#include <errno.h>
+
+#include <EGL/egl.h>
+#include <GLES/gl.h>
+
+#include <android/log.h>
+#include <android_native_app_glue.h>
+
#include <FL/Fl.H>
-//#define __APPLE__
-//#include <SDL2/SDL.h>
-//#undef __APPLE__
+
+#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "native-activity", __VA_ARGS__))
+
/*
* By linking this module, the following static method will instatiate the
@@ -35,31 +44,137 @@ Fl_Graphics_Driver *Fl_Graphics_Driver::newMainGraphicsDriver()
}
-void Fl_PicoAndroid_Graphics_Driver::rectf(int x, int y, int w, int h)
+
+
+static GLint vertices[][3] = {
+ { -0x10000, -0x10000, -0x10000 },
+ { 0x10000, -0x10000, -0x10000 },
+ { 0x10000, 0x10000, -0x10000 },
+ { -0x10000, 0x10000, -0x10000 },
+ { -0x10000, -0x10000, 0x10000 },
+ { 0x10000, -0x10000, 0x10000 },
+ { 0x10000, 0x10000, 0x10000 },
+ { -0x10000, 0x10000, 0x10000 }
+};
+
+static GLint colors[][4] = {
+ { 0x00000, 0x00000, 0x00000, 0x10000 },
+ { 0x10000, 0x00000, 0x00000, 0x10000 },
+ { 0x10000, 0x10000, 0x00000, 0x10000 },
+ { 0x00000, 0x10000, 0x00000, 0x10000 },
+ { 0x00000, 0x00000, 0x10000, 0x10000 },
+ { 0x10000, 0x00000, 0x10000, 0x10000 },
+ { 0x10000, 0x10000, 0x10000, 0x10000 },
+ { 0x00000, 0x10000, 0x10000, 0x10000 }
+};
+
+GLubyte indices[] = {
+ 0, 4, 5, 0, 5, 1,
+ 1, 5, 6, 1, 6, 2,
+ 2, 6, 7, 2, 7, 3,
+ 3, 7, 4, 3, 4, 0,
+ 4, 7, 6, 4, 6, 5,
+ 3, 0, 1, 3, 1, 2
+};
+
+static void drawSomething()
{
-// uchar r, g, b;
+ /*
+ static float _angle = 0.0f;
+
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ glTranslatef(0, 0, -3.0f);
+ glRotatef(_angle, 0, 1, 0);
+ glRotatef(_angle*0.25f, 1, 0, 0);
+
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_COLOR_ARRAY);
+
+ glFrontFace(GL_CW);
+ glVertexPointer(3, GL_FIXED, 0, vertices);
+ glColorPointer(4, GL_FIXED, 0, colors);
+ glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_BYTE, indices);
+
+ _angle += 1.2f;
+ */
+
+ GLfloat q3[] = {
+ -10,-10,
+ 10,-10,
+ 10,10,
+ -10,10
+ };
+
+ uchar r, g, b;
+ Fl::get_color(FL_RED, r, g, b);
// Fl::get_color(Fl_Graphics_Driver::color(), r, g, b);
-// SDL_SetRenderDrawColor((SDL_Renderer*)fl_window, r, g, b, SDL_ALPHA_OPAQUE);
-// SDL_Rect rect = {x, y, w, h};
-// SDL_RenderFillRect((SDL_Renderer*)fl_window, &rect);
+ glColor4ub(r, g, b, 255);
+
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glVertexPointer(2, GL_FLOAT, 0, q3);
+ glDrawArrays(GL_TRIANGLE_FAN,0,4);
+ glDisableClientState(GL_VERTEX_ARRAY);
+}
+
+
+
+void Fl_PicoAndroid_Graphics_Driver::rectf(int x, int y, int w, int h)
+{
+ GLfloat q3[] = {
+ x, y,
+ x, y+h-3,
+ x+w-3, y+h-3,
+ x+w-3, y
+ };
+
+ uchar r, g, b;
+ Fl::get_color(Fl_Graphics_Driver::color(), r, g, b);
+ glColor4ub(r, g, b, 255);
+
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glVertexPointer(2, GL_FLOAT, 0, q3);
+ glDrawArrays(GL_TRIANGLE_FAN,0,4);
+ glDisableClientState(GL_VERTEX_ARRAY);
+
+ LOGI("Rect: %d %d %d %d", x, y, w, h);
}
void Fl_PicoAndroid_Graphics_Driver::line(int x, int y, int x1, int y1)
{
-// uchar r, g, b;
-// Fl::get_color(Fl_Graphics_Driver::color(), r, g, b);
-// SDL_SetRenderDrawColor((SDL_Renderer*)fl_window, r, g, b, SDL_ALPHA_OPAQUE);
-// SDL_RenderDrawLine((SDL_Renderer*)fl_window, x, y, x1, y1);
+ GLfloat q3[] = {
+ x, y,
+ x1, y1
+ };
+
+ uchar r, g, b;
+ Fl::get_color(Fl_Graphics_Driver::color(), r, g, b);
+ glColor4ub(r, g, b, 255);
+
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glVertexPointer(2, GL_FLOAT, 0, q3);
+ glDrawArrays(GL_LINES,0,2);
+ glDisableClientState(GL_VERTEX_ARRAY);
}
void Fl_PicoAndroid_Graphics_Driver::point(int x, int y)
{
-// uchar r, g, b;
-// Fl::get_color(Fl_Graphics_Driver::color(), r, g, b);
-// SDL_SetRenderDrawColor((SDL_Renderer*)fl_window, r, g, b, SDL_ALPHA_OPAQUE);
-// SDL_RenderDrawPoint((SDL_Renderer*)fl_window, x, y);
+ GLfloat q3[] = {
+ x, y
+ };
+
+ uchar r, g, b;
+ Fl::get_color(Fl_Graphics_Driver::color(), r, g, b);
+ glColor4ub(r, g, b, 255);
+
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glVertexPointer(2, GL_POINTS, 0, q3);
+ glDrawArrays(GL_LINES,0,1);
+ glDisableClientState(GL_VERTEX_ARRAY);
}