mirror of
https://github.com/raysan5/raylib.git
synced 2025-12-25 10:22:33 -05:00
WARNING: **NEW** raylib code CONVENTION: Comments do not end with '.'
This commit is contained in:
@ -108,8 +108,6 @@ int main(void)
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Sample mouse input.
|
||||
mousePosition = GetMousePosition();
|
||||
|
||||
if (IsMouseButtonDown(MOUSE_BUTTON_LEFT))
|
||||
@ -125,7 +123,7 @@ int main(void)
|
||||
// Compute two cycles to allow the buffer padding, simplifying any modulation, resampling, etc.
|
||||
if (frequency != oldFrequency)
|
||||
{
|
||||
// Compute wavelength. Limit size in both directions.
|
||||
// Compute wavelength. Limit size in both directions
|
||||
//int oldWavelength = waveLength;
|
||||
waveLength = (int)(22050/frequency);
|
||||
if (waveLength > MAX_SAMPLES/2) waveLength = MAX_SAMPLES/2;
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
* 4. PollInputEvents()
|
||||
*
|
||||
* To avoid steps 2, 3 and 4, flag SUPPORT_CUSTOM_FRAME_CONTROL can be enabled in
|
||||
* config.h (it requires recompiling raylib). This way those steps are up to the user.
|
||||
* config.h (it requires recompiling raylib). This way those steps are up to the user
|
||||
*
|
||||
* Note that enabling this flag invalidates some functions:
|
||||
* - GetFrameTime()
|
||||
|
||||
@ -43,7 +43,8 @@ int main(void)
|
||||
Camera2D screenSpaceCamera = { 0 }; // Smoothing camera
|
||||
screenSpaceCamera.zoom = 1.0f;
|
||||
|
||||
RenderTexture2D target = LoadRenderTexture(virtualScreenWidth, virtualScreenHeight); // This is where we'll draw all our objects.
|
||||
// Load render texture to draw all our objects
|
||||
RenderTexture2D target = LoadRenderTexture(virtualScreenWidth, virtualScreenHeight);
|
||||
|
||||
Rectangle rec01 = { 70.0f, 35.0f, 20.0f, 20.0f };
|
||||
Rectangle rec02 = { 90.0f, 55.0f, 30.0f, 10.0f };
|
||||
|
||||
@ -6,30 +6,30 @@
|
||||
|
||||
1. File naming: <module>_<description> - Lower case filename, words separated by underscore,
|
||||
no more than 3-4 words in total to describe the example. <module> referes to the primary
|
||||
raylib module the example is more related with (code, shapes, textures, models, shaders, raudio).
|
||||
raylib module the example is more related with (code, shapes, textures, models, shaders, raudio)
|
||||
i.e: core_input_multitouch, shapes_lines_bezier, shaders_palette_switch
|
||||
|
||||
2. Follow below template structure, example info should list the module, the short description
|
||||
and the author of the example, twitter or github info could be also provided for the author.
|
||||
Short description should also be used on the title of the window.
|
||||
and the author of the example, twitter or github info could be also provided for the author
|
||||
Short description should also be used on the title of the window
|
||||
|
||||
3. Code should be organized by sections:[Initialization]- [Update] - [Draw] - [De-Initialization]
|
||||
Place your code between the dotted lines for every section, please don't mix update logic with drawing
|
||||
and remember to unload all loaded resources.
|
||||
and remember to unload all loaded resources
|
||||
|
||||
4. Code should follow raylib conventions: https://github.com/raysan5/raylib/wiki/raylib-coding-conventions
|
||||
Try to be very organized, using line-breaks appropiately.
|
||||
Try to be very organized, using line-breaks appropiately
|
||||
|
||||
5. Add comments to the specific parts of code the example is focus on.
|
||||
Don't abuse with comments, try to be clear and impersonal on the comments.
|
||||
5. Add comments to the specific parts of code the example is focus on
|
||||
Don't abuse with comments, try to be clear and impersonal on the comments
|
||||
|
||||
6. Try to keep the example simple, under 300 code lines if possible. Try to avoid external dependencies.
|
||||
Try to avoid defining functions outside the main(). Example should be as self-contained as possible.
|
||||
6. Try to keep the example simple, under 300 code lines if possible. Try to avoid external dependencies
|
||||
Try to avoid defining functions outside the main(). Example should be as self-contained as possible
|
||||
|
||||
7. About external resources, they should be placed in a [resources] folder and those resources
|
||||
should be open and free for use and distribution. Avoid propietary content.
|
||||
should be open and free for use and distribution. Avoid propietary content
|
||||
|
||||
8. Try to keep the example simple but with a creative touch.
|
||||
8. Try to keep the example simple but with a creative touch
|
||||
Simple but beautiful examples are more appealing to users!
|
||||
|
||||
9. In case of additional information is required, just come to raylib Discord channel: example-contributions
|
||||
@ -37,7 +37,7 @@
|
||||
10. Have fun!
|
||||
|
||||
The following files should be updated when adding a new example, it's planned to create some
|
||||
script to automatize this process but not available yet.
|
||||
script to automatize this process but not available yet
|
||||
|
||||
- raylib/examples/<category>/<category>_example_name.c
|
||||
- raylib/examples/<category>/<category>_example_name.png
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
*
|
||||
* NOTE: To export a model from blender, make sure it is not posed, the vertices need to be
|
||||
* in the same position as they would be in edit mode and the scale of your models is
|
||||
* set to 0. Scaling can be done from the export menu.
|
||||
* set to 0. Scaling can be done from the export menu
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
|
||||
@ -40,7 +40,7 @@ int main(void)
|
||||
Vector3 billPositionStatic = { 0.0f, 2.0f, 0.0f }; // Position of static billboard
|
||||
Vector3 billPositionRotating = { 1.0f, 2.0f, 1.0f }; // Position of rotating billboard
|
||||
|
||||
// Entire billboard texture, source is used to take a segment from a larger texture.
|
||||
// Entire billboard texture, source is used to take a segment from a larger texture
|
||||
Rectangle source = { 0.0f, 0.0f, (float)bill.width, (float)bill.height };
|
||||
|
||||
// NOTE: Billboard locked on axis-Y
|
||||
@ -54,7 +54,7 @@ int main(void)
|
||||
Vector2 origin = Vector2Scale(size, 0.5f);
|
||||
|
||||
// Distance is needed for the correct billboard draw order
|
||||
// Larger distance (further away from the camera) should be drawn prior to smaller distance.
|
||||
// Larger distance (further away from the camera) should be drawn prior to smaller distance
|
||||
float distanceStatic;
|
||||
float distanceRotating;
|
||||
float rotation = 0.0f;
|
||||
|
||||
@ -7,11 +7,11 @@
|
||||
* NOTE: raylib supports multiple models file formats:
|
||||
*
|
||||
* - OBJ > Text file format. Must include vertex position-texcoords-normals information,
|
||||
* if files references some .mtl materials file, it will be loaded (or try to).
|
||||
* if files references some .mtl materials file, it will be loaded (or try to)
|
||||
* - GLTF > Text/binary file format. Includes lot of information and it could
|
||||
* also reference external files, raylib will try loading mesh and materials data.
|
||||
* also reference external files, raylib will try loading mesh and materials data
|
||||
* - IQM > Binary file format. Includes mesh vertex data but also animation data,
|
||||
* raylib can load .iqm animations.
|
||||
* raylib can load .iqm animations
|
||||
* - VOX > Binary file format. MagikaVoxel mesh format:
|
||||
* https://github.com/ephtracy/voxel-model/blob/master/MagicaVoxel-file-format-vox.txt
|
||||
* - M3D > Binary file format. Model 3D format:
|
||||
|
||||
@ -119,7 +119,7 @@ int main(void)
|
||||
// without a -1, we would always draw a cube at the origin
|
||||
for (int i = 0; i < model.boneCount - 1; i++)
|
||||
{
|
||||
// By default the model is loaded in bind-pose by LoadModel().
|
||||
// By default the model is loaded in bind-pose by LoadModel()
|
||||
// But if UpdateModelAnimation() has been called at least once
|
||||
// then the model is already in animation pose, so we need the animated skeleton
|
||||
if (!animPlaying || !animsCount)
|
||||
|
||||
@ -221,10 +221,12 @@ int main(void)
|
||||
}
|
||||
|
||||
|
||||
// NoEase function, used when "no easing" is selected for any axis. It just ignores all parameters besides b.
|
||||
// NoEase function, used when "no easing" is selected for any axis
|
||||
// It just ignores all parameters besides b
|
||||
static float NoEase(float t, float b, float c, float d)
|
||||
{
|
||||
float burn = t + b + c + d; // Hack to avoid compiler warning (about unused variables)
|
||||
// Hack to avoid compiler warning (about unused variables)
|
||||
float burn = t + b + c + d;
|
||||
d += burn;
|
||||
|
||||
return b;
|
||||
|
||||
@ -16,13 +16,13 @@
|
||||
********************************************************************************************
|
||||
*
|
||||
* Mixes raylib and plain OpenGL code to draw a GL_POINTS based particle system. The
|
||||
* primary point is to demonstrate raylib and OpenGL interop.
|
||||
* primary point is to demonstrate raylib and OpenGL interop
|
||||
*
|
||||
* rlgl batched draw operations internally so we have to flush the current batch before
|
||||
* doing our own OpenGL work (rlDrawRenderBatchActive()).
|
||||
* doing our own OpenGL work (rlDrawRenderBatchActive())
|
||||
*
|
||||
* The example also demonstrates how to get the current model view projection matrix of
|
||||
* raylib. That way raylib cameras and so on work as expected.
|
||||
* raylib. That way raylib cameras and so on work as expected
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
@ -87,13 +87,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.
|
||||
// This way the particles line up every so often and you get a glimps of what is going on.
|
||||
// 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
|
||||
// that feeds the data from the buffer into the vertexPosition shader attribute.
|
||||
// that feeds the data from the buffer into the vertexPosition shader attribute
|
||||
GLuint vao = 0;
|
||||
GLuint vbo = 0;
|
||||
glGenVertexArrays(1, &vao);
|
||||
|
||||
@ -23,11 +23,11 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
// IMPORTANT: This must match gol*.glsl GOL_WIDTH constant.
|
||||
// This must be a multiple of 16 (check golLogic compute dispatch).
|
||||
// IMPORTANT: This must match gol*.glsl GOL_WIDTH constant
|
||||
// This must be a multiple of 16 (check golLogic compute dispatch)
|
||||
#define GOL_WIDTH 768
|
||||
|
||||
// Maximum amount of queued draw commands (squares draw from mouse down events).
|
||||
// Maximum amount of queued draw commands (squares draw from mouse down events)
|
||||
#define MAX_BUFFERED_TRANSFERTS 48
|
||||
|
||||
// Game Of Life Update Command
|
||||
@ -160,7 +160,7 @@ int main(void)
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Unload shader buffers objects.
|
||||
// Unload shader buffers objects
|
||||
rlUnloadShaderBuffer(ssboA);
|
||||
rlUnloadShaderBuffer(ssboB);
|
||||
rlUnloadShaderBuffer(ssboTransfert);
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
*
|
||||
* Example originally created with raylib 1.6, last time updated with raylib 4.0
|
||||
*
|
||||
* WARNING: This example is intended only for PLATFORM_DESKTOP and OpenGL 3.3 Core profile.
|
||||
* WARNING: This example is intended only for PLATFORM_DESKTOP and OpenGL 3.3 Core profile
|
||||
* It could work on other platforms if redesigned for those platforms (out-of-scope)
|
||||
*
|
||||
* DEPENDENCIES:
|
||||
@ -48,7 +48,7 @@
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||
* as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
* 3. This notice may not be removed or altered from any source distribution
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
* Example complexity rating: [★★★★] 4/4
|
||||
*
|
||||
* NOTE: This example requires raylib OpenGL 3.3 or ES2 versions for shaders support,
|
||||
* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version.
|
||||
* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version
|
||||
*
|
||||
* NOTE: Shaders used in this example are #version 330 (OpenGL 3.3).
|
||||
* NOTE: Shaders used in this example are #version 330 (OpenGL 3.3)
|
||||
*
|
||||
* Example originally created with raylib 3.0, last time updated with raylib 4.2
|
||||
*
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
* Example complexity rating: [★★☆☆] 2/4
|
||||
*
|
||||
* NOTE: This example requires raylib OpenGL 3.3 or ES2 versions for shaders support,
|
||||
* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version.
|
||||
* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version
|
||||
*
|
||||
* NOTE: Shaders used in this example are #version 330 (OpenGL 3.3), to test this example
|
||||
* on OpenGL ES 2.0 platforms (Android, Raspberry Pi, HTML5), use #version 100 shaders
|
||||
|
||||
@ -99,44 +99,44 @@ int main(void)
|
||||
|
||||
// NOTE: Vertex positions are stored in a texture for simplicity. A better approach would use a depth texture
|
||||
// (instead of a detph renderbuffer) to reconstruct world positions in the final render shader via clip-space position,
|
||||
// depth, and the inverse view/projection matrices.
|
||||
// depth, and the inverse view/projection matrices
|
||||
|
||||
// 16-bit precision ensures OpenGL ES 3 compatibility, though it may lack precision for real scenarios.
|
||||
// 16-bit precision ensures OpenGL ES 3 compatibility, though it may lack precision for real scenarios
|
||||
// But as mentioned above, the positions could be reconstructed instead of stored. If not targeting OpenGL ES
|
||||
// and you wish to maintain this approach, consider using `RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32`.
|
||||
// and you wish to maintain this approach, consider using `RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32`
|
||||
gBuffer.positionTexture = rlLoadTexture(NULL, screenWidth, screenHeight, RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16, 1);
|
||||
|
||||
// Similarly, 16-bit precision is used for normals ensures OpenGL ES 3 compatibility.
|
||||
// This is generally sufficient, but a 16-bit fixed-point format offer a better uniform precision in all orientations.
|
||||
// Similarly, 16-bit precision is used for normals ensures OpenGL ES 3 compatibility
|
||||
// This is generally sufficient, but a 16-bit fixed-point format offer a better uniform precision in all orientations
|
||||
gBuffer.normalTexture = rlLoadTexture(NULL, screenWidth, screenHeight, RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16, 1);
|
||||
|
||||
// Albedo (diffuse color) and specular strength can be combined into one texture.
|
||||
// The color in RGB, and the specular strength in the alpha channel.
|
||||
// Albedo (diffuse color) and specular strength can be combined into one texture
|
||||
// The color in RGB, and the specular strength in the alpha channel
|
||||
gBuffer.albedoSpecTexture = rlLoadTexture(NULL, screenWidth, screenHeight, RL_PIXELFORMAT_UNCOMPRESSED_R8G8B8A8, 1);
|
||||
|
||||
// Activate the draw buffers for our framebuffer
|
||||
rlActiveDrawBuffers(3);
|
||||
|
||||
// Now we attach our textures to the framebuffer.
|
||||
// Now we attach our textures to the framebuffer
|
||||
rlFramebufferAttach(gBuffer.framebuffer, gBuffer.positionTexture, RL_ATTACHMENT_COLOR_CHANNEL0, RL_ATTACHMENT_TEXTURE2D, 0);
|
||||
rlFramebufferAttach(gBuffer.framebuffer, gBuffer.normalTexture, RL_ATTACHMENT_COLOR_CHANNEL1, RL_ATTACHMENT_TEXTURE2D, 0);
|
||||
rlFramebufferAttach(gBuffer.framebuffer, gBuffer.albedoSpecTexture, RL_ATTACHMENT_COLOR_CHANNEL2, RL_ATTACHMENT_TEXTURE2D, 0);
|
||||
|
||||
// Finally we attach the depth buffer.
|
||||
// Finally we attach the depth buffer
|
||||
gBuffer.depthRenderbuffer = rlLoadTextureDepth(screenWidth, screenHeight, true);
|
||||
rlFramebufferAttach(gBuffer.framebuffer, gBuffer.depthRenderbuffer, RL_ATTACHMENT_DEPTH, RL_ATTACHMENT_RENDERBUFFER, 0);
|
||||
|
||||
// Make sure our framebuffer is complete.
|
||||
// Make sure our framebuffer is complete
|
||||
// NOTE: rlFramebufferComplete() automatically unbinds the framebuffer, so we don't have
|
||||
// to rlDisableFramebuffer() here.
|
||||
// to rlDisableFramebuffer() here
|
||||
if (!rlFramebufferComplete(gBuffer.framebuffer))
|
||||
{
|
||||
TraceLog(LOG_WARNING, "Framebuffer is not complete");
|
||||
}
|
||||
|
||||
// Now we initialize the sampler2D uniform's in the deferred shader.
|
||||
// Now we initialize the sampler2D uniform's in the deferred shader
|
||||
// We do this by setting the uniform's values to the texture units that
|
||||
// we later bind our g-buffer textures to.
|
||||
// we later bind our g-buffer textures to
|
||||
rlEnableShader(deferredShader.id);
|
||||
int texUnitPosition = 0;
|
||||
int texUnitNormal = 1;
|
||||
@ -219,7 +219,7 @@ int main(void)
|
||||
rlDisableColorBlend();
|
||||
BeginMode3D(camera);
|
||||
// NOTE: We have to use rlEnableShader here. `BeginShaderMode` or thus `rlSetShader`
|
||||
// will not work, as they won't immediately load the shader program.
|
||||
// will not work, as they won't immediately load the shader program
|
||||
rlEnableShader(gbufferShader.id);
|
||||
// When drawing a model here, make sure that the material's shaders
|
||||
// are set to the gbuffer shader!
|
||||
@ -236,7 +236,7 @@ int main(void)
|
||||
EndMode3D();
|
||||
rlEnableColorBlend();
|
||||
|
||||
// Go back to the default framebuffer (0) and draw our deferred shading.
|
||||
// Go back to the default framebuffer (0) and draw our deferred shading
|
||||
rlDisableFramebuffer();
|
||||
rlClearScreenBuffers(); // Clear color & depth buffer
|
||||
|
||||
@ -264,10 +264,10 @@ int main(void)
|
||||
rlEnableColorBlend();
|
||||
EndMode3D();
|
||||
|
||||
// As a last step, we now copy over the depth buffer from our g-buffer to the default framebuffer.
|
||||
// As a last step, we now copy over the depth buffer from our g-buffer to the default framebuffer
|
||||
rlBindFramebuffer(RL_READ_FRAMEBUFFER, gBuffer.framebuffer);
|
||||
rlBindFramebuffer(RL_DRAW_FRAMEBUFFER, 0);
|
||||
rlBlitFramebuffer(0, 0, screenWidth, screenHeight, 0, 0, screenWidth, screenHeight, 0x00000100); // GL_DEPTH_BUFFER_BIT
|
||||
rlBlitFramebuffer(0, 0, screenWidth, screenHeight, 0, 0, screenWidth, screenHeight, 0x00000100); // GL_DEPTH_BUFFER_BIT
|
||||
rlDisableFramebuffer();
|
||||
|
||||
// Since our shader is now done and disabled, we can draw spheres
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
*
|
||||
* Example complexity rating: [★★★☆] 3/4
|
||||
*
|
||||
* NOTE: Sieve of Eratosthenes, the earliest known (ancient Greek) prime number sieve.
|
||||
* NOTE: Sieve of Eratosthenes, the earliest known (ancient Greek) prime number sieve
|
||||
*
|
||||
* "Sift the twos and sift the threes,
|
||||
* The Sieve of Eratosthenes.
|
||||
@ -12,9 +12,9 @@
|
||||
* the numbers that are left are prime."
|
||||
*
|
||||
* NOTE: This example requires raylib OpenGL 3.3 or ES2 versions for shaders support,
|
||||
* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version.
|
||||
* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version
|
||||
*
|
||||
* NOTE: Shaders used in this example are #version 330 (OpenGL 3.3).
|
||||
* NOTE: Shaders used in this example are #version 330 (OpenGL 3.3)
|
||||
*
|
||||
* Example originally created with raylib 2.5, last time updated with raylib 4.0
|
||||
*
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
* Example complexity rating: [★★★☆] 3/4
|
||||
*
|
||||
* NOTE: This example requires raylib OpenGL 3.3 or ES2 versions for shaders support,
|
||||
* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version.
|
||||
* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version
|
||||
*
|
||||
* NOTE: Shaders used in this example are #version 330 (OpenGL 3.3).
|
||||
* NOTE: Shaders used in this example are #version 330 (OpenGL 3.3)
|
||||
*
|
||||
* Example originally created with raylib 2.5, last time updated with raylib 3.7
|
||||
*
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
* Example complexity rating: [★★★☆] 3/4
|
||||
*
|
||||
* NOTE: This example requires raylib OpenGL 3.3 for shaders support and only #version 330
|
||||
* is currently supported. OpenGL ES 2.0 platforms are not supported at the moment.
|
||||
* is currently supported. OpenGL ES 2.0 platforms are not supported at the moment
|
||||
*
|
||||
* Example originally created with raylib 3.0, last time updated with raylib 3.5
|
||||
*
|
||||
|
||||
@ -61,15 +61,15 @@ int main(void)
|
||||
// You are required to write depth for all shaders if one shader does it
|
||||
Shader shdrRaster = LoadShader(0, TextFormat("resources/shaders/glsl%i/hybrid_raster.fs", GLSL_VERSION));
|
||||
|
||||
// Declare Struct used to store camera locs.
|
||||
// Declare Struct used to store camera locs
|
||||
RayLocs marchLocs = {0};
|
||||
|
||||
// Fill the struct with shader locs.
|
||||
// Fill the struct with shader locs
|
||||
marchLocs.camPos = GetShaderLocation(shdrRaymarch, "camPos");
|
||||
marchLocs.camDir = GetShaderLocation(shdrRaymarch, "camDir");
|
||||
marchLocs.screenCenter = GetShaderLocation(shdrRaymarch, "screenCenter");
|
||||
|
||||
// Transfer screenCenter position to shader. Which is used to calculate ray direction.
|
||||
// Transfer screenCenter position to shader. Which is used to calculate ray direction
|
||||
Vector2 screenCenter = {.x = screenWidth/2.0f, .y = screenHeight/2.0f};
|
||||
SetShaderValue(shdrRaymarch, marchLocs.screenCenter , &screenCenter , SHADER_UNIFORM_VEC2);
|
||||
|
||||
@ -85,7 +85,7 @@ int main(void)
|
||||
.projection = CAMERA_PERSPECTIVE // Camera projection type
|
||||
};
|
||||
|
||||
// Camera FOV is pre-calculated in the camera Distance.
|
||||
// Camera FOV is pre-calculated in the camera distance
|
||||
float camDist = 1.0f/(tanf(camera.fovy*0.5f*DEG2RAD));
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
@ -98,10 +98,10 @@ int main(void)
|
||||
//----------------------------------------------------------------------------------
|
||||
UpdateCamera(&camera, CAMERA_ORBITAL);
|
||||
|
||||
// Update Camera Postion in the ray march shader.
|
||||
// Update Camera Postion in the ray march shader
|
||||
SetShaderValue(shdrRaymarch, marchLocs.camPos, &(camera.position), RL_SHADER_UNIFORM_VEC3);
|
||||
|
||||
// Update Camera Looking Vector. Vector length determines FOV.
|
||||
// Update Camera Looking Vector. Vector length determines FOV
|
||||
Vector3 camDir = Vector3Scale( Vector3Normalize( Vector3Subtract(camera.target, camera.position)) , camDist);
|
||||
SetShaderValue(shdrRaymarch, marchLocs.camDir, &(camDir), RL_SHADER_UNIFORM_VEC3);
|
||||
//----------------------------------------------------------------------------------
|
||||
@ -113,7 +113,7 @@ int main(void)
|
||||
ClearBackground(WHITE);
|
||||
|
||||
// Raymarch Scene
|
||||
rlEnableDepthTest(); //Manually enable Depth Test to handle multiple rendering methods.
|
||||
rlEnableDepthTest(); // Manually enable Depth Test to handle multiple rendering methods
|
||||
BeginShaderMode(shdrRaymarch);
|
||||
DrawRectangleRec((Rectangle){0,0, (float)screenWidth, (float)screenHeight},WHITE);
|
||||
EndShaderMode();
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
* Example complexity rating: [★★★☆] 3/4
|
||||
*
|
||||
* NOTE: This example requires raylib OpenGL 3.3 or ES2 versions for shaders support,
|
||||
* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version.
|
||||
* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version
|
||||
*
|
||||
* NOTE: Shaders used in this example are #version 330 (OpenGL 3.3).
|
||||
* NOTE: Shaders used in this example are #version 330 (OpenGL 3.3)
|
||||
*
|
||||
* Example originally created with raylib 2.5, last time updated with raylib 4.0
|
||||
*
|
||||
@ -109,7 +109,7 @@ int main(void)
|
||||
SetShaderValue(shader, cLoc, c, SHADER_UNIFORM_VEC2);
|
||||
}
|
||||
|
||||
// If "R" is pressed, reset zoom and offset.
|
||||
// If "R" is pressed, reset zoom and offset
|
||||
if (IsKeyPressed(KEY_R))
|
||||
{
|
||||
zoom = startingZoom;
|
||||
@ -125,17 +125,16 @@ int main(void)
|
||||
if (IsKeyPressed(KEY_RIGHT)) incrementSpeed++;
|
||||
else if (IsKeyPressed(KEY_LEFT)) incrementSpeed--;
|
||||
|
||||
// If either left or right button is pressed, zoom in/out.
|
||||
// If either left or right button is pressed, zoom in/out
|
||||
if (IsMouseButtonDown(MOUSE_BUTTON_LEFT) || IsMouseButtonDown(MOUSE_BUTTON_RIGHT))
|
||||
{
|
||||
// Change zoom. If Mouse left -> zoom in. Mouse right -> zoom out.
|
||||
// Change zoom. If Mouse left -> zoom in. Mouse right -> zoom out
|
||||
zoom *= IsMouseButtonDown(MOUSE_BUTTON_LEFT)? zoomSpeed : 1.0f/zoomSpeed;
|
||||
|
||||
const Vector2 mousePos = GetMousePosition();
|
||||
Vector2 offsetVelocity;
|
||||
// Find the velocity at which to change the camera. Take the distance of the mouse
|
||||
// from the center of the screen as the direction, and adjust magnitude based on
|
||||
// the current zoom.
|
||||
// from the center of the screen as the direction, and adjust magnitude based on the current zoom
|
||||
offsetVelocity.x = (mousePos.x/(float)screenWidth - 0.5f)*offsetSpeedMul/zoom;
|
||||
offsetVelocity.y = (mousePos.y/(float)screenHeight - 0.5f)*offsetSpeedMul/zoom;
|
||||
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
* Example complexity rating: [★★★☆] 3/4
|
||||
*
|
||||
* NOTE: This example requires raylib OpenGL 3.3 or ES2 versions for shaders support,
|
||||
* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version.
|
||||
* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version
|
||||
*
|
||||
* NOTE: Shaders used in this example are #version 330 (OpenGL 3.3).
|
||||
* NOTE: Shaders used in this example are #version 330 (OpenGL 3.3)
|
||||
*
|
||||
* Example originally created with raylib 4.5, last time updated with raylib 4.5
|
||||
*
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
* Example complexity rating: [★★☆☆] 2/4
|
||||
*
|
||||
* NOTE: This example requires raylib OpenGL 3.3 or ES2 versions for shaders support,
|
||||
* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version.
|
||||
* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version
|
||||
*
|
||||
* NOTE: Shaders used in this example are #version 330 (OpenGL 3.3), to test this example
|
||||
* on OpenGL ES 2.0 platforms (Android, Raspberry Pi, HTML5), use #version 100 shaders
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
* Example complexity rating: [★★☆☆] 2/4
|
||||
*
|
||||
* NOTE: This example requires raylib OpenGL 3.3 or ES2 versions for shaders support,
|
||||
* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version.
|
||||
* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version
|
||||
*
|
||||
* NOTE: Shaders used in this example are #version 330 (OpenGL 3.3), to test this example
|
||||
* on OpenGL ES 2.0 platforms (Android, Raspberry Pi, HTML5), use #version 100 shaders
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
* Example complexity rating: [★★★★] 4/4
|
||||
*
|
||||
* NOTE: This example requires raylib OpenGL 3.3 or ES2 versions for shaders support,
|
||||
* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version.
|
||||
* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version
|
||||
*
|
||||
* Example originally created with raylib 5.6, last time updated with raylib 5.6
|
||||
*
|
||||
@ -79,7 +79,7 @@ int main(void)
|
||||
SetTextureFilter(plane.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture, TEXTURE_FILTER_TRILINEAR);
|
||||
SetTextureFilter(plane.materials[0].maps[MATERIAL_MAP_NORMAL].texture, TEXTURE_FILTER_TRILINEAR);
|
||||
|
||||
// Specular exponent AKA shininess of the material.
|
||||
// Specular exponent AKA shininess of the material
|
||||
float specularExponent = 8.0f;
|
||||
int specularExponentLoc = GetShaderLocation(shader, "specularExponent");
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
* Example complexity rating: [★★★☆] 3/4
|
||||
*
|
||||
* NOTE: This example requires raylib OpenGL 3.3 or ES2 versions for shaders support,
|
||||
* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version.
|
||||
* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version
|
||||
*
|
||||
* NOTE: Shaders used in this example are #version 330 (OpenGL 3.3), to test this example
|
||||
* on OpenGL ES 2.0 platforms (Android, Raspberry Pi, HTML5), use #version 100 shaders
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
* Example complexity rating: [★★★☆] 3/4
|
||||
*
|
||||
* NOTE: This example requires raylib OpenGL 3.3 or ES2 versions for shaders support,
|
||||
* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version.
|
||||
* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version
|
||||
*
|
||||
* NOTE: Shaders used in this example are #version 330 (OpenGL 3.3), to test this example
|
||||
* on OpenGL ES 2.0 platforms (Android, Raspberry Pi, HTML5), use #version 100 shaders
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
* Example complexity rating: [★★★★] 4/4
|
||||
*
|
||||
* NOTE: This example requires raylib OpenGL 3.3 for shaders support and only #version 330
|
||||
* is currently supported. OpenGL ES 2.0 platforms are not supported at the moment.
|
||||
* is currently supported. OpenGL ES 2.0 platforms are not supported at the moment
|
||||
*
|
||||
* Example originally created with raylib 2.0, last time updated with raylib 4.2
|
||||
*
|
||||
|
||||
@ -44,7 +44,7 @@ int main(void)
|
||||
SetConfigFlags(FLAG_MSAA_4X_HINT);
|
||||
// Shadows are a HUGE topic, and this example shows an extremely simple implementation of the shadowmapping algorithm,
|
||||
// which is the industry standard for shadows. This algorithm can be extended in a ridiculous number of ways to improve
|
||||
// realism and also adapt it for different scenes. This is pretty much the simplest possible implementation.
|
||||
// realism and also adapt it for different scenes. This is pretty much the simplest possible implementation
|
||||
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - shadowmap");
|
||||
|
||||
Camera3D cam = (Camera3D){ 0 };
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
* Example complexity rating: [★★☆☆] 2/4
|
||||
*
|
||||
* NOTE: This example requires raylib OpenGL 3.3 or ES2 versions for shaders support,
|
||||
* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version.
|
||||
* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version
|
||||
*
|
||||
* NOTE: Shaders used in this example are #version 330 (OpenGL 3.3), to test this example
|
||||
* on OpenGL ES 2.0 platforms (Android, Raspberry Pi, HTML5), use #version 100 shaders
|
||||
|
||||
@ -20,13 +20,13 @@
|
||||
*
|
||||
* The right hand side of the screen there is just enough light to see whats
|
||||
* going on without the spot light, great for a stealth type game where you
|
||||
* have to avoid the spotlights.
|
||||
* have to avoid the spotlights
|
||||
*
|
||||
* The left hand side of the screen is in pitch dark except for where the spotlights are.
|
||||
* The left hand side of the screen is in pitch dark except for where the spotlights are
|
||||
*
|
||||
* Although this example doesn't scale like the letterbox example, you could integrate
|
||||
* the two techniques, but by scaling the actual colour of the render texture rather
|
||||
* than using alpha as a mask.
|
||||
* than using alpha as a mask
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
@ -115,7 +115,7 @@ int main(void)
|
||||
}
|
||||
|
||||
// Tell the shader how wide the screen is so we can have
|
||||
// a pitch black half and a dimly lit half.
|
||||
// a pitch black half and a dimly lit half
|
||||
unsigned int wLoc = GetShaderLocation(shdrSpot, "screenWidth");
|
||||
float sw = (float)GetScreenWidth();
|
||||
SetShaderValue(shdrSpot, wLoc, &sw, SHADER_UNIFORM_FLOAT);
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
* Example complexity rating: [★★★☆] 3/4
|
||||
*
|
||||
* NOTE: This example requires raylib OpenGL 3.3 or ES2 versions for shaders support,
|
||||
* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version.
|
||||
* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version
|
||||
*
|
||||
* Example originally created with raylib 4.0, last time updated with raylib 4.0
|
||||
*
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
*
|
||||
* Example complexity rating: [★★☆☆] 2/4
|
||||
*
|
||||
* Example demonstrates how to tile a texture on a 3D model using raylib.
|
||||
* Example demonstrates how to tile a texture on a 3D model using raylib
|
||||
*
|
||||
* Example originally created with raylib 4.5, last time updated with raylib 4.5
|
||||
*
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
* Example complexity rating: [★★☆☆] 2/4
|
||||
*
|
||||
* NOTE: This example requires raylib OpenGL 3.3 or ES2 versions for shaders support,
|
||||
* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version.
|
||||
* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version
|
||||
*
|
||||
* NOTE: Shaders used in this example are #version 330 (OpenGL 3.3), to test this example
|
||||
* on OpenGL ES 2.0 platforms (Android, Raspberry Pi, HTML5), use #version 100 shaders
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
* Example complexity rating: [★★★☆] 3/4
|
||||
*
|
||||
* NOTE: This example requires 'easings.h' library, provided on raylib/src. Just copy
|
||||
* the library to same directory as example or make sure it's available on include path.
|
||||
* the library to same directory as example or make sure it's available on include path
|
||||
*
|
||||
* Example originally created with raylib 2.0, last time updated with raylib 2.5
|
||||
*
|
||||
|
||||
@ -265,10 +265,10 @@ static void DrawRectangleRoundedGradientH(Rectangle rec, float roundnessLeft, fl
|
||||
rlSetTexture(0);
|
||||
#else
|
||||
|
||||
// Here we use the 'Diagram' to guide ourselves to which point receives what color.
|
||||
// Here we use the 'Diagram' to guide ourselves to which point receives what color
|
||||
// By choosing the color correctly associated with a pointe the gradient effect
|
||||
// will naturally come from OpenGL interpolation.
|
||||
// But this time instead of Quad, we think in triangles.
|
||||
// will naturally come from OpenGL interpolation
|
||||
// But this time instead of Quad, we think in triangles
|
||||
|
||||
rlBegin(RL_TRIANGLES);
|
||||
// Draw all of the 4 corners: [1] Upper Left Corner, [3] Upper Right Corner, [5] Lower Right Corner, [7] Lower Left Corner
|
||||
|
||||
@ -39,7 +39,7 @@ int main(void)
|
||||
InitWindow(screenWidth, screenHeight, "raylib [text] example - codepoints loading");
|
||||
|
||||
// Convert each utf-8 character into its
|
||||
// corresponding codepoint in the font file.
|
||||
// corresponding codepoint in the font file
|
||||
int codepointCount = 0;
|
||||
int *codepoints = LoadCodepoints(text, &codepointCount);
|
||||
|
||||
|
||||
@ -6,12 +6,12 @@
|
||||
*
|
||||
* NOTE: Draw a 2D text in 3D space, each letter is drawn in a quad (or 2 quads if backface is set)
|
||||
* where the texture coodinates of each quad map to the texture coordinates of the glyphs
|
||||
* inside the font texture.
|
||||
* inside the font texture
|
||||
*
|
||||
* A more efficient approach, i believe, would be to render the text in a render texture and
|
||||
* map that texture to a plane and render that, or maybe a shader but my method allows more
|
||||
* flexibility...for example to change position of each letter individually to make somethink
|
||||
* like a wavy text effect.
|
||||
* like a wavy text effect
|
||||
*
|
||||
* Special thanks to:
|
||||
* @Nighten for the DrawTextStyle() code https://github.com/NightenDushi/Raylib_DrawTextStyle
|
||||
@ -71,7 +71,7 @@ static void DrawText3D(Font font, const char *text, Vector3 position, float font
|
||||
// Draw a 2D text in 3D space and wave the parts that start with '~~' and end with '~~'
|
||||
// This is a modified version of the original code by @Nighten found here https://github.com/NightenDushi/Raylib_DrawTextStyle
|
||||
static void DrawTextWave3D(Font font, const char *text, Vector3 position, float fontSize, float fontSpacing, float lineSpacing, bool backface, WaveTextConfig *config, float time, Color tint);
|
||||
// Measure a text in 3D ignoring the `~~` chars.
|
||||
// Measure a text in 3D ignoring the `~~` chars
|
||||
static Vector3 MeasureTextWave3D(Font font, const char *text, float fontSize, float fontSpacing, float lineSpacing);
|
||||
// Generates a nice color with a random hue
|
||||
static Color GenerateRandomColor(float s, float v);
|
||||
@ -562,7 +562,7 @@ static void DrawText3D(Font font, const char *text, Vector3 position, float font
|
||||
}
|
||||
}
|
||||
|
||||
// Draw a 2D text in 3D space and wave the parts that start with `~~` and end with `~~`.
|
||||
// Draw a 2D text in 3D space and wave the parts that start with `~~` and end with `~~`
|
||||
// This is a modified version of the original code by @Nighten found here https://github.com/NightenDushi/Raylib_DrawTextStyle
|
||||
static void DrawTextWave3D(Font font, const char *text, Vector3 position, float fontSize, float fontSpacing, float lineSpacing, bool backface, WaveTextConfig* config, float time, Color tint)
|
||||
{
|
||||
@ -625,7 +625,7 @@ static void DrawTextWave3D(Font font, const char *text, Vector3 position, float
|
||||
}
|
||||
}
|
||||
|
||||
// Measure a text in 3D ignoring the `~~` chars.
|
||||
// Measure a text in 3D ignoring the `~~` chars
|
||||
static Vector3 MeasureTextWave3D(Font font, const char* text, float fontSize, float fontSpacing, float lineSpacing)
|
||||
{
|
||||
int len = TextLength(text);
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
* - Rectangles must be defined by a MAGENTA color background
|
||||
*
|
||||
* Following those constraints, a font can be provided just by an image,
|
||||
* this is quite handy to avoid additional font descriptor files (like BMFonts use).
|
||||
* this is quite handy to avoid additional font descriptor files (like BMFonts use)
|
||||
*
|
||||
* Example originally created with raylib 1.0, last time updated with raylib 1.0
|
||||
*
|
||||
|
||||
@ -63,7 +63,7 @@ int main(void)
|
||||
if ((key >= 32) && (key <= 125) && (letterCount < MAX_INPUT_CHARS))
|
||||
{
|
||||
name[letterCount] = (char)key;
|
||||
name[letterCount+1] = '\0'; // Add null terminator at the end of the string.
|
||||
name[letterCount+1] = '\0'; // Add null terminator at the end of the string
|
||||
letterCount++;
|
||||
}
|
||||
|
||||
|
||||
@ -179,9 +179,9 @@ static void DrawTextBoxedSelectable(Font font, const char *text, Rectangle rec,
|
||||
|
||||
// NOTE: When wordWrap is ON we first measure how much of the text we can draw before going outside of the rec container
|
||||
// We store this info in startLine and endLine, then we change states, draw the text between those two variables
|
||||
// and change states again and again recursively until the end of the text (or until we get outside of the container).
|
||||
// and change states again and again recursively until the end of the text (or until we get outside of the container)
|
||||
// When wordWrap is OFF we don't need the measure state so we go to the drawing state immediately
|
||||
// and begin drawing on the next line before we can get outside the container.
|
||||
// and begin drawing on the next line before we can get outside the container
|
||||
if (state == MEASURE_STATE)
|
||||
{
|
||||
// TODO: There are multiple types of spaces in UNICODE, maybe it's a good idea to add support for more
|
||||
|
||||
@ -378,9 +378,9 @@ static void DrawTextBoxedSelectable(Font font, const char *text, Rectangle rec,
|
||||
|
||||
// NOTE: When wordWrap is ON we first measure how much of the text we can draw before going outside of the rec container
|
||||
// We store this info in startLine and endLine, then we change states, draw the text between those two variables
|
||||
// and change states again and again recursively until the end of the text (or until we get outside of the container).
|
||||
// and change states again and again recursively until the end of the text (or until we get outside of the container)
|
||||
// When wordWrap is OFF we don't need the measure state so we go to the drawing state immediately
|
||||
// and begin drawing on the next line before we can get outside the container.
|
||||
// and begin drawing on the next line before we can get outside the container
|
||||
if (state == MEASURE_STATE)
|
||||
{
|
||||
// TODO: There are multiple types of spaces in UNICODE, maybe it's a good idea to add support for more
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
#define MARGIN_SIZE 8 // Size for the margins
|
||||
#define COLOR_SIZE 16 // Size of the color select buttons
|
||||
|
||||
// Draw part of a texture (defined by a rectangle) with rotation and scale tiled into dest.
|
||||
// Draw part of a texture (defined by a rectangle) with rotation and scale tiled into dest
|
||||
void DrawTextureTiled(Texture2D texture, Rectangle source, Rectangle dest, Vector2 origin, float rotation, float scale, Color tint);
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
@ -173,7 +173,7 @@ int main(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Draw part of a texture (defined by a rectangle) with rotation and scale tiled into dest.
|
||||
// Draw part of a texture (defined by a rectangle) with rotation and scale tiled into dest
|
||||
void DrawTextureTiled(Texture2D texture, Rectangle source, Rectangle dest, Vector2 origin, float rotation, float scale, Color tint)
|
||||
{
|
||||
if ((texture.id <= 0) || (scale <= 0.0f)) return; // Wanna see a infinite loop?!...just delete this line!
|
||||
|
||||
@ -75,9 +75,9 @@ int main(void)
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Draw
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
// TODO...
|
||||
// Nothing to update...
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
|
||||
@ -71,7 +71,7 @@ int main(void)
|
||||
// Activate one particle every frame and Update active particles
|
||||
// NOTE: Particles initial position should be mouse position when activated
|
||||
// NOTE: Particles fall down with gravity and rotation... and disappear after 2 seconds (alpha = 0)
|
||||
// NOTE: When a particle disappears, active = false and it can be reused.
|
||||
// NOTE: When a particle disappears, active = false and it can be reused
|
||||
for (int i = 0; i < MAX_PARTICLES; i++)
|
||||
{
|
||||
if (!mouseTail[i].active)
|
||||
|
||||
Reference in New Issue
Block a user