Added 6 new examples
							
								
								
									
										115
									
								
								examples/core_gestures_detection.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,115 @@
 | 
				
			|||||||
 | 
					/*******************************************************************************************
 | 
				
			||||||
 | 
					*
 | 
				
			||||||
 | 
					*   raylib [core] example - Gestures Detection
 | 
				
			||||||
 | 
					*
 | 
				
			||||||
 | 
					*   This example has been created using raylib 1.4 (www.raylib.com)
 | 
				
			||||||
 | 
					*   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
 | 
				
			||||||
 | 
					*
 | 
				
			||||||
 | 
					*   Copyright (c) 2016 Ramon Santamaria (@raysan5)
 | 
				
			||||||
 | 
					*
 | 
				
			||||||
 | 
					********************************************************************************************/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "raylib.h"
 | 
				
			||||||
 | 
					#include <string.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define MAX_GESTURE_STRINGS   20
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int main()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    // Initialization
 | 
				
			||||||
 | 
					    //--------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    int screenWidth = 800;
 | 
				
			||||||
 | 
					    int screenHeight = 450;
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    InitWindow(screenWidth, screenHeight, "raylib [core] example - gestures detection");
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Vector2 touchPosition = { 0, 0 };
 | 
				
			||||||
 | 
					    Rectangle touchArea = { 220, 10, screenWidth - 230, screenHeight - 20 };
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    int gesturesCount = 0;
 | 
				
			||||||
 | 
					    char gestureStrings[MAX_GESTURE_STRINGS][32];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    int currentGesture = GESTURE_NONE;
 | 
				
			||||||
 | 
					    int lastGesture = GESTURE_NONE;
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    //SetGesturesEnabled(0b0000000000001001);   // Enable only some gestures to be detected
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    SetTargetFPS(30);
 | 
				
			||||||
 | 
					    //--------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Main game loop
 | 
				
			||||||
 | 
					    while (!WindowShouldClose())    // Detect window close button or ESC key
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        // Update
 | 
				
			||||||
 | 
					        //----------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					        lastGesture = currentGesture;
 | 
				
			||||||
 | 
					        touchPosition = GetTouchPosition(0);
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (CheckCollisionPointRec(touchPosition, touchArea) &&  IsGestureDetected())
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            currentGesture = GetGestureType();
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					            if (currentGesture != lastGesture)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                // Store gesture string
 | 
				
			||||||
 | 
					                switch (currentGesture)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    case GESTURE_TAP: strcpy(gestureStrings[gesturesCount], "GESTURE TAP"); break;
 | 
				
			||||||
 | 
					                    case GESTURE_DOUBLETAP: strcpy(gestureStrings[gesturesCount], "GESTURE DOUBLETAP"); break;
 | 
				
			||||||
 | 
					                    case GESTURE_HOLD: strcpy(gestureStrings[gesturesCount], "GESTURE HOLD"); break;
 | 
				
			||||||
 | 
					                    case GESTURE_DRAG: strcpy(gestureStrings[gesturesCount], "GESTURE DRAG"); break;
 | 
				
			||||||
 | 
					                    case GESTURE_SWIPE_RIGHT: strcpy(gestureStrings[gesturesCount], "GESTURE SWIPE RIGHT"); break;
 | 
				
			||||||
 | 
					                    case GESTURE_SWIPE_LEFT: strcpy(gestureStrings[gesturesCount], "GESTURE SWIPE LEFT"); break;
 | 
				
			||||||
 | 
					                    case GESTURE_SWIPE_UP: strcpy(gestureStrings[gesturesCount], "GESTURE SWIPE UP"); break;
 | 
				
			||||||
 | 
					                    case GESTURE_SWIPE_DOWN: strcpy(gestureStrings[gesturesCount], "GESTURE SWIPE DOWN"); break;
 | 
				
			||||||
 | 
					                    default: break;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
 | 
					                gesturesCount++;
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
 | 
					                // Reset gestures strings
 | 
				
			||||||
 | 
					                if (gesturesCount >= MAX_GESTURE_STRINGS)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    for (int i = 0; i < MAX_GESTURE_STRINGS; i++) strcpy(gestureStrings[i], "\0");
 | 
				
			||||||
 | 
					                    
 | 
				
			||||||
 | 
					                    gesturesCount = 0;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else currentGesture = GESTURE_NONE;
 | 
				
			||||||
 | 
					        //----------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Draw
 | 
				
			||||||
 | 
					        //----------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					        BeginDrawing();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            ClearBackground(RAYWHITE);
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					            DrawRectangleRec(touchArea, GRAY);
 | 
				
			||||||
 | 
					            DrawRectangle(225, 15, screenWidth - 240, screenHeight - 30, RAYWHITE);
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					            DrawText("GESTURES TEST AREA", screenWidth - 270, screenHeight - 40, 20, Fade(GRAY, 0.5f));
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					            for (int i = 0; i < gesturesCount; i++)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (i%2 == 0) DrawRectangle(10, 30 + 20*i, 200, 20, Fade(LIGHTGRAY, 0.5f));
 | 
				
			||||||
 | 
					                else DrawRectangle(10, 30 + 20*i, 200, 20, Fade(LIGHTGRAY, 0.3f));
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
 | 
					                if (i < gesturesCount - 1) DrawText(gestureStrings[i], 35, 36 + 20*i, 10, DARKGRAY);
 | 
				
			||||||
 | 
					                else DrawText(gestureStrings[i], 35, 36 + 20*i, 10, MAROON);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					            DrawRectangleLines(10, 29, 200, screenHeight - 50, GRAY);
 | 
				
			||||||
 | 
					            DrawText("DETECTED GESTURES", 50, 15, 10, GRAY);
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					            if (currentGesture != GESTURE_NONE) DrawCircleV(touchPosition, 30, MAROON);
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					        EndDrawing();
 | 
				
			||||||
 | 
					        //----------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // De-Initialization
 | 
				
			||||||
 | 
					    //--------------------------------------------------------------------------------------   
 | 
				
			||||||
 | 
					    CloseWindow();        // Close window and OpenGL context
 | 
				
			||||||
 | 
					    //--------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										
											BIN
										
									
								
								examples/core_gestures_detection.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 19 KiB  | 
