misc/vim: inform the user when no results are found
[nit.git] / lib / mnit / opengles1.nit
index 56c6b29..eb1061b 100644 (file)
 # limitations under the License.
 
 # OpenGL ES1 general support (most of it)
-module opengles1 is pkgconfig("glesv1_cm", "x11", "egl")
+module opengles1 is pkgconfig("glesv1_cm", "egl")
 
 import mnit_display
 
 in "C header" `{
        #include <EGL/egl.h>
        #include <GLES/gl.h>
-       #define GL_GLEXT_PROTOTYPES 1
-       #include <GLES/glext.h>
-       #include <errno.h>
 
        EGLDisplay mnit_display;
        EGLSurface mnit_surface;
@@ -32,7 +29,6 @@ in "C header" `{
        EGLConfig mnit_config;
        int32_t mnit_width;
        int32_t mnit_height;
-       float mnit_zoom;
 
        struct mnit_opengles_Texture {
                GLuint texture;
@@ -210,7 +206,6 @@ class Opengles1Display
                mnit_config = config;
                mnit_width = w;
                mnit_height = h;
-               mnit_zoom = 1.0f;
 
                LOGI("surface", (int)surface);
                LOGI("display", (int)display);
@@ -266,12 +261,13 @@ class Opengles1Display
                glMatrixMode(GL_PROJECTION);
                glLoadIdentity();
                glOrthof(x, x+w, y+h, y, 0.0f, 1.0f);
-               mnit_zoom = ((float)w)/mnit_width;
                glMatrixMode(GL_MODELVIEW);
                glFrontFace( GL_CW );
        `}
 
-       redef fun blit( image, x, y ) is extern  `{
+       redef fun blit(image, x, y) do native_blit(image, x.to_f, y.to_f)
+
+       private fun native_blit(image: Opengles1Image, x, y: Float)  `{
                GLfloat texture_coord[4][2] =
                {
                        {image->src_xo, image->src_yi},
@@ -312,14 +308,16 @@ class Opengles1Display
                }
        `}
 
-    redef fun blit_centered( img, x, y )
+    redef fun blit_centered(img, x, y)
     do
-               x = x - img.center_x
-               y = y - img.center_y
-               blit( img, x, y )
+               x = x.sub(img.center_x)
+               y = y.sub(img.center_y)
+               blit(img, x, y)
     end
 
-       redef fun blit_rotated( image, x, y, angle ) is extern  `{
+       redef fun blit_rotated(image, x, y, angle) do native_blit_rotated(image, x.to_f, y.to_f, angle)
+
+       private fun native_blit_rotated(image: Opengles1Image, x, y, angle: Float) `{
                GLfloat texture_coord[4][2] =
                {
                        {image->src_xo, image->src_yi},
@@ -361,7 +359,14 @@ class Opengles1Display
        `}
 
        # a = top left, b = bottom left, c = bottom right, d = top right
-       redef fun blit_stretched( image, ax, ay, bx, by, cx, cy, dx, dy ) is extern  `{
+       redef fun blit_stretched(image, ax, ay, bx, by, cx, cy, dx, dy)
+       do
+               native_blit_stretched(image,
+                       ax.to_f, ay.to_f, bx.to_f, by.to_f,
+                       cx.to_f, cy.to_f, dx.to_f, dy.to_f)
+       end
+
+       private fun native_blit_stretched(image: I, ax, ay, bx, by, cx, cy, dx, dy: Float) `{
                GLfloat texture_coord[4][2] =
                {
                        {image->src_xo, image->src_yi},