Replaced some images and updated examples
BIN
examples/shaders/resources/fudesumi.png
Normal file
After Width: | Height: | Size: 214 KiB |
Before Width: | Height: | Size: 114 KiB |
|
@ -9,7 +9,7 @@
|
||||||
* on OpenGL ES 2.0 platforms (Android, Raspberry Pi, HTML5), use #version 100 shaders
|
* on OpenGL ES 2.0 platforms (Android, Raspberry Pi, HTML5), use #version 100 shaders
|
||||||
* raylib comes with shaders ready for both versions, check raylib/shaders install folder
|
* raylib comes with shaders ready for both versions, check raylib/shaders install folder
|
||||||
*
|
*
|
||||||
* This example has been created using raylib 1.3 (www.raylib.com)
|
* This example has been created using raylib 1.7 (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) 2015 Ramon Santamaria (@raysan5)
|
* Copyright (c) 2015 Ramon Santamaria (@raysan5)
|
||||||
|
@ -18,9 +18,6 @@
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
|
@ -30,14 +27,12 @@ int main()
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - shapes and texture shaders");
|
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - shapes and texture shaders");
|
||||||
|
|
||||||
Texture2D sonic = LoadTexture("resources/texture_formats/sonic.png");
|
Texture2D fudesumi = LoadTexture("resources/fudesumi.png");
|
||||||
|
|
||||||
// NOTE: Using GLSL 330 shader version, on OpenGL ES 2.0 use GLSL 100 shader version
|
// NOTE: Using GLSL 330 shader version, on OpenGL ES 2.0 use GLSL 100 shader version
|
||||||
Shader shader = LoadShader("resources/shaders/glsl330/base.vs",
|
Shader shader = LoadShader("resources/shaders/glsl330/base.vs",
|
||||||
"resources/shaders/glsl330/grayscale.fs");
|
"resources/shaders/glsl330/grayscale.fs");
|
||||||
|
|
||||||
// Shader usage is also different than models/postprocessing, shader is just activated when required
|
|
||||||
|
|
||||||
SetTargetFPS(60);
|
SetTargetFPS(60);
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -91,11 +86,13 @@ int main()
|
||||||
// Activate our custom shader to be applied on next shapes/textures drawings
|
// Activate our custom shader to be applied on next shapes/textures drawings
|
||||||
BeginShaderMode(shader);
|
BeginShaderMode(shader);
|
||||||
|
|
||||||
DrawTexture(sonic, 380, -10, WHITE); // Using custom shader
|
DrawTexture(fudesumi, 500, -30, WHITE); // Using custom shader
|
||||||
|
|
||||||
// Activate our default shader for next drawings
|
// Activate our default shader for next drawings
|
||||||
EndShaderMode();
|
EndShaderMode();
|
||||||
|
|
||||||
|
DrawText("(c) Fudesumi sprite by Eiden Marsal", 380, screenHeight - 20, 10, GRAY);
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
|
@ -103,7 +100,7 @@ int main()
|
||||||
// De-Initialization
|
// De-Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
UnloadShader(shader); // Unload shader
|
UnloadShader(shader); // Unload shader
|
||||||
UnloadTexture(sonic); // Unload texture
|
UnloadTexture(fudesumi); // Unload texture
|
||||||
|
|
||||||
CloseWindow(); // Close window and OpenGL context
|
CloseWindow(); // Close window and OpenGL context
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
Before Width: | Height: | Size: 108 KiB After Width: | Height: | Size: 164 KiB |
BIN
examples/textures/resources/fudesumi.png
Normal file
After Width: | Height: | Size: 214 KiB |
BIN
examples/textures/resources/fudesumi.raw
Normal file
|
@ -27,9 +27,9 @@ int main()
|
||||||
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
|
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
|
||||||
|
|
||||||
// Load RAW image data (512x512, 32bit RGBA, no file header)
|
// Load RAW image data (512x512, 32bit RGBA, no file header)
|
||||||
Image sonicRaw = LoadImageRaw("resources/texture_formats/sonic_R8G8B8A8.raw", 512, 512, UNCOMPRESSED_R8G8B8A8, 0);
|
Image fudesumiRaw = LoadImageRaw("resources/fudesumi.raw", 384, 512, UNCOMPRESSED_R8G8B8A8, 0);
|
||||||
Texture2D sonic = LoadTextureFromImage(sonicRaw); // Upload CPU (RAM) image to GPU (VRAM)
|
Texture2D fudesumi = LoadTextureFromImage(fudesumiRaw); // Upload CPU (RAM) image to GPU (VRAM)
|
||||||
UnloadImage(sonicRaw); // Unload CPU (RAM) image data
|
UnloadImage(fudesumiRaw); // Unload CPU (RAM) image data
|
||||||
|
|
||||||
// Generate a checked texture by code (1024x1024 pixels)
|
// Generate a checked texture by code (1024x1024 pixels)
|
||||||
int width = 1024;
|
int width = 1024;
|
||||||
|
@ -42,8 +42,8 @@ int main()
|
||||||
{
|
{
|
||||||
for (int x = 0; x < width; x++)
|
for (int x = 0; x < width; x++)
|
||||||
{
|
{
|
||||||
if (((x/32+y/32)/1)%2 == 0) pixels[y*height + x] = DARKBLUE;
|
if (((x/32+y/32)/1)%2 == 0) pixels[y*height + x] = ORANGE;
|
||||||
else pixels[y*height + x] = SKYBLUE;
|
else pixels[y*height + x] = GOLD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,12 +70,14 @@ int main()
|
||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
DrawTexture(checked, screenWidth/2 - checked.width/2, screenHeight/2 - checked.height/2, Fade(WHITE, 0.3f));
|
DrawTexture(checked, screenWidth/2 - checked.width/2, screenHeight/2 - checked.height/2, Fade(WHITE, 0.5f));
|
||||||
DrawTexture(sonic, 330, -20, WHITE);
|
DrawTexture(fudesumi, 430, -30, WHITE);
|
||||||
|
|
||||||
DrawText("CHECKED TEXTURE ", 84, 100, 30, DARKBLUE);
|
DrawText("CHECKED TEXTURE ", 84, 100, 30, BROWN);
|
||||||
DrawText("GENERATED by CODE", 72, 164, 30, DARKBLUE);
|
DrawText("GENERATED by CODE", 72, 164, 30, BROWN);
|
||||||
DrawText("and RAW IMAGE LOADING", 46, 226, 30, DARKBLUE);
|
DrawText("and RAW IMAGE LOADING", 46, 226, 30, BROWN);
|
||||||
|
|
||||||
|
DrawText("(c) Fudesumi sprite by Eiden Marsal", 310, screenHeight - 20, 10, BROWN);
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
@ -83,7 +85,7 @@ int main()
|
||||||
|
|
||||||
// De-Initialization
|
// De-Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
UnloadTexture(sonic); // Texture unloading
|
UnloadTexture(fudesumi); // Texture unloading
|
||||||
UnloadTexture(checked); // Texture unloading
|
UnloadTexture(checked); // Texture unloading
|
||||||
|
|
||||||
CloseWindow(); // Close window and OpenGL context
|
CloseWindow(); // Close window and OpenGL context
|
||||||
|
|
Before Width: | Height: | Size: 85 KiB After Width: | Height: | Size: 240 KiB |
|
@ -21,10 +21,10 @@ int main()
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [textures] examples - texture source and destination rectangles");
|
InitWindow(screenWidth, screenHeight, "raylib [textures] examples - texture source and destination rectangles");
|
||||||
|
|
||||||
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
|
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
|
||||||
Texture2D guybrush = LoadTexture("resources/guybrush.png"); // Texture loading
|
Texture2D scarfy = LoadTexture("resources/scarfy.png"); // Texture loading
|
||||||
|
|
||||||
int frameWidth = guybrush.width/7;
|
int frameWidth = scarfy.width/6;
|
||||||
int frameHeight = guybrush.height;
|
int frameHeight = scarfy.height;
|
||||||
|
|
||||||
// NOTE: Source rectangle (part of the texture to use for drawing)
|
// NOTE: Source rectangle (part of the texture to use for drawing)
|
||||||
Rectangle sourceRec = { 0, 0, frameWidth, frameHeight };
|
Rectangle sourceRec = { 0, 0, frameWidth, frameHeight };
|
||||||
|
@ -59,18 +59,20 @@ int main()
|
||||||
// destRec defines the rectangle where our texture part will fit (scaling it to fit)
|
// destRec defines the rectangle where our texture part will fit (scaling it to fit)
|
||||||
// origin defines the point of the texture used as reference for rotation and scaling
|
// origin defines the point of the texture used as reference for rotation and scaling
|
||||||
// rotation defines the texture rotation (using origin as rotation point)
|
// rotation defines the texture rotation (using origin as rotation point)
|
||||||
DrawTexturePro(guybrush, sourceRec, destRec, origin, rotation, WHITE);
|
DrawTexturePro(scarfy, sourceRec, destRec, origin, rotation, WHITE);
|
||||||
|
|
||||||
DrawLine(destRec.x, 0, destRec.x, screenHeight, GRAY);
|
DrawLine(destRec.x, 0, destRec.x, screenHeight, GRAY);
|
||||||
DrawLine(0, destRec.y, screenWidth, destRec.y, GRAY);
|
DrawLine(0, destRec.y, screenWidth, destRec.y, GRAY);
|
||||||
|
|
||||||
|
DrawText("(c) Scarfy sprite by Eiden Marsal", screenWidth - 200, screenHeight - 20, 10, GRAY);
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
|
|
||||||
// De-Initialization
|
// De-Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
UnloadTexture(guybrush); // Texture unloading
|
UnloadTexture(scarfy); // Texture unloading
|
||||||
|
|
||||||
CloseWindow(); // Close window and OpenGL context
|
CloseWindow(); // Close window and OpenGL context
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
Before Width: | Height: | Size: 46 KiB After Width: | Height: | Size: 37 KiB |