mirror of
https://github.com/raysan5/raylib.git
synced 2025-11-17 15:51:19 +00:00
EXAMPLES: Format tweaks
This commit is contained in:
@@ -30,18 +30,18 @@
|
||||
|
||||
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_DESKTOP_SDL)
|
||||
#if defined(GRAPHICS_API_OPENGL_ES2)
|
||||
#include "glad_gles2.h" // Required for: OpenGL functionality
|
||||
#include "glad_gles2.h" // Required for: OpenGL functionality
|
||||
#define glGenVertexArrays glGenVertexArraysOES
|
||||
#define glBindVertexArray glBindVertexArrayOES
|
||||
#define glDeleteVertexArrays glDeleteVertexArraysOES
|
||||
#define GLSL_VERSION 100
|
||||
#else
|
||||
#if defined(__APPLE__)
|
||||
#define GL_SILENCE_DEPRECATION // Silence Opengl API deprecation warnings
|
||||
#define GL_SILENCE_DEPRECATION // Silence Opengl API deprecation warnings
|
||||
#include <OpenGL/gl3.h> // OpenGL 3 library for OSX
|
||||
#include <OpenGL/gl3ext.h> // OpenGL 3 extensions library for OSX
|
||||
#else
|
||||
#include "glad.h" // Required for: OpenGL functionality
|
||||
#include "glad.h" // Required for: OpenGL functionality
|
||||
#endif
|
||||
#define GLSL_VERSION 330
|
||||
#endif
|
||||
@@ -71,7 +71,7 @@ int main(void)
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib - point particles");
|
||||
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - point particles");
|
||||
|
||||
Shader shader = LoadShader(TextFormat("resources/shaders/glsl%i/point_particle.vs", GLSL_VERSION),
|
||||
TextFormat("resources/shaders/glsl%i/point_particle.fs", GLSL_VERSION));
|
||||
@@ -86,13 +86,13 @@ int main(void)
|
||||
{
|
||||
particles[i].x = (float)GetRandomValue(20, screenWidth - 20);
|
||||
particles[i].y = (float)GetRandomValue(50, screenHeight - 20);
|
||||
|
||||
// Give each particle a slightly different period. But don't spread it to much.
|
||||
|
||||
// Give each particle a slightly different period. But don't spread it to much.
|
||||
// This way the particles line up every so often and you get a glimps of what is going on.
|
||||
particles[i].period = (float)GetRandomValue(10, 30)/10.0f;
|
||||
}
|
||||
|
||||
// Create a plain OpenGL vertex buffer with the data and an vertex array object
|
||||
// Create a plain OpenGL vertex buffer with the data and an vertex array object
|
||||
// that feeds the data from the buffer into the vertexPosition shader attribute.
|
||||
GLuint vao = 0;
|
||||
GLuint vbo = 0;
|
||||
@@ -125,13 +125,13 @@ int main(void)
|
||||
|
||||
DrawRectangle(10, 10, 210, 30, MAROON);
|
||||
DrawText(TextFormat("%zu particles in one vertex buffer", MAX_PARTICLES), 20, 20, 10, RAYWHITE);
|
||||
|
||||
|
||||
rlDrawRenderBatchActive(); // Draw iternal buffers data (previous draw calls)
|
||||
|
||||
// Switch to plain OpenGL
|
||||
//------------------------------------------------------------------------------
|
||||
glUseProgram(shader.id);
|
||||
|
||||
|
||||
glUniform1f(currentTimeLoc, GetTime());
|
||||
|
||||
Vector4 color = ColorNormalize((Color){ 255, 0, 0, 128 });
|
||||
@@ -139,18 +139,18 @@ int main(void)
|
||||
|
||||
// Get the current modelview and projection matrix so the particle system is displayed and transformed
|
||||
Matrix modelViewProjection = MatrixMultiply(rlGetMatrixModelview(), rlGetMatrixProjection());
|
||||
|
||||
|
||||
glUniformMatrix4fv(shader.locs[SHADER_LOC_MATRIX_MVP], 1, false, MatrixToFloat(modelViewProjection));
|
||||
|
||||
glBindVertexArray(vao);
|
||||
glDrawArrays(GL_POINTS, 0, MAX_PARTICLES);
|
||||
glBindVertexArray(0);
|
||||
|
||||
|
||||
glUseProgram(0);
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
DrawFPS(screenWidth - 100, 10);
|
||||
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user