Browse Source

Code used to test some features (and resources)

pull/3/head
raysan5 11 years ago
parent
commit
f76a00adc1
25 changed files with 5160 additions and 12 deletions
  1. BIN
      tests/resources/audio/0564.ogg
  2. BIN
      tests/resources/audio/coin.wav
  3. BIN
      tests/resources/audio/deserve_to_be_loved.ogg
  4. BIN
      tests/resources/audio/destiny.ogg
  5. BIN
      tests/resources/audio/spring.wav
  6. BIN
      tests/resources/audio/weird.wav
  7. +4731
    -0
      tests/resources/cat.obj
  8. BIN
      tests/resources/catsham.png
  9. BIN
      tests/resources/catwhite.png
  10. +0
    -0
      tests/resources/heightmap.png
  11. BIN
      tests/resources/mouse.png
  12. BIN
      tests/resources/raylib_logo.dds
  13. BIN
      tests/resources/raylib_logo.png
  14. BIN
      tests/resources/raylib_logo_uncompressed.dds
  15. +79
    -0
      tests/test_3d_models.c
  16. +2
    -2
      tests/test_billboard.c
  17. +1
    -1
      tests/test_formattext.c
  18. +7
    -6
      tests/test_heightmap.c
  19. +2
    -2
      tests/test_image_loading.c
  20. +1
    -1
      tests/test_mouse_wheel.c
  21. +86
    -0
      tests/test_music_stream.c
  22. +60
    -0
      tests/test_sound_ogg.c
  23. +59
    -0
      tests/test_texture_mipmaps.c
  24. +66
    -0
      tests/test_texture_pro.c
  25. +66
    -0
      tests/test_textures_dds.c

BIN
tests/resources/audio/0564.ogg View File


BIN
tests/resources/audio/coin.wav View File


BIN
tests/resources/audio/deserve_to_be_loved.ogg View File


BIN
tests/resources/audio/destiny.ogg View File


BIN
tests/resources/audio/spring.wav View File


BIN
tests/resources/audio/weird.wav View File


+ 4731
- 0
tests/resources/cat.obj
File diff suppressed because it is too large
View File


BIN
tests/resources/catsham.png View File

Before After
Width: 512  |  Height: 512  |  Size: 308 KiB

BIN
tests/resources/catwhite.png View File

Before After
Width: 512  |  Height: 512  |  Size: 302 KiB

tests/heightmap.png → tests/resources/heightmap.png View File


BIN
tests/resources/mouse.png View File

Before After
Width: 32  |  Height: 32  |  Size: 1.7 KiB

BIN
tests/resources/raylib_logo.dds View File


BIN
tests/resources/raylib_logo.png View File

Before After
Width: 256  |  Height: 256  |  Size: 3.7 KiB

BIN
tests/resources/raylib_logo_uncompressed.dds View File


+ 79
- 0
tests/test_3d_models.c View File

@ -0,0 +1,79 @@
/*******************************************************************************************
*
* raylib test - Load and draw a 3d model (OBJ)
*
* This test has been created using raylib 1.1 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
*
********************************************************************************************/
#include "raylib.h"
int main()
{
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
Vector3 position = { 0.0, 0.0, 0.0 };
// Define the camera to look into our 3d world
Camera camera = {{ 10.0, 8.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }};
InitWindow(screenWidth, screenHeight, "raylib test - 3d models in OpenGL 3.3+");
Texture2D texture = LoadTexture("resources/catwhite.png");
Model cat = LoadModel("resources/cat.obj");
SetModelTexture(&cat, texture);
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
if (IsKeyDown(KEY_LEFT)) position.x -= 0.2;
if (IsKeyDown(KEY_RIGHT)) position.x += 0.2;
if (IsKeyDown(KEY_UP)) position.z -= 0.2;
if (IsKeyDown(KEY_DOWN)) position.z += 0.2;
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
Begin3dMode(camera);
DrawModel(cat, position, 0.1f, BEIGE); // OK_GL11, OK_GL33
//DrawModelWires(cat, position, 0.1f, RED); // OK_GL11, OK_GL33
DrawGrid(10.0, 1.0); // Draw a grid
DrawGizmo(position);
End3dMode();
DrawFPS(10, 10);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
UnloadTexture(texture); // Unload texture
UnloadModel(cat); // Unload model
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}

