diff --git a/README.md b/README.md index fde1e279f..b6404b7eb 100644 --- a/README.md +++ b/README.md @@ -17,19 +17,19 @@ features * Written in plain C code (C99) * Uses PascalCase/camelCase notation * Hardware accelerated with OpenGL (1.1, 2.1, 3.3 or ES2) - * Unique OpenGL abstraction layer (usable as standalone module): [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.c) - * Powerful fonts module with multiple SpriteFonts formats support (XNA bitmap fonts, AngelCode fonts, TTF) + * Unique OpenGL abstraction layer (usable as standalone module): [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.c) + * Powerful fonts module with SpriteFonts support (XNA bitmap fonts, AngelCode fonts, TTF) * Outstanding texture formats support, including compressed formats (DXT, ETC, PVRT, ASTC) - * Basic 3d support for Shapes, Models, Billboards, Heightmaps and Cubicmaps - * Materials (diffuse, normal, specular) and Lighting (point, directional, spot) support + * Basic 3d support for Geometrics, Models, Billboards, Heightmaps and Cubicmaps + * Flexible Materials system, supporting by default diffuse, normal and specular maps * Shaders support, including Model shaders and Postprocessing shaders - * Powerful math module for Vector and Matrix operations: [raymath](https://github.com/raysan5/raylib/blob/master/src/raymath.c) - * Audio loading and playing with streaming support and mixing channels (WAV, OGG, FLAC, XM, MOD) + * Powerful math module for Vector, Matrix and Quaternion operations: [raymath](https://github.com/raysan5/raylib/blob/master/src/raymath.c) + * Audio loading and playing with streaming support (WAV, OGG, FLAC, XM, MOD) * Multiple platforms support: Windows, Linux, Mac, **Android**, **Raspberry Pi** and **HTML5** * VR stereo rendering support with configurable HMD device parameters * Custom color palette for fancy visuals on raywhite background * Minimal external dependencies (GLFW3, OpenGL, OpenAL) - * Complete binding to LUA: [raylib-lua](https://github.com/raysan5/raylib-lua) + * Complete bindings to LUA ([raylib-lua](https://github.com/raysan5/raylib-lua)) and Go ([raylib-go](https://github.com/gen2brain/raylib-go)) raylib uses on its core module the outstanding [GLFW3](http://www.glfw.org/) library. The best option I found for multiplatform (Windows, Linux, Mac) window/context and input management (clean, focused, great license, well documented, modern, maintained, ...). @@ -43,31 +43,17 @@ On Raspberry Pi, raylib uses Videocore API and EGL for window/context management raylib is licensed under a zlib/libpng license. View [LICENSE](https://github.com/raysan5/raylib/blob/master/LICENSE.md). -tools requirements ------------------- +building +-------- + +For detailed building instructions, check [raylib Wiki](https://github.com/raysan5/raylib/wiki). raylib has been developed using exclusively two tools: * Notepad++ (text editor) - [http://notepad-plus-plus.org/](http://notepad-plus-plus.org/) * MinGW (GCC compiler) - [http://www.mingw.org/](http://www.mingw.org/) -Those are the tools I recommend to develop with raylib, in fact, those are the tools my students use. -I believe those are the best tools to train spartan-programmers. - -Someone could argue about debugging. raylib is a library intended for learning and I think C it's a clear enough language -to allow writing small-mid size programs with a printf-based debugging. All raylib examples have also been written this way. - -Since raylib v1.1, you can download a Windows Installer package for easy installation and configuration. Check [raylib Webpage](http://www.raylib.com/) - -building source (generate libraylib.a) --------------------------------------- - -Check raylib wiki page: [Compile for...](https://github.com/raysan5/raylib/wiki) - -building examples ------------------ - -Check raylib wiki page: [Compile for...](https://github.com/raysan5/raylib/wiki) +Those are the tools recommended to develop with raylib, in fact, those are the tools my students use. contact ------- @@ -98,7 +84,7 @@ contributing (in some way or another) to make raylib project better. Huge thanks - Marc Agüera for testing and using raylib on a real product ([Koala Seasons](http://www.koalaseasons.com)) - Daniel Moreno for testing and using raylib on a real product ([Koala Seasons](http://www.koalaseasons.com)) - Daniel Gomez for testing and using raylib on a real product ([Koala Seasons](http://www.koalaseasons.com)) - - Sergio Martinez for helping on raygui development and tools development (raygui_styler). + - [Sergio Martinez](https://github.com/anidealgift) for helping on raygui development and tools development (raygui_styler). - [Victor Fisac](https://github.com/victorfisac) for developing physics raylib module (physac) and implementing materials and lighting systems... among multiple other improvements and multiple tools and games. - Albert Martos for helping on raygui and porting examples and game-templates to Android and HTML5. - Ian Eito for helping on raygui and porting examples and game-templates to Android and HTML5. @@ -106,15 +92,22 @@ contributing (in some way or another) to make raylib project better. Huge thanks - [Chris Hemingway](https://github.com/cHemingway) for improving raylib on OSX build system. - [Emanuele Petriglia](https://github.com/LelixSuper) for working on multiple GNU/Linux improvements and developing [TicTacToe](https://github.com/LelixSuper/TicTacToe) raylib game. - [Joshua Reisenauer](https://github.com/kd7tck) for adding audio modules support (XM, MOD) and reviewing audio system. - - Marcelo Paez (paezao) for his help on OSX to solve High DPI display issue. Thanks Marcelo! + - [Marcelo Paez](https://github.com/paezao) for his help on OSX to solve High DPI display issue. Thanks Marcelo! - [Ghassan Al-Mashareqa](https://github.com/ghassanpl) for his amazing contribution with raylib Lua module, I just work over his code to implement [rlua](https://github.com/raysan5/raylib/blob/master/src/rlua.h) - [Teodor Stoenescu](https://github.com/teodor-stoenescu) for his improvements on OBJ object loading. + - [RDR8](https://github.com/RDR8) for helping with Linux build improvements + - [Saggi Mizrahi](https://github.com/ficoos) for multiple fixes on Linux and audio system + - [Daniel Lemos](https://github.com/xspager) for fixing issues on Linux games building + - [Joel Davis](https://github.com/joeld42) for adding raycast picking utilities and a [great example](https://github.com/raysan5/raylib/blob/master/examples/models/models_mesh_picking.c) + - [Richard Goodwin](https://github.com/AudioMorphology) for adding RPI touchscreen support + - [Milan Nikolic](https://github.com/gen2brain) for adding Android build support with custom standalone toolchain Please, if I forget someone in this list, excuse me and write me an email to remind me to add you! -[raysan5]: mailto:ray@raylib.com "Ramon Santamaria - Ray San" - license ------- raylib is licensed under an unmodified zlib/libpng license, which is an OSI-certified, BSD-like license that allows static linking with closed source software. Check [LICENSE](LICENSE.md) for further details. + +[raysan5]: mailto:ray@raylib.com "Ramon Santamaria - Ray San" + diff --git a/docs/cheatsheet/cheatsheet.html b/docs/cheatsheet/cheatsheet.html index be1e696a4..b54046142 100644 --- a/docs/cheatsheet/cheatsheet.html +++ b/docs/cheatsheet/cheatsheet.html @@ -127,7 +127,7 @@

[simple and easy-to-use library to learn videogames programming]

-

v1.6.0 quick reference card

+

v1.7.0 quick reference card


@@ -154,7 +154,7 @@

colors

- + diff --git a/docs/cheatsheet/raylib_audio.c b/docs/cheatsheet/raylib_audio.c index 85b58ebf1..3d0447bff 100644 --- a/docs/cheatsheet/raylib_audio.c +++ b/docs/cheatsheet/raylib_audio.c @@ -3,6 +3,7 @@ void InitAudioDevice(void); // Initialize audio device and context void CloseAudioDevice(void); // Close the audio device and context (and music stream) bool IsAudioDeviceReady(void); // Check if audio device is ready + void SetMasterVolume(float volume); // Set master volume (listener) // Wave/Sound loading/unloading functions Wave LoadWave(const char *fileName); // Load wave data from file into RAM @@ -10,7 +11,6 @@ int sampleSize, int channels); // Load wave data from float array data (32bit) Sound LoadSound(const char *fileName); // Load sound to memory Sound LoadSoundFromWave(Wave wave); // Load sound to memory from wave data - Sound LoadSoundFromRES(const char *rresName, int resId); // Load sound to memory from rRES file (raylib Resource) void UpdateSound(Sound sound, void *data, int numSamples); // Update sound buffer with new data void UnloadWave(Wave wave); // Unload wave data void UnloadSound(Sound sound); // Unload sound @@ -39,6 +39,7 @@ bool IsMusicPlaying(Music music); // Check if music is playing void SetMusicVolume(Music music, float volume); // Set volume for music (1.0 is max level) void SetMusicPitch(Music music, float pitch); // Set pitch for a music (1.0 is base level) + void SetMusicLoopCount(Music music, float count); // Set music loop count (loop repeats) float GetMusicTimeLength(Music music); // Get music time length (in seconds) float GetMusicTimePlayed(Music music); // Get current music time played (in seconds) diff --git a/docs/cheatsheet/raylib_core.c b/docs/cheatsheet/raylib_core.c index 25fe1fc1d..b2827c419 100644 --- a/docs/cheatsheet/raylib_core.c +++ b/docs/cheatsheet/raylib_core.c @@ -1,62 +1,72 @@ // Window-related functions void InitWindow(int width, int height, char* title); // Initialize Window and Graphics Context (OpenGL) - void CloseWindow(void); // Close Window and Terminate Context - bool WindowShouldClose(void); // Detect if KEY_ESCAPE pressed or Close icon pressed - bool IsWindowMinimized(void); // Detect if window has been minimized (or lost focus) - void ToggleFullscreen(void); // Fullscreen toggle (by default F11) + void CloseWindow(void); // Close window and unload OpenGL context + bool WindowShouldClose(void); // Check if KEY_ESCAPE pressed or Close icon pressed + bool IsWindowMinimized(void); // Check if window has been minimized (or lost focus) + void ToggleFullscreen(void); // Toggle fullscreen mode (only PLATFORM_DESKTOP) + void SetWindowIcon(Image image); // Set icon for window (only PLATFORM_DESKTOP) + void SetWindowPosition(int x, int y); // Set window position on screen (only PLATFORM_DESKTOP) + void SetWindowMonitor(int monitor); // Set monitor for the current window (fullscreen mode) + void SetWindowMinSize(int width, int height); // Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE) int GetScreenWidth(void); // Get current screen width int GetScreenHeight(void); // Get current screen height // Cursor-related functions void ShowCursor(void); // Shows cursor void HideCursor(void); // Hides cursor - bool IsCursorHidden(void); // Returns true if cursor is not visible - void EnableCursor(void); // Enables cursor - void DisableCursor(void); // Disables cursor + bool IsCursorHidden(void); // Check if cursor is not visible + void EnableCursor(void); // Enables cursor (unlock cursor) + void DisableCursor(void); // Disables cursor (lock cursor) // Drawing-related functions - void ClearBackground(Color color); // Sets Background Color - void BeginDrawing(void); // Setup drawing canvas to start drawing - void EndDrawing(void); // End canvas drawing and Swap Buffers (Double Buffering) - - void Begin2dMode(Camera2D camera); // Initialize 2D mode with custom camera - void End2dMode(void); // Ends 2D mode custom camera usage - void Begin3dMode(Camera camera); // Initializes 3D mode for drawing (Camera setup) + void ClearBackground(Color color); // Set background color (framebuffer clear color) + void BeginDrawing(void); // Setup canvas (framebuffer) to start drawing + void EndDrawing(void); // End canvas drawing and swap buffers (double buffering) + void Begin2dMode(Camera2D camera); // Initialize 2D mode with custom camera (2D) + void End2dMode(void); // Ends 2D mode with custom camera + void Begin3dMode(Camera camera); // Initializes 3D mode with custom camera (3D) void End3dMode(void); // Ends 3D mode and returns to default 2D orthographic mode void BeginTextureMode(RenderTexture2D target); // Initializes render texture for drawing void EndTextureMode(void); // Ends drawing to render texture - + + // Screen-space-related functions Ray GetMouseRay(Vector2 mousePosition, Camera camera); // Returns a ray trace from mouse position - Vector2 GetWorldToScreen(Vector3 position, Camera camera); // Returns the screen space position from a 3d world space position + Vector2 GetWorldToScreen(Vector3 position, Camera camera); // Returns the screen space position for a 3d world space position Matrix GetCameraMatrix(Camera camera); // Returns camera transform matrix (view matrix) // Timming-related functions void SetTargetFPS(int fps); // Set target FPS (maximum) - float GetFPS(void); // Returns current FPS - float GetFrameTime(void); // Returns time in seconds for one frame + int GetFPS(void); // Returns current FPS + float GetFrameTime(void); // Returns time in seconds for last frame drawn // Color-related functions - Color GetColor(int hexValue); // Returns a Color struct from hexadecimal value int GetHexValue(Color color); // Returns hexadecimal value for a Color + Color GetColor(int hexValue); // Returns a Color struct from hexadecimal value + Color Fade(Color color, float alpha); // Color fade-in or fade-out, alpha goes from 0.0f to 1.0f float *ColorToFloat(Color color); // Converts Color to float array and normalizes float *VectorToFloat(Vector3 vec); // Converts Vector3 to float array float *MatrixToFloat(Matrix mat); // Converts Matrix to float array // Misc. functions + void ShowLogo(void); // Activate raylib logo at startup (can be done with flags) + void SetConfigFlags(char flags); // Setup window configuration flags (view FLAGS) + void TraceLog(int logType, const char *text, ...); // Show trace log messages (INFO, WARNING, ERROR, DEBUG) + void TakeScreenshot(const char *fileName); // Takes a screenshot of current screen (saved a .png) int GetRandomValue(int min, int max); // Returns a random value between min and max (both included) - Color Fade(Color color, float alpha); // Color fade-in or fade-out, alpha goes from 0.0 to 1.0 - void SetConfigFlags(char flags); // Setup some window configuration flags - void ShowLogo(void); // Activates raylib logo at startup (can be done with flags) - // Drag-and-drop files functions - bool IsFileDropped(void); // Check if a file have been dropped into window - char **GetDroppedFiles(int *count); // Retrieve dropped files into window + // Files management functions + bool IsFileExtension(const char *fileName, const char *ext); // Check file extension + const char *GetDirectoryPath(const char *fileName); // Get directory for a given fileName (with path) + const char *GetWorkingDirectory(void); // Get current working directory + bool ChangeDirectory(const char *dir); // Change working directory, returns true if success + bool IsFileDropped(void); // Check if a file has been dropped into window + char **GetDroppedFiles(int *count); // Get dropped files names void ClearDroppedFiles(void); // Clear dropped files paths buffer // Persistent storage management - void StorageSaveValue(int position, int value); // Storage save integer value (to defined position) - int StorageLoadValue(int position); // Storage load integer value (from defined position) + void StorageSaveValue(int position, int value); // Save integer value to storage file (to defined position) + int StorageLoadValue(int position); // Load integer value from storage file (from defined position) // Input-related functions: keyboard bool IsKeyPressed(int key); // Detect if a key has been pressed once diff --git a/docs/cheatsheet/raylib_models.c b/docs/cheatsheet/raylib_models.c index 34f9668e0..909d7bee0 100644 --- a/docs/cheatsheet/raylib_models.c +++ b/docs/cheatsheet/raylib_models.c @@ -19,20 +19,20 @@ void DrawRay(Ray ray, Color color); // Draw a ray line void DrawGrid(int slices, float spacing); // Draw a grid (centered at (0, 0, 0)) void DrawGizmo(Vector3 position); // Draw simple gizmo - void DrawLight(Light light); // Draw light in 3D world // Model loading/unloading functions - Model LoadModel(const char *fileName); // Load a 3d model (.OBJ) - Model LoadModelEx(Mesh data, bool dynamic); // Load a 3d model (from mesh data) - Model LoadModelFromRES(const char *rresName, int resId); // Load a 3d model from rRES file (raylib Resource) - Model LoadHeightmap(Image heightmap, Vector3 size); // Load a heightmap image as a 3d model - Model LoadCubicmap(Image cubicmap); // Load a map image as a 3d model (cubes based) - void UnloadModel(Model model); // Unload 3d model from memory + Mesh LoadMesh(const char *fileName); // Load mesh from file + Mesh LoadMeshEx(int numVertex, float *vData, float *vtData, float *vnData, Color *cData); // Load mesh from vertex data + Model LoadModel(const char *fileName); // Load model from file + Model LoadModelFromMesh(Mesh data, bool dynamic); // Load model from mesh data + Model LoadHeightmap(Image heightmap, Vector3 size); // Load heightmap model from image data + Model LoadCubicmap(Image cubicmap); // Load cubes-based map model from image data + void UnloadMesh(Mesh *mesh); // Unload mesh from memory (RAM and/or VRAM) + void UnloadModel(Model model); // Unload model from memory (RAM and/or VRAM) // Material loading/unloading functions Material LoadMaterial(const char *fileName); // Load material data (from file) Material LoadDefaultMaterial(void); // Load default material (uses default models shader) - Material LoadStandardMaterial(void); // Load standard material (uses material attributes and lighting shader) void UnloadMaterial(Material material); // Unload material textures from VRAM // Model drawing functions @@ -55,4 +55,7 @@ bool CheckCollisionRaySphereEx(Ray ray, Vector3 spherePosition, float sphereRadius, Vector3 *collisionPoint); // Detect collision between ray and sphere ex. bool CheckCollisionRayBox(Ray ray, Vector3 minBBox, Vector3 maxBBox); // Detect collision between ray and box BoundingBox CalculateBoundingBox(Mesh mesh); // Calculate mesh bounding box limits + RayHitInfo GetCollisionRayMesh(Ray ray, Mesh *mesh); // Get collision info between ray and mesh + RayHitInfo GetCollisionRayTriangle(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3); // Get collision info between ray and triangle + RayHitInfo GetCollisionRayGround(Ray ray, float groundHeight); // Get collision info between ray and ground plane (Y-normal plane) diff --git a/docs/cheatsheet/raylib_shaders.c b/docs/cheatsheet/raylib_shaders.c index de77ee1a4..c321a5022 100644 --- a/docs/cheatsheet/raylib_shaders.c +++ b/docs/cheatsheet/raylib_shaders.c @@ -1,9 +1,10 @@ // Shader loading/unloading functions + char *LoadText(const char *fileName); // Load chars array from text file Shader LoadShader(char *vsFileName, char *fsFileName); // Load a custom shader and bind default locations void UnloadShader(Shader shader); // Unload a custom shader from memory + Shader GetDefaultShader(void); // Get default shader - Shader GetStandardShader(void); // Get standard shader Texture2D GetDefaultTexture(void); // Get default texture // Shader access functions @@ -19,16 +20,13 @@ void EndShaderMode(void); // End custom shader drawing (use default shader) void BeginBlendMode(int mode); // Begin blending mode (alpha, additive, multiplied) void EndBlendMode(void); // End blending mode (reset to default: alpha blending) - - // Light creation/destruction functions - Light CreateLight(int type, Vector3 position, Color diffuse); // Create a new light, initialize it and add to pool - void DestroyLight(Light light); // Destroy a light and take it out of the list - + // VR control functions - void InitVrDevice(int vrDevice); // Init VR device - void CloseVrDevice(void); // Close VR device - bool IsVrDeviceReady(void); // Detect if VR device is ready - bool IsVrSimulator(void); // Detect if VR simulator is running + void InitVrSimulator(int vrDevice); // Init VR simulator for selected device + void CloseVrSimulator(void); // Close VR simulator for current device + bool IsVrSimulatorReady(void); // Detect if VR simulator is ready void UpdateVrTracking(Camera *camera); // Update VR tracking (position and orientation) and camera - void ToggleVrMode(void); // Enable/Disable VR experience (device or simulator) + void ToggleVrMode(void); // Enable/Disable VR experience + void BeginVrDrawing(void); // Begin VR simulator stereo rendering + void EndVrDrawing(void); // End VR simulator stereo rendering diff --git a/docs/cheatsheet/raylib_shapes.c b/docs/cheatsheet/raylib_shapes.c index 534efbe33..7bf4eaaa3 100644 --- a/docs/cheatsheet/raylib_shapes.c +++ b/docs/cheatsheet/raylib_shapes.c @@ -4,12 +4,15 @@ void DrawPixelV(Vector2 position, Color color); // Draw a pixel (Vector version) void DrawLine(int startPosX, int startPosY, int endPosX, int endPosY, Color color); // Draw a line void DrawLineV(Vector2 startPos, Vector2 endPos, Color color); // Draw a line (Vector version) + void DrawLineEx(Vector2 startPos, Vector2 endPos, float thick, Color color); // Draw a line defining thickness + void DrawLineBezier(Vector2 startPos, Vector2 endPos, float thick, Color color); // Draw a line using cubic-bezier curves in-out void DrawCircle(int centerX, int centerY, float radius, Color color); // Draw a color-filled circle void DrawCircleGradient(int centerX, int centerY, float radius, Color color1, Color color2); // Draw a gradient-filled circle void DrawCircleV(Vector2 center, float radius, Color color); // Draw a color-filled circle (Vector version) void DrawCircleLines(int centerX, int centerY, float radius, Color color); // Draw circle outline void DrawRectangle(int posX, int posY, int width, int height, Color color); // Draw a color-filled rectangle void DrawRectangleRec(Rectangle rec, Color color); // Draw a color-filled rectangle + void DrawRectanglePro(Rectangle rec, Vector2 origin, float rotation, Color color); // Draw a color-filled rectangle with pro parameters void DrawRectangleGradient(int posX, int posY, int width, int height, Color color1, Color color2); // Draw a gradient-filled rectangle void DrawRectangleV(Vector2 position, Vector2 size, Color color); // Draw a color-filled rectangle (Vector version) void DrawRectangleLines(int posX, int posY, int width, int height, Color color); // Draw rectangle outline diff --git a/docs/cheatsheet/raylib_structs.c b/docs/cheatsheet/raylib_structs.c index dd7aa6659..96441470a 100644 --- a/docs/cheatsheet/raylib_structs.c +++ b/docs/cheatsheet/raylib_structs.c @@ -20,6 +20,7 @@ struct Light; // Light type, defines light properties struct Model; // Basic 3d Model type struct Ray; // Ray type (useful for raycast) + struct RayHitInfo; // Raycast hit information struct Wave; // Wave type, defines audio wave data struct Sound; // Basic Sound source and buffer diff --git a/docs/cheatsheet/raylib_text.c b/docs/cheatsheet/raylib_text.c index 1e231c291..1c164e5ba 100644 --- a/docs/cheatsheet/raylib_text.c +++ b/docs/cheatsheet/raylib_text.c @@ -2,14 +2,14 @@ // SpriteFont loading/unloading functions SpriteFont GetDefaultFont(void); // Get the default SpriteFont SpriteFont LoadSpriteFont(const char *fileName); // Load a SpriteFont image into GPU memory - SpriteFont LoadSpriteFontTTF(const char *fileName, int fontSize, int numChars, int *fontChars); // Load a SpriteFont from TTF font with parameters + SpriteFont LoadSpriteFontEx(const char *fileName, int fontSize, int numChars, int *fontChars); // Load a SpriteFont from TTF font with parameters void UnloadSpriteFont(SpriteFont spriteFont); // Unload SpriteFont from GPU memory // Text drawing functions + void DrawFPS(int posX, int posY); // Shows current FPS on top-left corner void DrawText(const char *text, int posX, int posY, int fontSize, Color color); // Draw text (using default font) void DrawTextEx(SpriteFont spriteFont, const char* text, Vector2 position, // Draw text using SpriteFont and additional parameters int fontSize, int spacing, Color tint); - void DrawFPS(int posX, int posY); // Shows current FPS on top-left corner // Text misc. functions int MeasureText(const char *text, int fontSize); // Measure string width for default font diff --git a/docs/cheatsheet/raylib_textures.c b/docs/cheatsheet/raylib_textures.c index df7c3d05c..d776c5676 100644 --- a/docs/cheatsheet/raylib_textures.c +++ b/docs/cheatsheet/raylib_textures.c @@ -2,11 +2,9 @@ // Image/Texture2D data loading/unloading functions Image LoadImage(const char *fileName); // Load an image into CPU memory (RAM) Image LoadImageEx(Color *pixels, int width, int height); // Load image data from Color array data (RGBA - 32bit) + Image LoadImagePro(void *data, int width, int height, int format); // Load image from raw data with parameters Image LoadImageRaw(const char *fileName, int width, int height, int format, int headerSize); // Load image data from RAW file - Image LoadImageFromRES(const char *rresName, int resId); // Load an image from rRES file (raylib Resource) Texture2D LoadTexture(const char *fileName); // Load an image as texture into GPU memory - Texture2D LoadTextureEx(void *data, int width, int height, int textureFormat, int mipmapCount); // Load a texture from raw data into GPU memory - Texture2D LoadTextureFromRES(const char *rresName, int resId); // Load an image as texture from rRES file (raylib Resource) Texture2D LoadTextureFromImage(Image image); // Load a texture from image data RenderTexture2D LoadRenderTexture(int width, int height); // Load a texture to be used for rendering void UnloadImage(Image image); // Unload image from CPU memory (RAM) @@ -19,6 +17,7 @@ // Image manipulation functions void ImageToPOT(Image *image, Color fillColor); // Convert image to POT (power-of-two) void ImageFormat(Image *image, int newFormat); // Convert image data to desired format + void ImageAlphaMask(Image *image, Image alphaMask); // Apply alpha mask to image void ImageDither(Image *image, int rBpp, int gBpp, int bBpp, int aBpp); // Dither image data to 16bpp or lower (Floyd-Steinberg dithering) Image ImageCopy(Image image); // Create an image duplicate (useful for transformations) void ImageCrop(Image *image, Rectangle crop); // Crop an image to a defined rectangle diff --git a/docs/common/src/libraylib.a b/docs/common/src/libraylib.a deleted file mode 100644 index 1606a4111..000000000 Binary files a/docs/common/src/libraylib.a and /dev/null differ diff --git a/docs/examples/src/shaders/shaders_postprocessing.c b/docs/examples/src/shaders/shaders_postprocessing.c index 43d1af725..bb239efad 100644 --- a/docs/examples/src/shaders/shaders_postprocessing.c +++ b/docs/examples/src/shaders/shaders_postprocessing.c @@ -18,6 +18,48 @@ #include "raylib.h" +#if defined(PLATFORM_DESKTOP) + #define GLSL_VERSION 330 + #define DEFAULT_VERTEX_SHADER "resources/shaders/glsl330/base.vs" +#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB + #define GLSL_VERSION 100 + #define DEFAULT_VERTEX_SHADER "resources/shaders/glsl100/base.vs" +#endif + +#define MAX_POSTPRO_SHADERS 12 + +typedef enum { + FX_GRAYSCALE = 0, + FX_POSTERIZATION, + FX_DREAM_VISION, + FX_PIXELIZER, + FX_CROSS_HATCHING, + FX_CROSS_STITCHING, + FX_PREDATOR_VIEW, + FX_SCANLINES, + FX_FISHEYE, + FX_SOBEL, + FX_BLOOM, + FX_BLUR, + //FX_FXAA +} PostproShader; + +static const char *postproShaderText[] = { + "GRAYSCALE", + "POSTERIZATION", + "DREAM_VISION", + "PIXELIZER", + "CROSS_HATCHING", + "CROSS_STITCHING", + "PREDATOR_VIEW", + "SCANLINES", + "FISHEYE", + "SOBEL", + "BLOOM", + "BLUR", + //"FXAA" +}; + int main() { // Initialization @@ -38,8 +80,25 @@ int main() Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position - Shader shader = LoadShader("resources/shaders/glsl330/base.vs", - "resources/shaders/glsl330/bloom.fs"); // Load postpro shader + // Load all postpro shaders + // NOTE 1: All postpro shader use the base vertex shader (DEFAULT_VERTEX_SHADER) + // NOTE 2: We load the correct shader depending on GLSL version + Shader shaders[MAX_POSTPRO_SHADERS]; + + shaders[FX_GRAYSCALE] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/grayscale.fs", GLSL_VERSION)); + shaders[FX_POSTERIZATION] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/posterization.fs", GLSL_VERSION)); + shaders[FX_DREAM_VISION] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/dream_vision.fs", GLSL_VERSION)); + shaders[FX_PIXELIZER] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/pixelizer.fs", GLSL_VERSION)); + shaders[FX_CROSS_HATCHING] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/cross_hatching.fs", GLSL_VERSION)); + shaders[FX_CROSS_STITCHING] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/cross_stitching.fs", GLSL_VERSION)); + shaders[FX_PREDATOR_VIEW] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/predator.fs", GLSL_VERSION)); + shaders[FX_SCANLINES] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/scanlines.fs", GLSL_VERSION)); + shaders[FX_FISHEYE] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/fisheye.fs", GLSL_VERSION)); + shaders[FX_SOBEL] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/sobel.fs", GLSL_VERSION)); + shaders[FX_BLOOM] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/bloom.fs", GLSL_VERSION)); + shaders[FX_BLUR] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/blur.fs", GLSL_VERSION)); + + int currentShader = FX_GRAYSCALE; // Create a RenderTexture2D to be used for render to texture RenderTexture2D target = LoadRenderTexture(screenWidth, screenHeight); @@ -56,6 +115,12 @@ int main() // Update //---------------------------------------------------------------------------------- UpdateCamera(&camera); // Update camera + + if (IsKeyPressed(KEY_RIGHT)) currentShader++; + else if (IsKeyPressed(KEY_LEFT)) currentShader--; + + if (currentShader >= MAX_POSTPRO_SHADERS) currentShader = 0; + else if (currentShader < 0) currentShader = MAX_POSTPRO_SHADERS - 1; //---------------------------------------------------------------------------------- // Draw @@ -73,21 +138,26 @@ int main() DrawGrid(10, 1.0f); // Draw a grid End3dMode(); - - DrawText("HELLO POSTPROCESSING!", 70, 190, 50, RED); EndTextureMode(); // End drawing to texture (now we have a texture available for next passes) - BeginShaderMode(shader); + // Render previously generated texture using selected postpro shader + BeginShaderMode(shaders[currentShader]); // NOTE: Render texture must be y-flipped due to default OpenGL coordinates (left-bottom) DrawTextureRec(target.texture, (Rectangle){ 0, 0, target.texture.width, -target.texture.height }, (Vector2){ 0, 0 }, WHITE); EndShaderMode(); + DrawRectangle(0, 9, 580, 30, Fade(LIGHTGRAY, 0.7f)); + DrawText("(c) Dwarf 3D model by David Moreno", screenWidth - 200, screenHeight - 20, 10, DARKGRAY); - - DrawFPS(10, 10); + + DrawText("CURRENT POSTPRO SHADER:", 10, 15, 20, BLACK); + DrawText(postproShaderText[currentShader], 330, 15, 20, RED); + DrawText("< >", 540, 10, 30, DARKBLUE); + + DrawFPS(700, 15); EndDrawing(); //---------------------------------------------------------------------------------- @@ -95,7 +165,10 @@ int main() // De-Initialization //-------------------------------------------------------------------------------------- - UnloadShader(shader); // Unload shader + + // Unload all postpro shaders + for (int i = 0; i < MAX_POSTPRO_SHADERS; i++) UnloadShader(shaders[i]); + UnloadTexture(texture); // Unload texture UnloadModel(dwarf); // Unload model UnloadRenderTexture(target); // Unload render texture diff --git a/docs/examples/web/shaders/shaders_postprocessing.png b/docs/examples/web/shaders/shaders_postprocessing.png index 684cbd419..628ab810d 100644 Binary files a/docs/examples/web/shaders/shaders_postprocessing.png and b/docs/examples/web/shaders/shaders_postprocessing.png differ diff --git a/docs/images/raylib_architecture.png b/docs/images/raylib_architecture.png index cfe429fc0..ab0e5f626 100644 Binary files a/docs/images/raylib_architecture.png and b/docs/images/raylib_architecture.png differ diff --git a/docs/images/raylib_architecture_v1.6.png b/docs/images/raylib_architecture_v1.6.png new file mode 100644 index 000000000..cfe429fc0 Binary files /dev/null and b/docs/images/raylib_architecture_v1.6.png differ diff --git a/docs/index.html b/docs/index.html index 847e43465..d5f824fed 100644 --- a/docs/index.html +++ b/docs/index.html @@ -86,7 +86,7 @@

-

raylib is highly inspired by Borland BGI graphics lib and by XNA framework. Allegro and SDL have also been analyzed for reference.

+

raylib is highly inspired by Borland BGI graphics lib and by XNA framework. Allegro and SDL have also been used as reference.


NOTE for ADVENTURERS: raylib is a programming library to learn videogames programming; no fancy interface, no visual helpers, no auto-debugging... just coding in the most pure spartan-programmers way. Are you ready to learn? Jump to code examples!.


@@ -99,16 +99,16 @@ - Unique OpenGL abstraction layer (usable as standalone module): [rlgl]
- Powerful fonts module with SpriteFonts support (XNA fonts, AngelCode fonts, TTF)
- Outstanding texture formats support, including compressed formats (DXT, ETC, ASTC)
- - Basic 3d support for Geometrics, Models, Heightmaps and Billboards
- - Materials (diffuse, normal, specular) and Lighting (point, directional, spot)
+ - Basic 3d support for Geometrics, Models, Billboards, Heightmaps ann Cubicmaps
+ - Flexible Materials system, supporting by default diffuse, normal and specular maps
- Shaders support, including Model shaders and Postprocessing shaders
- - Powerful math module for Vector and Matrix operations: [raymath]
+ - Powerful math module for Vector, Matrix and Quaternion operations: [raymath]
- Audio loading and playing with streaming support (WAV, OGG, FLAC, XM, MOD)
+ - Multiple platforms support: Windows, Linux, Mac, Android, Raspberry Pi and HTML5
- VR stereo rendering support with configurable HMD device parameters
- - Multiplatform support: Android, Raspberry Pi, HTML5, Oculus Rift CV1
- Custom color palette for fancy visuals on raywhite background
- Minimal external dependencies (GLFW3, OpenGL, OpenAL)
- - Complete binding to Lua, Go and Pascal.
+ - Complete bindings to Lua (raylib-lua) and Go (raylib-go).

raylib architechture @@ -118,7 +118,7 @@

raylib is open-source and free to use. View license.


raylib supporters on patreon -

The following people is supporting raylib project on patreon. Many thanks to all of them for believing in the project and contributing to it.

+

The following people have supported raylib project on patreon. Many thanks to all of them for believing in the project and contributing to it.


- Jarrod - 2drealms (@2drealms)

- Kovay Hatfield

@@ -133,8 +133,11 @@

- Antonio Radovcic

- James W. Bohnke

- Evan Sirchuk

+

- Justin Loudermilk

+

- Tazd'ij (@tazdij)

+

- James W.Bohnke


-

And a very special thanks to Ilya Zarembsky (@wly_cdgr) for his generous contribution. Many thanks Ilya! Hope your students are enjoying raylib! :D

+

And a very special thanks to Ilya Zarembsky (@wly_cdgr) for his generous contribution. Many thanks Ilya!