@@ -5,7 +5,7 @@
 | 
				
			|||||||
*   This example has been created using raylib 1.4 (www.raylib.com)
 | 
					*   This example has been created using raylib 1.4 (www.raylib.com)
 | 
				
			||||||
*   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
 | 
					*   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
 | 
				
			||||||
*
 | 
					*
 | 
				
			||||||
*   Copyright (c) 2014 Ramon Santamaria (@raysan5)
 | 
					*   Copyright (c) 2015 Ramon Santamaria (@raysan5)
 | 
				
			||||||
*
 | 
					*
 | 
				
			||||||
********************************************************************************************/
 | 
					********************************************************************************************/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -85,8 +85,8 @@ else
 | 
				
			|||||||
# external libraries headers
 | 
					# external libraries headers
 | 
				
			||||||
# GLFW3
 | 
					# GLFW3
 | 
				
			||||||
    INCLUDES += -I../external/glfw3/include
 | 
					    INCLUDES += -I../external/glfw3/include
 | 
				
			||||||
# GLEW
 | 
					# GLEW - Not required any more, replaced by GLAD
 | 
				
			||||||
    INCLUDES += -I../external/glew/include
 | 
					    #INCLUDES += -I../external/glew/include
 | 
				
			||||||
# OpenAL Soft
 | 
					# OpenAL Soft
 | 
				
			||||||
    INCLUDES += -I../external/openal_soft/include
 | 
					    INCLUDES += -I../external/openal_soft/include
 | 
				
			||||||
endif
 | 
					endif
 | 
				
			||||||
@@ -102,8 +102,8 @@ else
 | 
				
			|||||||
    ifneq ($(PLATFORM_OS),OSX)
 | 
					    ifneq ($(PLATFORM_OS),OSX)
 | 
				
			||||||
    # OpenAL Soft
 | 
					    # OpenAL Soft
 | 
				
			||||||
    	LFLAGS += -L../external/openal_soft/lib/$(LIBPATH)
 | 
					    	LFLAGS += -L../external/openal_soft/lib/$(LIBPATH)
 | 
				
			||||||
	# GLEW
 | 
						# GLEW - Not required any more, replaced by GLAD
 | 
				
			||||||
    	LFLAGS += -L../external/glew/lib/$(LIBPATH)
 | 
					    	#LFLAGS += -L../external/glew/lib/$(LIBPATH)
 | 
				
			||||||
    endif
 | 
					    endif
 | 
				
			||||||
endif
 | 
					endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -126,7 +126,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
 | 
				
			|||||||
    else
 | 
					    else
 | 
				
			||||||
        # libraries for Windows desktop compiling
 | 
					        # libraries for Windows desktop compiling
 | 
				
			||||||
        # NOTE: GLFW3 and OpenAL Soft libraries should be installed
 | 
					        # NOTE: GLFW3 and OpenAL Soft libraries should be installed
 | 
				
			||||||
        LIBS = -lraylib -lglfw3 -lglew32 -lopengl32 -lopenal32 -lgdi32
 | 
					        LIBS = -lraylib -lglfw3 -lopengl32 -lopenal32 -lgdi32
 | 
				
			||||||
    endif
 | 
					    endif
 | 
				
			||||||
    endif
 | 
					    endif
 | 
				
			||||||
endif
 | 
					endif
 | 
				
			||||||
@@ -161,6 +161,8 @@ EXAMPLES = \
 | 
				
			|||||||
    core_random_values \
 | 
					    core_random_values \
 | 
				
			||||||
    core_color_select \
 | 
					    core_color_select \
 | 
				
			||||||
    core_drop_files \
 | 
					    core_drop_files \
 | 
				
			||||||
 | 
					    core_storage_values \
 | 
				
			||||||
 | 
					    core_gestures_detection \
 | 
				
			||||||
    core_3d_mode \
 | 
					    core_3d_mode \
 | 
				
			||||||
    core_3d_picking \
 | 
					    core_3d_picking \
 | 
				
			||||||
    core_3d_camera_free \
 | 
					    core_3d_camera_free \
 | 
				
			||||||
@@ -177,10 +179,14 @@ EXAMPLES = \
 | 
				
			|||||||
    textures_raw_data \
 | 
					    textures_raw_data \
 | 
				
			||||||
    textures_formats_loading \
 | 
					    textures_formats_loading \
 | 
				
			||||||
    textures_particles_trail_blending \
 | 
					    textures_particles_trail_blending \
 | 
				
			||||||
 | 
					    textures_image_processing \
 | 
				
			||||||
 | 
					    textures_image_drawing \
 | 
				
			||||||
    text_sprite_fonts \
 | 
					    text_sprite_fonts \
 | 
				
			||||||
 | 
					    text_bmfont_ttf \
 | 
				
			||||||
    text_rbmf_fonts \
 | 
					    text_rbmf_fonts \
 | 
				
			||||||
    text_format_text \
 | 
					    text_format_text \
 | 
				
			||||||
    text_font_select \
 | 
					    text_font_select \
 | 
				
			||||||
 | 
					    text_writing_anim \
 | 
				
			||||||
    models_geometric_shapes \
 | 
					    models_geometric_shapes \
 | 
				
			||||||
    models_box_collisions \
 | 
					    models_box_collisions \
 | 
				
			||||||
    models_billboard \
 | 
					    models_billboard \
 | 
				
			||||||