+ 2
- 2
tests/test_billboard.c View File

@ -2,10 +2,10 @@
*
* raylib test - Testing DrawBillboard() and DrawBillboardRec()
*
* This example has been created using raylib 1.0 (www.raylib.com)
* This test has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com)
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
*
********************************************************************************************/

+ 1
- 1
tests/test_formattext.c View File

@ -2,7 +2,7 @@
*
* raylib test - Testing FormatText() function
*
* This example has been created using raylib 1.0 (www.raylib.com)
* This test has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com)

+ 7
- 6
tests/test_heightmap.c View File

@ -2,10 +2,10 @@
*
* raylib test - Testing Heightmap Loading and Drawing
*
* This example has been created using raylib 1.0 (www.raylib.com)
* This test has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com)
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
*
********************************************************************************************/
@ -25,11 +25,13 @@ int main()
InitWindow(screenWidth, screenHeight, "raylib test - Heightmap loading and drawing");
Image img = LoadImage("heightmap.png");
Image img = LoadImage("resources/heightmap.png");
Model map = LoadHeightmap(img, 4);
Texture2D tex = CreateTexture(img);
Texture2D texture = CreateTexture(img, false);
UnloadImage(img);
SetModelTexture(&map, texture);
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
@ -49,8 +51,7 @@ int main()
Begin3dMode(camera);
//DrawModel(map, position, 0.5f, MAROON);
DrawModelEx(map, tex, position, 0.5f, WHITE); // Draw 3d model with texture
DrawModel(map, position, 0.5f, MAROON);
DrawGrid(10.0, 1.0); // Draw a grid

+ 2
- 2
tests/test_image_loading.c View File

@ -2,7 +2,7 @@
*
* raylib test - Testing LoadImage() and CreateTexture()
*
* This example has been created using raylib 1.0 (www.raylib.com)
* This test has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com)
@ -23,7 +23,7 @@ int main()
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
Image img = LoadImage("resources/raylib_logo.png");
Texture2D texture = CreateTexture(img);
Texture2D texture = CreateTexture(img, false);
UnloadImage(img);
//---------------------------------------------------------------------------------------

+ 1
- 1
tests/test_mouse_wheel.c View File

@ -2,7 +2,7 @@
*
* raylib test - Testing GetMouseWheelMove()
*
* This example has been created using raylib 1.0 (www.raylib.com)
* This test has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com)

+ 86
- 0
tests/test_music_stream.c View File

@ -0,0 +1,86 @@
/*******************************************************************************************
*
* raylib test - Music playing (streaming)
*
* NOTE: This test requires OpenAL32 dll installed (or in the same folder)
*
* This test has been created using raylib 1.1 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
*
********************************************************************************************/
#include "raylib.h"
int main()
{
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib test - music playing (streaming)");
InitAudioDevice(); // Initialize audio device
PlayMusicStream("resources/audio/deserve_to_be_loved.ogg"); // Load Music file
int framesCounter = 0;
float volume = 1.0;
float timePlayed = 0;
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
framesCounter++;
// Testing music fading
/*
if (framesCounter > 600)
{
volume -= 0.01;
if (volume <= 0)
{
volume = 1.0;
framesCounter = -600;
PlayMusicStream("resources/audio/destiny.ogg");
}
SetMusicVolume(volume);
}
*/
timePlayed = GetMusicTimePlayed() / GetMusicTimeLength() * 100 * 4; // We scale by 4 to fit 400 pixels
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
DrawText("MUSIC SHOULD BE PLAYING!", 255, 200, 20, LIGHTGRAY);
DrawRectangle(200, 250, 400, 12, LIGHTGRAY);
DrawRectangle(200, 250, (int)timePlayed, 12, MAROON);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
CloseAudioDevice(); // Close audio device (music streaming is automatically stopped)
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}

