Browse Source

Some code tweaks...

Ray San 7 years ago
parent
commit
3d755d617a
4 changed files with 17 additions and 6 deletions
  1. 1 1
      examples/text/text_ttf_loading.c
  2. 13 3
      src/core.c
  3. 1 2
      src/text.c
  4. 2 0
      src/textures.c

+ 1 - 1
examples/text/text_ttf_loading.c

@@ -32,7 +32,7 @@ int main()
     GenTextureMipmaps(&font.texture);
     GenTextureMipmaps(&font.texture);
 
 
     float fontSize = font.baseSize;
     float fontSize = font.baseSize;
-    Vector2 fontPosition = { 40, screenHeight/2 + 50 };
+    Vector2 fontPosition = { 40, screenHeight/2 - 50 };
     Vector2 textSize;
     Vector2 textSize;
 
 
     SetTextureFilter(font.texture, FILTER_POINT);
     SetTextureFilter(font.texture, FILTER_POINT);

+ 13 - 3
src/core.c

@@ -81,7 +81,7 @@
 #define SUPPORT_DEFAULT_FONT
 #define SUPPORT_DEFAULT_FONT
 #define SUPPORT_MOUSE_GESTURES
 #define SUPPORT_MOUSE_GESTURES
 #define SUPPORT_CAMERA_SYSTEM
 #define SUPPORT_CAMERA_SYSTEM
-#define SUPPORT_GESTURES_SYSTEM
+//#define SUPPORT_GESTURES_SYSTEM
 #define SUPPORT_BUSY_WAIT_LOOP
 #define SUPPORT_BUSY_WAIT_LOOP
 #define SUPPORT_GIF_RECORDING
 #define SUPPORT_GIF_RECORDING
 //-------------------------------------------------
 //-------------------------------------------------
@@ -2526,6 +2526,8 @@ static void WindowSizeCallback(GLFWwindow *window, int width, int height)
     rlClearScreenBuffers();                     // Clear screen buffers (color and depth)
     rlClearScreenBuffers();                     // Clear screen buffers (color and depth)
 
 
     // Window size must be updated to be used on 3D mode to get new aspect ratio (Begin3dMode())
     // Window size must be updated to be used on 3D mode to get new aspect ratio (Begin3dMode())
+    // NOTE: Be careful! GLFW3 will choose the closest fullscreen resolution supported by current monitor,
+    // for example, if reescaling back to 800x450 (desired), it could set 720x480 (closest fullscreen supported)
     screenWidth = width;
     screenWidth = width;
     screenHeight = height;
     screenHeight = height;
     renderWidth = width;
     renderWidth = width;
@@ -2777,8 +2779,16 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event)
     ProcessGestureEvent(gestureEvent);
     ProcessGestureEvent(gestureEvent);
 #else
 #else
     
     
-    // TODO: Support only simple touch position
-    
+    // Support only simple touch position
+    if (flags == AMOTION_EVENT_ACTION_DOWN)
+    {
+        // Get first touch position
+        touchPosition[0].x = AMotionEvent_getX(event, 0);
+        touchPosition[0].y = AMotionEvent_getY(event, 0);
+        
+        touchPosition[0].x /= (float)GetScreenWidth();
+        touchPosition[0].y /= (float)GetScreenHeight();
+    }
 #endif
 #endif
 
 
     return 0;
     return 0;

+ 1 - 2
src/text.c

@@ -883,11 +883,10 @@ static SpriteFont LoadTTF(const char *fileName, int fontSize, int charsCount, in
     scale = stbtt_ScaleForPixelHeight(&fontInfo, fontSize);
     scale = stbtt_ScaleForPixelHeight(&fontInfo, fontSize);
     stbtt_GetFontVMetrics(&fontInfo, &ascent, 0, 0);
     stbtt_GetFontVMetrics(&fontInfo, &ascent, 0, 0);
     baseline = (int)(ascent*scale);
     baseline = (int)(ascent*scale);
-
     
     
     if (fontChars[0] != 32) TraceLog(LOG_WARNING, "TTF spritefont loading: first character is not SPACE(32) character");
     if (fontChars[0] != 32) TraceLog(LOG_WARNING, "TTF spritefont loading: first character is not SPACE(32) character");
 
 
-    // NOTE: Using stb_truetype crappy packing method, no guarante the font fits the image...
+    // NOTE: Using stb_truetype crappy packing method, no guarantee the font fits the image...
     // TODO: Replace this function by a proper packing method and support random chars order,
     // TODO: Replace this function by a proper packing method and support random chars order,
     // we already receive a list (fontChars) with the ordered expected characters
     // we already receive a list (fontChars) with the ordered expected characters
     int result = stbtt_BakeFontBitmap(ttfBuffer, 0, fontSize, dataBitmap, textureSize, textureSize, fontChars[0], charsCount, charData);
     int result = stbtt_BakeFontBitmap(ttfBuffer, 0, fontSize, dataBitmap, textureSize, textureSize, fontChars[0], charsCount, charData);

+ 2 - 0
src/textures.c

@@ -58,6 +58,8 @@
 #define SUPPORT_FILEFORMAT_PNG
 #define SUPPORT_FILEFORMAT_PNG
 #define SUPPORT_FILEFORMAT_DDS
 #define SUPPORT_FILEFORMAT_DDS
 #define SUPPORT_FILEFORMAT_HDR
 #define SUPPORT_FILEFORMAT_HDR
+#define SUPPORT_FILEFORMAT_KTX
+#define SUPPORT_FILEFORMAT_ASTC
 #define SUPPORT_IMAGE_MANIPULATION
 #define SUPPORT_IMAGE_MANIPULATION
 #define SUPPORT_IMAGE_GENERATION
 #define SUPPORT_IMAGE_GENERATION
 //-------------------------------------------------
 //-------------------------------------------------