@@ -195,8 +201,6 @@ EXAMPLES = \
 | 
				
			|||||||
    audio_music_stream \
 | 
					    audio_music_stream \
 | 
				
			||||||
    fix_dylib \
 | 
					    fix_dylib \
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    #core_input_gamepad \
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# typing 'make' will invoke the first target entry in the file,
 | 
					# typing 'make' will invoke the first target entry in the file,
 | 
				
			||||||
# in this case, the 'default' target entry is raylib
 | 
					# in this case, the 'default' target entry is raylib
 | 
				
			||||||
@@ -217,6 +221,10 @@ core_input_keys: core_input_keys.c
 | 
				
			|||||||
core_input_mouse: core_input_mouse.c
 | 
					core_input_mouse: core_input_mouse.c
 | 
				
			||||||
	$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
 | 
						$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# compile [core] example - mouse wheel
 | 
				
			||||||
 | 
					core_mouse_wheel: core_mouse_wheel.c
 | 
				
			||||||
 | 
						$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# compile [core] example - gamepad input
 | 
					# compile [core] example - gamepad input
 | 
				
			||||||
core_input_gamepad: core_input_gamepad.c
 | 
					core_input_gamepad: core_input_gamepad.c
 | 
				
			||||||
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
 | 
					ifeq ($(PLATFORM),PLATFORM_DESKTOP)
 | 
				
			||||||
@@ -225,8 +233,12 @@ else
 | 
				
			|||||||
	@echo core_input_gamepad: Only supported on desktop platform
 | 
						@echo core_input_gamepad: Only supported on desktop platform
 | 
				
			||||||
endif
 | 
					endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# compile [core] example - mouse wheel
 | 
					# compile [core] example - generate random values
 | 
				
			||||||
core_mouse_wheel: core_mouse_wheel.c
 | 
					core_random_values: core_random_values.c
 | 
				
			||||||
 | 
						$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# compile [core] example - color selection (collision detection)
 | 
				
			||||||
 | 
					core_color_select: core_color_select.c
 | 
				
			||||||
	$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
 | 
						$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# compile [core] example - drop files
 | 
					# compile [core] example - drop files
 | 
				
			||||||
@@ -237,12 +249,16 @@ else
 | 
				
			|||||||
	@echo core_drop_files: Only supported on desktop platform
 | 
						@echo core_drop_files: Only supported on desktop platform
 | 
				
			||||||
endif
 | 
					endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# compile [core] example - generate random values
 | 
					# compile [core] example - storage values
 | 
				
			||||||
core_random_values: core_random_values.c
 | 
					core_storage_values: core_storage_values.c
 | 
				
			||||||
 | 
					ifeq ($(PLATFORM),PLATFORM_DESKTOP)
 | 
				
			||||||
	$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
 | 
						$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
 | 
				
			||||||
 | 
					else
 | 
				
			||||||
 | 
						@echo core_storage_values: Only supported on desktop platform
 | 
				
			||||||
 | 
					endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# compile [core] example - color selection (collision detection)
 | 
					# compile [core] example - gestures detection
 | 
				
			||||||
core_color_select: core_color_select.c
 | 
					core_gestures_detection: core_gestures_detection.c
 | 
				
			||||||
	$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
 | 
						$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# compile [core] example - 3d mode
 | 
					# compile [core] example - 3d mode
 | 
				
			||||||
@@ -309,10 +325,22 @@ textures_formats_loading: textures_formats_loading.c
 | 
				
			|||||||
textures_particles_trail_blending: textures_particles_trail_blending.c
 | 
					textures_particles_trail_blending: textures_particles_trail_blending.c
 | 
				
			||||||
	$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
 | 
						$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
 | 
					# compile [textures] example - texture image processing
 | 
				
			||||||
 | 
					textures_image_processing: textures_image_processing.c
 | 
				
			||||||
 | 
						$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					# compile [textures] example - texture image drawing
 | 
				
			||||||
 | 
					textures_image_drawing: textures_image_drawing.c
 | 
				
			||||||
 | 
						$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
# compile [text] example - sprite fonts loading
 | 
					# compile [text] example - sprite fonts loading
 | 
				
			||||||
text_sprite_fonts: text_sprite_fonts.c
 | 
					text_sprite_fonts: text_sprite_fonts.c
 | 
				
			||||||
	$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
 | 
						$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
 | 
					# compile [text] example - bmfonts and ttf loading
 | 
				
			||||||
 | 
					text_bmfont_ttf: text_bmfont_ttf.c
 | 
				
			||||||
 | 
						$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# compile [text] example - raylib bitmap fonts (rBMF)
 | 
					# compile [text] example - raylib bitmap fonts (rBMF)
 | 
				
			||||||
text_rbmf_fonts: text_rbmf_fonts.c
 | 
					text_rbmf_fonts: text_rbmf_fonts.c
 | 
				
			||||||
	$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
 | 
						$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
 | 
				
			||||||
@@ -325,6 +353,10 @@ text_format_text: text_format_text.c
 | 
				
			|||||||
text_font_select: text_font_select.c
 | 
					text_font_select: text_font_select.c
 | 
				
			||||||
	$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
 | 
						$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# compile [text] example - text writing animation
 | 
				
			||||||
 | 
					text_writing_anim: text_writing_anim.c
 | 
				
			||||||
 | 
						$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# compile [models] example - basic geometric 3d shapes
 | 
					# compile [models] example - basic geometric 3d shapes
 | 
				
			||||||
models_geometric_shapes: models_geometric_shapes.c
 | 
					models_geometric_shapes: models_geometric_shapes.c
 | 
				
			||||||
	$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
 | 
						$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
 | 
				
			||||||
 
 | 
				
			|||||||