+ 60
- 0
tests/test_sound_ogg.c View File

@ -0,0 +1,60 @@
/*******************************************************************************************
*
* raylib test - OGG audio loading and playing
*
* NOTE: This test requires OpenAL32 dll installed (or in the same folder)
*
* This test has been created using raylib 1.1 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
*
********************************************************************************************/
#include "raylib.h"
int main()
{
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib test - ogg audio loading and playing");
InitAudioDevice(); // Initialize audio device
Sound fx = LoadSound("resources/audio/0564.ogg"); // Load audio file
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
if (IsKeyPressed(KEY_SPACE)) PlaySound(fx); // Play the sound!
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
DrawText("Press SPACE to PLAY the SOUND!", 240, 200, 20, LIGHTGRAY);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
UnloadSound(fx); // Unload sound data
CloseAudioDevice(); // Close audio device
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}

+ 59
- 0
tests/test_texture_mipmaps.c View File

@ -0,0 +1,59 @@
/*******************************************************************************************
*
* raylib test - Texture loading with mipmaps, mipmaps generation
*
* This test has been created using raylib 1.1 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
*
********************************************************************************************/
#include "raylib.h"
int main()
{
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib test - texture mipmaps");
Image image = LoadImage("resources/raylib_logo.png");
Texture2D texture = CreateTexture(image, true);
// NOTE: With OpenGL 3.3 mipmaps generation works great (automatic generation)
// NOTE: With OpenGL 1.1 mipmaps generation works great too! (manual generation)
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
// TODO: Update your variables here
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
DrawTexture(texture, 0, 0, WHITE);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
UnloadTexture(texture); // Texture unloading
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}

+ 66
- 0
tests/test_texture_pro.c View File

@ -0,0 +1,66 @@
/*******************************************************************************************
*
* raylib test - Texture loading and drawing with pro parameters (rotation, origin, scale...)
*
* This test has been created using raylib 1.1 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
*
********************************************************************************************/
#include "raylib.h"
int main()
{
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib test - texture pro");
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
Texture2D texture = LoadTexture("resources/raylib_logo.png"); // Texture loading
Vector2 position = { 200, 100 };
Rectangle sourceRec = { 128, 128, 128, 128 };
Rectangle destRec = { 128, 128, 128, 128 };
Vector2 origin = { 64, 64 }; // NOTE: origin is relative to destRec size
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
// TODO: Update your variables here
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
//DrawTextureEx(texture, position, 45, 1, MAROON);
DrawTexturePro(texture, sourceRec, destRec, origin, 45, GREEN);
DrawLine(destRec.x, 0, destRec.x, screenHeight, RED);
DrawLine(0, destRec.y, screenWidth, destRec.y, RED);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
UnloadTexture(texture); // Texture unloading
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}

+ 66
- 0
tests/test_textures_dds.c View File

@ -0,0 +1,66 @@
/*******************************************************************************************
*
* raylib test - DDS Texture loading and drawing (compressed and uncompressed)
*
* This test has been created using raylib 1.1 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
*
********************************************************************************************/
#include "raylib.h"
int main()
{
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib test - DDS texture loading and drawing");
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
//Texture2D texture = LoadTexture("resources/raylib_logo.dds"); // Texture loading
//Texture2D texture = LoadTexture("resources/raylib_logo_uncompressed.dds"); // Texture loading
Image image = LoadImage("resources/raylib_logo_uncompressed.dds");
Texture2D texture = CreateTexture(image, false);
// NOTE: With OpenGL 3.3 mipmaps generation works great
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, WHITE);
DrawText("this IS a texture!", 360, 370, 10, GRAY);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
//UnloadTexture(texture); // Texture unloading
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}

Loading…
Cancel
Save