summaryrefslogtreecommitdiffhomepage
path: root/examples/others
diff options
context:
space:
mode:
Diffstat (limited to 'examples/others')
-rw-r--r--examples/others/audio_standalone.c25
-rw-r--r--examples/others/bunnymark.c23
-rw-r--r--examples/others/resources/shaders/glsl100/standard.vs4
-rw-r--r--examples/others/resources/shaders/glsl330/standard.vs4
4 files changed, 26 insertions, 30 deletions
diff --git a/examples/others/audio_standalone.c b/examples/others/audio_standalone.c
index 0a09c988..38fe9935 100644
--- a/examples/others/audio_standalone.c
+++ b/examples/others/audio_standalone.c
@@ -26,14 +26,11 @@
********************************************************************************************/
#include <stdio.h>
+#include "audio.h"
#if defined(_WIN32)
#include <conio.h> // Windows only, no stardard library
-#endif
-
-#include "audio.h"
-
-#if defined(__linux__)
+#else
#include <stdio.h>
#include <termios.h>
#include <unistd.h>
@@ -79,13 +76,13 @@ int main()
{
// Initialization
//--------------------------------------------------------------------------------------
- unsigned char key;
-
+ static unsigned char key;
+
InitAudioDevice();
-
+
Sound fxWav = LoadSound("resources/audio/weird.wav"); // Load WAV audio file
Sound fxOgg = LoadSound("resources/audio/tanatana.ogg"); // Load OGG audio file
-
+
Music music = LoadMusicStream("resources/audio/guitar_noodling.ogg");
PlayMusicStream(music);
@@ -102,23 +99,23 @@ int main()
PlaySound(fxWav);
key = 0;
}
-
+
if (key == 'd')
{
PlaySound(fxOgg);
key = 0;
}
-
+
UpdateMusicStream(music);
}
-
+
// De-Initialization
//--------------------------------------------------------------------------------------
UnloadSound(fxWav); // Unload sound data
UnloadSound(fxOgg); // Unload sound data
-
+
UnloadMusicStream(music); // Unload music stream data
-
+
CloseAudioDevice();
//--------------------------------------------------------------------------------------
diff --git a/examples/others/bunnymark.c b/examples/others/bunnymark.c
index 1ada54db..8b524b01 100644
--- a/examples/others/bunnymark.c
+++ b/examples/others/bunnymark.c
@@ -10,7 +10,6 @@
********************************************************************************************/
#include "raylib.h"
-
#include <stdlib.h> // Required for: malloc(), free()
#define MAX_BUNNIES 100000 // 100K bunnies
@@ -29,15 +28,16 @@ int main()
int screenHeight = 960;
InitWindow(screenWidth, screenHeight, "raylib example - Bunnymark");
-
+
Texture2D texBunny = LoadTexture("resources/wabbit_alpha.png");
-
+
Bunny *bunnies = (Bunny *)malloc(MAX_BUNNIES*sizeof(Bunny)); // Bunnies array
+
int bunniesCount = 0; // Bunnies counter
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
-
+
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
@@ -54,7 +54,7 @@ int main()
bunniesCount++;
}
}
-
+
// Update bunnies
for (int i = 0; i < bunniesCount; i++)
{
@@ -65,14 +65,14 @@ int main()
if ((bunnies[i].position.y > GetScreenHeight()) || (bunnies[i].position.y < 0)) bunnies[i].speed.y *= -1;
}
//----------------------------------------------------------------------------------
-
+
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
-
- for (int i = 0; i <= bunniesCount; i++)
+
+ for (int i = 0; i < bunniesCount; i++)
{
// NOTE: When internal QUADS batch limit is reached, a draw call is launched and
// batching buffer starts being filled again; before launching the draw call,
@@ -80,11 +80,10 @@ int main()
// a stall and consequently a frame drop, limiting number of bunnies drawn at 60 fps
DrawTexture(texBunny, bunnies[i].position.x, bunnies[i].position.y, RAYWHITE);
}
-
+
DrawRectangle(0, 0, screenWidth, 40, LIGHTGRAY);
DrawText("raylib bunnymark", 10, 10, 20, DARKGRAY);
DrawText(FormatText("bunnies: %i", bunniesCount), 400, 10, 20, RED);
-
DrawFPS(260, 10);
EndDrawing();
@@ -94,9 +93,9 @@ int main()
// De-Initialization
//--------------------------------------------------------------------------------------
free(bunnies);
-
+
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
-} \ No newline at end of file
+}
diff --git a/examples/others/resources/shaders/glsl100/standard.vs b/examples/others/resources/shaders/glsl100/standard.vs
index 49c5a3eb..2b958938 100644
--- a/examples/others/resources/shaders/glsl100/standard.vs
+++ b/examples/others/resources/shaders/glsl100/standard.vs
@@ -10,7 +10,7 @@ varying vec2 fragTexCoord;
varying vec4 fragColor;
varying vec3 fragNormal;
-uniform mat4 mvpMatrix;
+uniform mat4 mvp;
void main()
{
@@ -19,5 +19,5 @@ void main()
fragColor = vertexColor;
fragNormal = vertexNormal;
- gl_Position = mvpMatrix*vec4(vertexPosition, 1.0);
+ gl_Position = mvp*vec4(vertexPosition, 1.0);
} \ No newline at end of file
diff --git a/examples/others/resources/shaders/glsl330/standard.vs b/examples/others/resources/shaders/glsl330/standard.vs
index fc0a5ff4..7fbdbf5e 100644
--- a/examples/others/resources/shaders/glsl330/standard.vs
+++ b/examples/others/resources/shaders/glsl330/standard.vs
@@ -10,7 +10,7 @@ out vec2 fragTexCoord;
out vec4 fragColor;
out vec3 fragNormal;
-uniform mat4 mvpMatrix;
+uniform mat4 mvp;
void main()
{
@@ -19,5 +19,5 @@ void main()
fragColor = vertexColor;
fragNormal = vertexNormal;
- gl_Position = mvpMatrix*vec4(vertexPosition, 1.0);
+ gl_Position = mvp*vec4(vertexPosition, 1.0);
} \ No newline at end of file