| 
		 Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 54 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								examples/resources/cat.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 648 KiB  | 
							
								
								
									
										99
									
								
								examples/resources/fonts/bmfont.fnt
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,99 @@
 | 
				
			|||||||
 | 
					info face="Arial Black" size=-32 bold=0 italic=0 charset="" unicode=1 stretchH=100 smooth=1 aa=1 padding=0,0,0,0 spacing=2,2 outline=0
 | 
				
			||||||
 | 
					common lineHeight=45 base=35 scaleW=512 scaleH=256 pages=1 packed=0 alphaChnl=0 redChnl=4 greenChnl=4 blueChnl=4
 | 
				
			||||||
 | 
					page id=0 file="bmfont.png"
 | 
				
			||||||
 | 
					chars count=95
 | 
				
			||||||
 | 
					char id=32   x=423   y=141   width=3     height=45    xoffset=-1    yoffset=0     xadvance=11    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=33   x=323   y=141   width=9     height=45    xoffset=1     yoffset=0     xadvance=11    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=34   x=123   y=141   width=16    height=45    xoffset=0     yoffset=0     xadvance=16    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=35   x=221   y=47    width=21    height=45    xoffset=0     yoffset=0     xadvance=21    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=36   x=244   y=47    width=21    height=45    xoffset=0     yoffset=0     xadvance=21    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=37   x=70    y=0     width=30    height=45    xoffset=1     yoffset=0     xadvance=32    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=38   x=390   y=0     width=25    height=45    xoffset=2     yoffset=0     xadvance=28    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=39   x=378   y=141   width=8     height=45    xoffset=1     yoffset=0     xadvance=9     page=0  chnl=15
 | 
				
			||||||
 | 
					char id=40   x=222   y=141   width=11    height=45    xoffset=1     yoffset=0     xadvance=12    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=41   x=499   y=94    width=11    height=45    xoffset=1     yoffset=0     xadvance=12    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=42   x=497   y=47    width=13    height=45    xoffset=2     yoffset=0     xadvance=18    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=43   x=394   y=94    width=19    height=45    xoffset=1     yoffset=0     xadvance=21    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=44   x=367   y=141   width=9     height=45    xoffset=1     yoffset=0     xadvance=11    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=45   x=261   y=141   width=11    height=45    xoffset=0     yoffset=0     xadvance=11    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=46   x=356   y=141   width=9     height=45    xoffset=1     yoffset=0     xadvance=11    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=47   x=248   y=141   width=11    height=45    xoffset=-1    yoffset=0     xadvance=9     page=0  chnl=15
 | 
				
			||||||
 | 
					char id=48   x=382   y=47    width=21    height=45    xoffset=0     yoffset=0     xadvance=21    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=49   x=496   y=0     width=14    height=45    xoffset=2     yoffset=0     xadvance=21    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=50   x=134   y=94    width=20    height=45    xoffset=0     yoffset=0     xadvance=21    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=51   x=359   y=47    width=21    height=45    xoffset=0     yoffset=0     xadvance=21    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=52   x=313   y=47    width=21    height=45    xoffset=0     yoffset=0     xadvance=21    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=53   x=336   y=47    width=21    height=45    xoffset=0     yoffset=0     xadvance=21    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=54   x=178   y=94    width=20    height=45    xoffset=1     yoffset=0     xadvance=21    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=55   x=478   y=94    width=19    height=45    xoffset=1     yoffset=0     xadvance=21    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=56   x=290   y=47    width=21    height=45    xoffset=0     yoffset=0     xadvance=21    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=57   x=90    y=94    width=20    height=45    xoffset=0     yoffset=0     xadvance=21    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=58   x=345   y=141   width=9     height=45    xoffset=1     yoffset=0     xadvance=11    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=59   x=334   y=141   width=9     height=45    xoffset=1     yoffset=0     xadvance=11    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=60   x=0     y=141   width=19    height=45    xoffset=1     yoffset=0     xadvance=21    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=61   x=21    y=141   width=19    height=45    xoffset=1     yoffset=0     xadvance=21    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=62   x=310   y=94    width=19    height=45    xoffset=1     yoffset=0     xadvance=21    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=63   x=352   y=94    width=19    height=45    xoffset=1     yoffset=0     xadvance=20    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=64   x=279   y=0     width=26    height=45    xoffset=-1    yoffset=0     xadvance=24    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=65   x=193   y=0     width=27    height=45    xoffset=-1    yoffset=0     xadvance=25    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=66   x=150   y=47    width=22    height=45    xoffset=2     yoffset=0     xadvance=25    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=67   x=444   y=0     width=24    height=45    xoffset=1     yoffset=0     xadvance=25    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=68   x=174   y=47    width=22    height=45    xoffset=2     yoffset=0     xadvance=25    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=69   x=156   y=94    width=20    height=45    xoffset=2     yoffset=0     xadvance=23    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=70   x=63    y=141   width=18    height=45    xoffset=2     yoffset=0     xadvance=21    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=71   x=417   y=0     width=25    height=45    xoffset=1     yoffset=0     xadvance=27    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=72   x=125   y=47    width=23    height=45    xoffset=2     yoffset=0     xadvance=27    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=73   x=388   y=141   width=8     height=45    xoffset=2     yoffset=0     xadvance=12    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=74   x=200   y=94    width=20    height=45    xoffset=0     yoffset=0     xadvance=21    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=75   x=251   y=0     width=26    height=45    xoffset=2     yoffset=0     xadvance=27    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=76   x=373   y=94    width=19    height=45    xoffset=2     yoffset=0     xadvance=21    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=77   x=134   y=0     width=28    height=45    xoffset=1     yoffset=0     xadvance=30    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=78   x=100   y=47    width=23    height=45    xoffset=2     yoffset=0     xadvance=27    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=79   x=363   y=0     width=25    height=45    xoffset=1     yoffset=0     xadvance=27    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=80   x=112   y=94    width=20    height=45    xoffset=2     yoffset=0     xadvance=23    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=81   x=335   y=0     width=26    height=45    xoffset=1     yoffset=0     xadvance=27    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=82   x=470   y=0     width=24    height=45    xoffset=2     yoffset=0     xadvance=25    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=83   x=75    y=47    width=23    height=45    xoffset=0     yoffset=0     xadvance=23    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=84   x=50    y=47    width=23    height=45    xoffset=0     yoffset=0     xadvance=23    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=85   x=25    y=47    width=23    height=45    xoffset=2     yoffset=0     xadvance=27    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=86   x=307   y=0     width=26    height=45    xoffset=0     yoffset=0     xadvance=25    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=87   x=0     y=0     width=34    height=45    xoffset=-1    yoffset=0     xadvance=32    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=88   x=222   y=0     width=27    height=45    xoffset=-1    yoffset=0     xadvance=25    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=89   x=164   y=0     width=27    height=45    xoffset=-1    yoffset=0     xadvance=25    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=90   x=0     y=47    width=23    height=45    xoffset=0     yoffset=0     xadvance=23    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=91   x=274   y=141   width=11    height=45    xoffset=1     yoffset=0     xadvance=12    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=92   x=300   y=141   width=10    height=45    xoffset=-1    yoffset=0     xadvance=9     page=0  chnl=15
 | 
				
			||||||
 | 
					char id=93   x=287   y=141   width=11    height=45    xoffset=0     yoffset=0     xadvance=12    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=94   x=457   y=94    width=19    height=45    xoffset=1     yoffset=0     xadvance=21    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=95   x=103   y=141   width=18    height=45    xoffset=-1    yoffset=0     xadvance=16    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=96   x=312   y=141   width=9     height=45    xoffset=0     yoffset=0     xadvance=11    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=97   x=474   y=47    width=21    height=45    xoffset=0     yoffset=0     xadvance=21    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=98   x=68    y=94    width=20    height=45    xoffset=1     yoffset=0     xadvance=21    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=99   x=267   y=47    width=21    height=45    xoffset=0     yoffset=0     xadvance=21    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=100  x=46    y=94    width=20    height=45    xoffset=0     yoffset=0     xadvance=21    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=101  x=198   y=47    width=21    height=45    xoffset=0     yoffset=0     xadvance=21    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=102  x=141   y=141   width=15    height=45    xoffset=-1    yoffset=0     xadvance=12    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=103  x=222   y=94    width=20    height=45    xoffset=0     yoffset=0     xadvance=21    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=104  x=415   y=94    width=19    height=45    xoffset=1     yoffset=0     xadvance=21    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=105  x=398   y=141   width=7     height=45    xoffset=2     yoffset=0     xadvance=11    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=106  x=235   y=141   width=11    height=45    xoffset=-2    yoffset=0     xadvance=11    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=107  x=405   y=47    width=21    height=45    xoffset=1     yoffset=0     xadvance=21    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=108  x=407   y=141   width=7     height=45    xoffset=2     yoffset=0     xadvance=11    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=109  x=102   y=0     width=30    height=45    xoffset=1     yoffset=0     xadvance=32    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=110  x=331   y=94    width=19    height=45    xoffset=1     yoffset=0     xadvance=21    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=111  x=428   y=47    width=21    height=45    xoffset=0     yoffset=0     xadvance=21    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=112  x=266   y=94    width=20    height=45    xoffset=1     yoffset=0     xadvance=21    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=113  x=288   y=94    width=20    height=45    xoffset=0     yoffset=0     xadvance=21    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=114  x=158   y=141   width=15    height=45    xoffset=1     yoffset=0     xadvance=14    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=115  x=244   y=94    width=20    height=45    xoffset=0     yoffset=0     xadvance=20    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=116  x=175   y=141   width=14    height=45    xoffset=0     yoffset=0     xadvance=14    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=117  x=436   y=94    width=19    height=45    xoffset=1     yoffset=0     xadvance=21    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=118  x=451   y=47    width=21    height=45    xoffset=0     yoffset=0     xadvance=20    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=119  x=36    y=0     width=32    height=45    xoffset=-1    yoffset=0     xadvance=30    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=120  x=0     y=94    width=21    height=45    xoffset=0     yoffset=0     xadvance=21    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=121  x=23    y=94    width=21    height=45    xoffset=0     yoffset=0     xadvance=20    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=122  x=83    y=141   width=18    height=45    xoffset=0     yoffset=0     xadvance=18    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=123  x=191   y=141   width=14    height=45    xoffset=-1    yoffset=0     xadvance=12    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=124  x=416   y=141   width=5     height=45    xoffset=2     yoffset=0     xadvance=9     page=0  chnl=15
 | 
				
			||||||
 | 
					char id=125  x=207   y=141   width=13    height=45    xoffset=0     yoffset=0     xadvance=12    page=0  chnl=15
 | 
				
			||||||
 | 
					char id=126  x=42    y=141   width=19    height=45    xoffset=1     yoffset=0     xadvance=21    page=0  chnl=15
 | 
				
			||||||
							
								
								
									
										
											BIN
										
									
								
								examples/resources/fonts/bmfont.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 14 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								examples/resources/fonts/pixantiqua.ttf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										
											BIN
										
									
								
								examples/resources/parrots.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 288 KiB  | 
							
								
								
									
										68
									
								
								examples/text_bmfont_ttf.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,68 @@
 | 
				
			|||||||
 | 
					/*******************************************************************************************
 | 
				
			||||||
 | 
					*
 | 
				
			||||||
 | 
					*   raylib [text] example - BMFont and TTF SpriteFonts loading
 | 
				
			||||||
 | 
					*
 | 
				
			||||||
 | 
					*   This example has been created using raylib 1.4 (www.raylib.com)
 | 
				
			||||||
 | 
					*   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
 | 
				
			||||||
 | 
					*
 | 
				
			||||||
 | 
					*   Copyright (c) 2016 Ramon Santamaria (@raysan5)
 | 
				
			||||||
 | 
					*
 | 
				
			||||||
 | 
					********************************************************************************************/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "raylib.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int main()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    // Initialization
 | 
				
			||||||
 | 
					    //--------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    int screenWidth = 800;
 | 
				
			||||||
 | 
					    int screenHeight = 450;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    InitWindow(screenWidth, screenHeight, "raylib [text] example - bmfont and ttf sprite fonts loading");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    const char msgBm[64] = "THIS IS AN AngelCode SPRITE FONT";
 | 
				
			||||||
 | 
					    const char msgTtf[64] = "THIS SPRITE FONT has been GENERATED from a TTF";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // NOTE: Textures/Fonts MUST be loaded after Window initialization (OpenGL context is required)
 | 
				
			||||||
 | 
					    SpriteFont fontBm = LoadSpriteFont("resources/fonts/bmfont.fnt");       // BMFont (AngelCode)
 | 
				
			||||||
 | 
					    SpriteFont fontTtf = LoadSpriteFont("resources/fonts/pixantiqua.ttf");  // TTF font
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Vector2 fontPosition;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    fontPosition.x = screenWidth/2 - MeasureTextEx(fontBm, msgBm, fontBm.size, 0).x/2;
 | 
				
			||||||
 | 
					    fontPosition.y = screenHeight/2 - fontBm.size/2 - 80;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    SetTargetFPS(60);
 | 
				
			||||||
 | 
					    //--------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Main game loop
 | 
				
			||||||
 | 
					    while (!WindowShouldClose())    // Detect window close button or ESC key
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        // Update
 | 
				
			||||||
 | 
					        //----------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					        // TODO: Update variables here...
 | 
				
			||||||
 | 
					        //----------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Draw
 | 
				
			||||||
 | 
					        //----------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					        BeginDrawing();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            ClearBackground(RAYWHITE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            DrawTextEx(fontBm, msgBm, fontPosition, fontBm.size, 0, MAROON);
 | 
				
			||||||
 | 
					            DrawTextEx(fontTtf, msgTtf, (Vector2){ 75.0f, 240.0f }, fontTtf.size*0.8f, 2, LIME);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        EndDrawing();
 | 
				
			||||||
 | 
					        //----------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // De-Initialization
 | 
				
			||||||
 | 
					    //--------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    UnloadSpriteFont(fontBm);     // AngelCode SpriteFont unloading
 | 
				
			||||||
 | 
					    UnloadSpriteFont(fontTtf);    // TTF SpriteFont unloading
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    CloseWindow();                // Close window and OpenGL context
 | 
				
			||||||
 | 
					    //--------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										
											BIN
										
									
								
								examples/text_bmfont_ttf.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 19 KiB  | 
							
								
								
									
										60
									
								
								examples/text_writing_anim.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,60 @@
 | 
				
			|||||||
 | 
					/*******************************************************************************************
 | 
				
			||||||
 | 
					*
 | 
				
			||||||
 | 
					*   raylib [text] example - Text Writing Animation
 | 
				
			||||||
 | 
					*
 | 
				
			||||||
 | 
					*   This example has been created using raylib 1.4 (www.raylib.com)
 | 
				
			||||||
 | 
					*   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
 | 
				
			||||||
 | 
					*
 | 
				
			||||||
 | 
					*   Copyright (c) 2016 Ramon Santamaria (@raysan5)
 | 
				
			||||||
 | 
					*
 | 
				
			||||||
 | 
					********************************************************************************************/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "raylib.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int main()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    // Initialization
 | 
				
			||||||
 | 
					    //--------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    int screenWidth = 800;
 | 
				
			||||||
 | 
					    int screenHeight = 450;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    InitWindow(screenWidth, screenHeight, "raylib [text] example - text writing anim");
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    const char message[128] = "This sample illustrates a text writing\nanimation effect! Check it out! ;)";
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    int framesCounter = 0;
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    SetTargetFPS(60);
 | 
				
			||||||
 | 
					    //--------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Main game loop
 | 
				
			||||||
 | 
					    while (!WindowShouldClose())    // Detect window close button or ESC key
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        // Update
 | 
				
			||||||
 | 
					        //----------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					        framesCounter++;
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (IsKeyPressed(KEY_ENTER)) framesCounter = 0;
 | 
				
			||||||
 | 
					        //----------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Draw
 | 
				
			||||||
 | 
					        //----------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					        BeginDrawing();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            ClearBackground(RAYWHITE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            DrawText(SubText(message, 0, framesCounter/10), 210, 160, 20, MAROON);
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					            DrawText("PRESS [ENTER] to RESTART!", 240, 280, 20, LIGHTGRAY);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        EndDrawing();
 | 
				
			||||||
 | 
					        //----------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // De-Initialization
 | 
				
			||||||
 | 
					    //--------------------------------------------------------------------------------------   
 | 
				
			||||||
 | 
					    CloseWindow();        // Close window and OpenGL context
 | 
				
			||||||
 | 
					    //--------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										
											BIN
										
									
								
								examples/text_writing_anim.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 15 KiB  | 
							
								
								
									
										78
									
								
								examples/textures_image_drawing.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,78 @@
 | 
				
			|||||||
 | 
					/*******************************************************************************************
 | 
				
			||||||
 | 
					*
 | 
				
			||||||
 | 
					*   raylib [textures] example - Image loading and drawing on it
 | 
				
			||||||
 | 
					*
 | 
				
			||||||
 | 
					*   NOTE: Images are loaded in CPU memory (RAM); textures are loaded in GPU memory (VRAM)
 | 
				
			||||||
 | 
					*
 | 
				
			||||||
 | 
					*   This example has been created using raylib 1.4 (www.raylib.com)
 | 
				
			||||||
 | 
					*   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
 | 
				
			||||||
 | 
					*
 | 
				
			||||||
 | 
					*   Copyright (c) 2016 Ramon Santamaria (@raysan5)
 | 
				
			||||||
 | 
					*
 | 
				
			||||||
 | 
					********************************************************************************************/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "raylib.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int main()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    // Initialization
 | 
				
			||||||
 | 
					    //--------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    int screenWidth = 800;
 | 
				
			||||||
 | 
					    int screenHeight = 450;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    InitWindow(screenWidth, screenHeight, "raylib [textures] example - image drawing");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Image cat = LoadImage("resources/cat.png");             // Load image in CPU memory (RAM)
 | 
				
			||||||
 | 
					    ImageCrop(&cat, (Rectangle){ 170, 120, 280, 380 });     // Crop an image piece
 | 
				
			||||||
 | 
					    ImageFlipHorizontal(&cat);                              // Flip cropped image horizontally
 | 
				
			||||||
 | 
					    ImageResize(&cat, 150, 200);                            // Resize flipped-cropped image
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Image parrots = LoadImage("resources/parrots.png");     // Load image in CPU memory (RAM)
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    // Draw one image over the other with a scaling of 1.5f
 | 
				
			||||||
 | 
					    ImageDraw(&parrots, cat, (Rectangle){ 0, 0, cat.width, cat.height}, (Rectangle){ 30, 40, cat.width*1.5f, cat.height*1.5f });
 | 
				
			||||||
 | 
					    ImageCrop(&parrots, (Rectangle){ 0, 50, parrots.width, parrots.height - 100 }); // Crop resulting image
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    UnloadImage(cat);       // Unload image from RAM
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Texture2D texture = LoadTextureFromImage(parrots);      // Image converted to texture, uploaded to GPU memory (VRAM)
 | 
				
			||||||
 | 
					    UnloadImage(parrots);   // Once image has been converted to texture and uploaded to VRAM, it can be unloaded from RAM
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    SetTargetFPS(60);
 | 
				
			||||||
 | 
					    //---------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Main game loop
 | 
				
			||||||
 | 
					    while (!WindowShouldClose())    // Detect window close button or ESC key
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        // Update
 | 
				
			||||||
 | 
					        //----------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					        // TODO: Update your variables here
 | 
				
			||||||
 | 
					        //----------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Draw
 | 
				
			||||||
 | 
					        //----------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					        BeginDrawing();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            ClearBackground(RAYWHITE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            DrawTexture(texture, screenWidth/2 - texture.width/2, screenHeight/2 - texture.height/2 - 40, WHITE);
 | 
				
			||||||
 | 
					            DrawRectangleLines(screenWidth/2 - texture.width/2, screenHeight/2 - texture.height/2 - 40, texture.width, texture.height, DARKGRAY);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            DrawText("We are drawing only one texture from various images composed!", 240, 350, 10, DARKGRAY);
 | 
				
			||||||
 | 
					            DrawText("Source images have been cropped, scaled, flipped and copied one over the other.", 190, 370, 10, DARKGRAY);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        EndDrawing();
 | 
				
			||||||
 | 
					        //----------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // De-Initialization
 | 
				
			||||||
 | 
					    //--------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    UnloadTexture(texture);       // Texture unloading
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    CloseWindow();                // Close window and OpenGL context
 | 
				
			||||||
 | 
					    //--------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										
											BIN
										
									
								
								examples/textures_image_drawing.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 410 KiB  | 
							
								
								
									
										154
									
								
								examples/textures_image_processing.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,154 @@
 | 
				
			|||||||
 | 
					/*******************************************************************************************
 | 
				
			||||||
 | 
					*
 | 
				
			||||||
 | 
					*   raylib [textures] example - Image processing
 | 
				
			||||||
 | 
					*
 | 
				
			||||||
 | 
					*   NOTE: Images are loaded in CPU memory (RAM); textures are loaded in GPU memory (VRAM)
 | 
				
			||||||
 | 
					*
 | 
				
			||||||
 | 
					*   This example has been created using raylib 1.4 (www.raylib.com)
 | 
				
			||||||
 | 
					*   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
 | 
				
			||||||
 | 
					*
 | 
				
			||||||
 | 
					*   Copyright (c) 2016 Ramon Santamaria (@raysan5)
 | 
				
			||||||
 | 
					*
 | 
				
			||||||
 | 
					********************************************************************************************/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "raylib.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <stdlib.h>     // Required for: free()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define NUM_PROCESSES    8
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					typedef enum { 
 | 
				
			||||||
 | 
					    NONE = 0, 
 | 
				
			||||||
 | 
					    COLOR_GRAYSCALE, 
 | 
				
			||||||
 | 
					    COLOR_TINT, 
 | 
				
			||||||
 | 
					    COLOR_INVERT, 
 | 
				
			||||||
 | 
					    COLOR_CONTRAST, 
 | 
				
			||||||
 | 
					    COLOR_BRIGHTNESS, 
 | 
				
			||||||
 | 
					    FLIP_VERTICAL, 
 | 
				
			||||||
 | 
					    FLIP_HORIZONTAL 
 | 
				
			||||||
 | 
					} ImageProcess;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static const char *processText[] = {
 | 
				
			||||||
 | 
					    "NO PROCESSING",
 | 
				
			||||||
 | 
					    "COLOR GRAYSCALE",
 | 
				
			||||||
 | 
					    "COLOR TINT",
 | 
				
			||||||
 | 
					    "COLOR INVERT",
 | 
				
			||||||
 | 
					    "COLOR CONTRAST",
 | 
				
			||||||
 | 
					    "COLOR BRIGHTNESS",
 | 
				
			||||||
 | 
					    "FLIP VERTICAL",
 | 
				
			||||||
 | 
					    "FLIP HORIZONTAL"
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int main()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    // Initialization
 | 
				
			||||||
 | 
					    //--------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    int screenWidth = 800;
 | 
				
			||||||
 | 
					    int screenHeight = 450;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    InitWindow(screenWidth, screenHeight, "raylib [textures] example - image processing");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Image image = LoadImage("resources/parrots.png");   // Loaded in CPU memory (RAM)
 | 
				
			||||||
 | 
					    ImageFormat(&image, UNCOMPRESSED_R8G8B8A8);         // Format image to RGBA 32bit (required for texture update)
 | 
				
			||||||
 | 
					    Texture2D texture = LoadTextureFromImage(image);    // Image converted to texture, GPU memory (VRAM)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    int currentProcess = NONE;
 | 
				
			||||||
 | 
					    bool textureReload = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Rectangle selectRecs[NUM_PROCESSES];
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    for (int i = 0; i < NUM_PROCESSES; i++) selectRecs[i] = (Rectangle){ 40, 50 + 32*i, 150, 30 };
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    SetTargetFPS(60);
 | 
				
			||||||
 | 
					    //---------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Main game loop
 | 
				
			||||||
 | 
					    while (!WindowShouldClose())    // Detect window close button or ESC key
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        // Update
 | 
				
			||||||
 | 
					        //----------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					        if (IsKeyPressed(KEY_DOWN))
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            currentProcess++;
 | 
				
			||||||
 | 
					            if (currentProcess > 7) currentProcess = 0;
 | 
				
			||||||
 | 
					            textureReload = true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else if (IsKeyPressed(KEY_UP))
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            currentProcess--;
 | 
				
			||||||
 | 
					            if (currentProcess < 0) currentProcess = 7;
 | 
				
			||||||
 | 
					            textureReload = true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (textureReload)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            UnloadImage(image);                         // Unload current image data
 | 
				
			||||||
 | 
					            image = LoadImage("resources/parrots.png"); // Re-load image data
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // NOTE: Image processing is a costly CPU process to be done every frame, 
 | 
				
			||||||
 | 
					            // If image processing is required in a frame-basis, it should be done 
 | 
				
			||||||
 | 
					            // with a texture and by shaders
 | 
				
			||||||
 | 
					            switch (currentProcess)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                case COLOR_GRAYSCALE: ImageColorGrayscale(&image); break;
 | 
				
			||||||
 | 
					                case COLOR_TINT: ImageColorTint(&image, GREEN); break;
 | 
				
			||||||
 | 
					                case COLOR_INVERT: ImageColorInvert(&image); break;
 | 
				
			||||||
 | 
					                case COLOR_CONTRAST: ImageColorContrast(&image, -40); break;
 | 
				
			||||||
 | 
					                case COLOR_BRIGHTNESS: ImageColorBrightness(&image, -80); break;
 | 
				
			||||||
 | 
					                case FLIP_VERTICAL: ImageFlipVertical(&image); break;
 | 
				
			||||||
 | 
					                case FLIP_HORIZONTAL: ImageFlipHorizontal(&image); break;
 | 
				
			||||||
 | 
					                default: break;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					            Color *pixels = GetImageData(image);        // Get pixel data from image (RGBA 32bit)
 | 
				
			||||||
 | 
					            UpdateTexture(texture, pixels);             // Update texture with new image data
 | 
				
			||||||
 | 
					            free(pixels);                               // Unload pixels data from RAM
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					            textureReload = false;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        //----------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Draw
 | 
				
			||||||
 | 
					        //----------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					        BeginDrawing();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            ClearBackground(RAYWHITE);
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					            DrawText("IMAGE PROCESSING:", 40, 30, 10, DARKGRAY);
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					            // Draw rectangles
 | 
				
			||||||
 | 
					            for (int i = 0; i < NUM_PROCESSES; i++)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (i == currentProcess)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    DrawRectangleRec(selectRecs[i], SKYBLUE);
 | 
				
			||||||
 | 
					                    DrawRectangleLines(selectRecs[i].x, selectRecs[i].y, selectRecs[i].width, selectRecs[i].height, BLUE);
 | 
				
			||||||
 | 
					                    DrawText(processText[i], selectRecs[i].x + selectRecs[i].width/2 - MeasureText(processText[i], 10)/2, selectRecs[i].y + 11, 10, DARKBLUE);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    DrawRectangleRec(selectRecs[i], LIGHTGRAY);
 | 
				
			||||||
 | 
					                    DrawRectangleLines(selectRecs[i].x, selectRecs[i].y, selectRecs[i].width, selectRecs[i].height, GRAY);
 | 
				
			||||||
 | 
					                    DrawText(processText[i], selectRecs[i].x + selectRecs[i].width/2 - MeasureText(processText[i], 10)/2, selectRecs[i].y + 11, 10, DARKGRAY);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            DrawTexture(texture, screenWidth - texture.width - 60, screenHeight/2 - texture.height/2, WHITE);
 | 
				
			||||||
 | 
					            DrawRectangleLines(screenWidth - texture.width - 60, screenHeight/2 - texture.height/2, texture.width, texture.height, BLACK);
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					        EndDrawing();
 | 
				
			||||||
 | 
					        //----------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // De-Initialization
 | 
				
			||||||
 | 
					    //--------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    UnloadTexture(texture);       // Unload texture from VRAM
 | 
				
			||||||
 | 
					    UnloadImage(image);           // Unload image from RAM
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    CloseWindow();                // Close window and OpenGL context
 | 
				
			||||||
 | 
					    //--------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										
											BIN
										
									
								
								examples/textures_image_processing.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 253 KiB  |