Merge branch 'master' of https://github.com/raysan5/raylib into raysan5-master
# Conflicts: # src/raylib.h
This commit is contained in:
commit
983d31c9d0
17
src/core.c
17
src/core.c
|
|
@ -273,6 +273,7 @@ static GLFWwindow *window; // Native window (graphic device
|
|||
#endif
|
||||
static bool windowReady = false; // Check if window has been initialized successfully
|
||||
static bool windowMinimized = false; // Check if window has been minimized
|
||||
static bool windowResized = false; // Check if window has been resized
|
||||
static const char *windowTitle = NULL; // Window text title...
|
||||
|
||||
static unsigned int displayWidth, displayHeight;// Display width and height (monitor, device-screen, LCD, ...)
|
||||
|
|
@ -742,6 +743,16 @@ bool IsWindowMinimized(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
// Check if window has been resized
|
||||
bool IsWindowResized(void)
|
||||
{
|
||||
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB) || defined(PLATFORM_UWP)
|
||||
return windowResized;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Check if window is currently hidden
|
||||
bool IsWindowHidden(void)
|
||||
{
|
||||
|
|
@ -990,6 +1001,8 @@ const char *GetClipboardText(void)
|
|||
{
|
||||
#if defined(PLATFORM_DESKTOP)
|
||||
return glfwGetClipboardString(window);
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -3136,6 +3149,8 @@ static void PollInputEvents(void)
|
|||
}
|
||||
}
|
||||
|
||||
windowResized = false;
|
||||
|
||||
#if defined(SUPPORT_EVENTS_WAITING)
|
||||
glfwWaitEvents();
|
||||
#else
|
||||
|
|
@ -3412,6 +3427,8 @@ static void WindowSizeCallback(GLFWwindow *window, int width, int height)
|
|||
currentHeight = height;
|
||||
|
||||
// NOTE: Postprocessing texture is not scaled to new size
|
||||
|
||||
windowResized = true;
|
||||
}
|
||||
|
||||
// GLFW3 WindowIconify Callback, runs when window is minimized/restored
|
||||
|
|
|
|||
|
|
@ -367,7 +367,7 @@ static mal_uint32 OnAudioBufferDSPRead(mal_dsp *pDSP, mal_uint32 frameCount, voi
|
|||
{
|
||||
AudioBuffer *audioBuffer = (AudioBuffer *)pUserData;
|
||||
|
||||
mal_uint32 subBufferSizeInFrames = audioBuffer->bufferSizeInFrames/2;
|
||||
mal_uint32 subBufferSizeInFrames = (audioBuffer->bufferSizeInFrames > 1)? audioBuffer->bufferSizeInFrames/2 : audioBuffer->bufferSizeInFrames;
|
||||
mal_uint32 currentSubBufferIndex = audioBuffer->frameCursorPos/subBufferSizeInFrames;
|
||||
|
||||
if (currentSubBufferIndex > 1)
|
||||
|
|
|
|||
307
src/raylib.h
307
src/raylib.h
|
|
@ -75,11 +75,9 @@
|
|||
#include <inttypes.h> // Required for rnet
|
||||
|
||||
#if defined(_WIN32) && defined(BUILD_LIBTYPE_SHARED)
|
||||
# define RLAPI \
|
||||
__declspec(dllexport) // We are building raylib as a Win32 shared library (.dll)
|
||||
#define RLAPI __declspec(dllexport) // We are building raylib as a Win32 shared library (.dll)
|
||||
#elif defined(_WIN32) && defined(USE_LIBTYPE_SHARED)
|
||||
# define RLAPI \
|
||||
__declspec(dllimport) // We are using raylib as a Win32 shared library (.dll)
|
||||
#define RLAPI __declspec(dllimport) // We are using raylib as a Win32 shared library (.dll)
|
||||
#else
|
||||
#define RLAPI // We are building or using raylib as a static library (or Linux shared library)
|
||||
#endif
|
||||
|
|
@ -97,10 +95,8 @@
|
|||
#define MAX_TOUCH_POINTS 10 // Maximum number of touch points supported
|
||||
|
||||
// Shader and material limits
|
||||
#define MAX_SHADER_LOCATIONS \
|
||||
32 // Maximum number of predefined locations stored in shader struct
|
||||
#define MAX_MATERIAL_MAPS \
|
||||
12 // Maximum number of texture maps stored in shader struct
|
||||
#define MAX_SHADER_LOCATIONS 32 // Maximum number of predefined locations stored in shader struct
|
||||
#define MAX_MATERIAL_MAPS 12 // Maximum number of texture maps stored in shader struct
|
||||
|
||||
// Network defines
|
||||
#define SOCKET_MAX_SET_SIZE 32
|
||||
|
|
@ -118,11 +114,9 @@
|
|||
// getnameinfo() defines
|
||||
#define NAME_INFO_DEFAULT 0x00 /* No flags set */
|
||||
#define NAME_INFO_NOFQDN 0x01 /* Only return nodename portion for local hosts */
|
||||
#define NAME_INFO_NUMERICHOST \
|
||||
0x02 /* Return numeric form of the host's address */
|
||||
#define NAME_INFO_NUMERICHOST 0x02 /* Return numeric form of the host's address */
|
||||
#define NAME_INFO_NAMEREQD 0x04 /* Error if the host's name not in DNS */
|
||||
#define NAME_INFO_NUMERICSERV \
|
||||
0x08 /* Return numeric form of the service (port #) */
|
||||
#define NAME_INFO_NUMERICSERV 0x08 /* Return numeric form of the service (port #) */
|
||||
#define NAME_INFO_DGRAM 0x10 /* Service is a datagram service */
|
||||
|
||||
// NOTE: MSC C++ compiler does not support compound literals (C99 feature)
|
||||
|
|
@ -135,59 +129,33 @@
|
|||
|
||||
// Some Basic Colors
|
||||
// NOTE: Custom raylib color palette for amazing visuals on WHITE background
|
||||
#define LIGHTGRAY \
|
||||
CLITERAL { 200, 200, 200, 255 } // Light Gray
|
||||
#define GRAY \
|
||||
CLITERAL { 130, 130, 130, 255 } // Gray
|
||||
#define DARKGRAY \
|
||||
CLITERAL { 80, 80, 80, 255 } // Dark Gray
|
||||
#define YELLOW \
|
||||
CLITERAL { 253, 249, 0, 255 } // Yellow
|
||||
#define GOLD \
|
||||
CLITERAL { 255, 203, 0, 255 } // Gold
|
||||
#define ORANGE \
|
||||
CLITERAL { 255, 161, 0, 255 } // Orange
|
||||
#define PINK \
|
||||
CLITERAL { 255, 109, 194, 255 } // Pink
|
||||
#define RED \
|
||||
CLITERAL { 230, 41, 55, 255 } // Red
|
||||
#define MAROON \
|
||||
CLITERAL { 190, 33, 55, 255 } // Maroon
|
||||
#define GREEN \
|
||||
CLITERAL { 0, 228, 48, 255 } // Green
|
||||
#define LIME \
|
||||
CLITERAL { 0, 158, 47, 255 } // Lime
|
||||
#define DARKGREEN \
|
||||
CLITERAL { 0, 117, 44, 255 } // Dark Green
|
||||
#define SKYBLUE \
|
||||
CLITERAL { 102, 191, 255, 255 } // Sky Blue
|
||||
#define BLUE \
|
||||
CLITERAL { 0, 121, 241, 255 } // Blue
|
||||
#define DARKBLUE \
|
||||
CLITERAL { 0, 82, 172, 255 } // Dark Blue
|
||||
#define PURPLE \
|
||||
CLITERAL { 200, 122, 255, 255 } // Purple
|
||||
#define VIOLET \
|
||||
CLITERAL { 135, 60, 190, 255 } // Violet
|
||||
#define DARKPURPLE \
|
||||
CLITERAL { 112, 31, 126, 255 } // Dark Purple
|
||||
#define BEIGE \
|
||||
CLITERAL { 211, 176, 131, 255 } // Beige
|
||||
#define BROWN \
|
||||
CLITERAL { 127, 106, 79, 255 } // Brown
|
||||
#define DARKBROWN \
|
||||
CLITERAL { 76, 63, 47, 255 } // Dark Brown
|
||||
#define LIGHTGRAY CLITERAL{ 200, 200, 200, 255 } // Light Gray
|
||||
#define GRAY CLITERAL{ 130, 130, 130, 255 } // Gray
|
||||
#define DARKGRAY CLITERAL{ 80, 80, 80, 255 } // Dark Gray
|
||||
#define YELLOW CLITERAL{ 253, 249, 0, 255 } // Yellow
|
||||
#define GOLD CLITERAL{ 255, 203, 0, 255 } // Gold
|
||||
#define ORANGE CLITERAL{ 255, 161, 0, 255 } // Orange
|
||||
#define PINK CLITERAL{ 255, 109, 194, 255 } // Pink
|
||||
#define RED CLITERAL{ 230, 41, 55, 255 } // Red
|
||||
#define MAROON CLITERAL{ 190, 33, 55, 255 } // Maroon
|
||||
#define GREEN CLITERAL{ 0, 228, 48, 255 } // Green
|
||||
#define LIME CLITERAL{ 0, 158, 47, 255 } // Lime
|
||||
#define DARKGREEN CLITERAL{ 0, 117, 44, 255 } // Dark Green
|
||||
#define SKYBLUE CLITERAL{ 102, 191, 255, 255 } // Sky Blue
|
||||
#define BLUE CLITERAL{ 0, 121, 241, 255 } // Blue
|
||||
#define DARKBLUE CLITERAL{ 0, 82, 172, 255 } // Dark Blue
|
||||
#define PURPLE CLITERAL{ 200, 122, 255, 255 } // Purple
|
||||
#define VIOLET CLITERAL{ 135, 60, 190, 255 } // Violet
|
||||
#define DARKPURPLE CLITERAL{ 112, 31, 126, 255 } // Dark Purple
|
||||
#define BEIGE CLITERAL{ 211, 176, 131, 255 } // Beige
|
||||
#define BROWN CLITERAL{ 127, 106, 79, 255 } // Brown
|
||||
#define DARKBROWN CLITERAL{ 76, 63, 47, 255 } // Dark Brown
|
||||
|
||||
#define WHITE \
|
||||
CLITERAL { 255, 255, 255, 255 } // White
|
||||
#define BLACK \
|
||||
CLITERAL { 0, 0, 0, 255 } // Black
|
||||
#define BLANK \
|
||||
CLITERAL { 0, 0, 0, 0 } // Blank (Transparent)
|
||||
#define MAGENTA \
|
||||
CLITERAL { 255, 0, 255, 255 } // Magenta
|
||||
#define RAYWHITE \
|
||||
CLITERAL { 245, 245, 245, 255 } // My own White (raylib logo)
|
||||
#define WHITE CLITERAL{ 255, 255, 255, 255 } // White
|
||||
#define BLACK CLITERAL{ 0, 0, 0, 255 } // Black
|
||||
#define BLANK CLITERAL{ 0, 0, 0, 0 } // Blank (Transparent)
|
||||
#define MAGENTA CLITERAL{ 255, 0, 255, 255 } // Magenta
|
||||
#define RAYWHITE CLITERAL{ 245, 245, 245, 255 } // My own White (raylib logo)
|
||||
|
||||
// Temporal hack to avoid breaking old codebases using
|
||||
// deprecated raylib implementation of these functions
|
||||
|
|
@ -202,34 +170,27 @@
|
|||
#if defined(__STDC__) && __STDC_VERSION__ >= 199901L
|
||||
#include <stdbool.h>
|
||||
#elif !defined(__cplusplus) && !defined(bool)
|
||||
typedef enum
|
||||
{
|
||||
false,
|
||||
true
|
||||
} bool;
|
||||
typedef enum { false, true } bool;
|
||||
#endif
|
||||
|
||||
// Network typedefs
|
||||
typedef int32_t SocketChannel;
|
||||
|
||||
// Vector2 type
|
||||
typedef struct Vector2
|
||||
{
|
||||
typedef struct Vector2 {
|
||||
float x;
|
||||
float y;
|
||||
} Vector2;
|
||||
|
||||
// Vector3 type
|
||||
typedef struct Vector3
|
||||
{
|
||||
typedef struct Vector3 {
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
} Vector3;
|
||||
|
||||
// Vector4 type
|
||||
typedef struct Vector4
|
||||
{
|
||||
typedef struct Vector4 {
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
|
|
@ -240,8 +201,7 @@ typedef struct Vector4
|
|||
typedef Vector4 Quaternion;
|
||||
|
||||
// Matrix type (OpenGL style 4x4 - right handed, column major)
|
||||
typedef struct Matrix
|
||||
{
|
||||
typedef struct Matrix {
|
||||
float m0, m4, m8, m12;
|
||||
float m1, m5, m9, m13;
|
||||
float m2, m6, m10, m14;
|
||||
|
|
@ -249,8 +209,7 @@ typedef struct Matrix
|
|||
} Matrix;
|
||||
|
||||
// Color type, RGBA (32bit)
|
||||
typedef struct Color
|
||||
{
|
||||
typedef struct Color {
|
||||
unsigned char r;
|
||||
unsigned char g;
|
||||
unsigned char b;
|
||||
|
|
@ -258,8 +217,7 @@ typedef struct Color
|
|||
} Color;
|
||||
|
||||
// Rectangle type
|
||||
typedef struct Rectangle
|
||||
{
|
||||
typedef struct Rectangle {
|
||||
float x;
|
||||
float y;
|
||||
float width;
|
||||
|
|
@ -268,8 +226,7 @@ typedef struct Rectangle
|
|||
|
||||
// Image type, bpp always RGBA (32bit)
|
||||
// NOTE: Data stored in CPU memory (RAM)
|
||||
typedef struct Image
|
||||
{
|
||||
typedef struct Image {
|
||||
void *data; // Image raw data
|
||||
int width; // Image base width
|
||||
int height; // Image base height
|
||||
|
|
@ -279,8 +236,7 @@ typedef struct Image
|
|||
|
||||
// Texture2D type
|
||||
// NOTE: Data stored in GPU memory
|
||||
typedef struct Texture2D
|
||||
{
|
||||
typedef struct Texture2D {
|
||||
unsigned int id; // OpenGL texture id
|
||||
int width; // Texture base width
|
||||
int height; // Texture base height
|
||||
|
|
@ -295,8 +251,7 @@ typedef Texture2D Texture;
|
|||
typedef Texture2D TextureCubemap;
|
||||
|
||||
// RenderTexture2D type, for texture rendering
|
||||
typedef struct RenderTexture2D
|
||||
{
|
||||
typedef struct RenderTexture2D {
|
||||
unsigned int id; // OpenGL Framebuffer Object (FBO) id
|
||||
Texture2D texture; // Color buffer attachment texture
|
||||
Texture2D depth; // Depth buffer attachment texture
|
||||
|
|
@ -307,8 +262,7 @@ typedef struct RenderTexture2D
|
|||
typedef RenderTexture2D RenderTexture;
|
||||
|
||||
// N-Patch layout info
|
||||
typedef struct NPatchInfo
|
||||
{
|
||||
typedef struct NPatchInfo {
|
||||
Rectangle sourceRec; // Region in the texture
|
||||
int left; // left border offset
|
||||
int top; // top border offset
|
||||
|
|
@ -318,8 +272,7 @@ typedef struct NPatchInfo
|
|||
} NPatchInfo;
|
||||
|
||||
// Font character info
|
||||
typedef struct CharInfo
|
||||
{
|
||||
typedef struct CharInfo {
|
||||
int value; // Character value (Unicode)
|
||||
Rectangle rec; // Character rectangle in sprite font
|
||||
int offsetX; // Character offset X when drawing
|
||||
|
|
@ -329,8 +282,7 @@ typedef struct CharInfo
|
|||
} CharInfo;
|
||||
|
||||
// Font type, includes texture and charSet array data
|
||||
typedef struct Font
|
||||
{
|
||||
typedef struct Font {
|
||||
Texture2D texture; // Font texture
|
||||
int baseSize; // Base size (default chars height)
|
||||
int charsCount; // Number of characters
|
||||
|
|
@ -340,8 +292,7 @@ typedef struct Font
|
|||
#define SpriteFont Font // SpriteFont type fallback, defaults to Font
|
||||
|
||||
// Camera type, defines a camera position/orientation in 3d space
|
||||
typedef struct Camera3D
|
||||
{
|
||||
typedef struct Camera3D {
|
||||
Vector3 position; // Camera position
|
||||
Vector3 target; // Camera target it looks-at
|
||||
Vector3 up; // Camera up vector (rotation over its axis)
|
||||
|
|
@ -352,8 +303,7 @@ typedef struct Camera3D
|
|||
#define Camera Camera3D // Camera type fallback, defaults to Camera3D
|
||||
|
||||
// Camera2D type, defines a 2d camera
|
||||
typedef struct Camera2D
|
||||
{
|
||||
typedef struct Camera2D {
|
||||
Vector2 offset; // Camera offset (displacement from target)
|
||||
Vector2 target; // Camera target (rotation and zoom origin)
|
||||
float rotation; // Camera rotation in degrees
|
||||
|
|
@ -361,16 +311,14 @@ typedef struct Camera2D
|
|||
} Camera2D;
|
||||
|
||||
// Bounding box type
|
||||
typedef struct BoundingBox
|
||||
{
|
||||
typedef struct BoundingBox {
|
||||
Vector3 min; // Minimum vertex box-corner
|
||||
Vector3 max; // Maximum vertex box-corner
|
||||
} BoundingBox;
|
||||
|
||||
// Vertex data definning a mesh
|
||||
// NOTE: Data stored in CPU memory (and GPU)
|
||||
typedef struct Mesh
|
||||
{
|
||||
typedef struct Mesh {
|
||||
int vertexCount; // Number of vertices stored in arrays
|
||||
int triangleCount; // Number of triangles stored (indexed or not)
|
||||
|
||||
|
|
@ -395,46 +343,49 @@ typedef struct Mesh
|
|||
} Mesh;
|
||||
|
||||
// Shader type (generic)
|
||||
typedef struct Shader
|
||||
{
|
||||
typedef struct Shader {
|
||||
unsigned int id; // Shader program id
|
||||
int locs[MAX_SHADER_LOCATIONS]; // Shader locations array
|
||||
} Shader;
|
||||
|
||||
// Material texture map
|
||||
typedef struct MaterialMap
|
||||
{
|
||||
typedef struct MaterialMap {
|
||||
Texture2D texture; // Material map texture
|
||||
Color color; // Material map color
|
||||
float value; // Material map value
|
||||
} MaterialMap;
|
||||
|
||||
// Material type (generic)
|
||||
typedef struct Material
|
||||
{
|
||||
typedef struct Material {
|
||||
Shader shader; // Material shader
|
||||
MaterialMap maps[MAX_MATERIAL_MAPS]; // Material maps
|
||||
float *params; // Material generic parameters (if required)
|
||||
} Material;
|
||||
|
||||
// Model type
|
||||
typedef struct Model
|
||||
{
|
||||
typedef struct Model {
|
||||
Mesh mesh; // Vertex data buffers (RAM and VRAM)
|
||||
Matrix transform; // Local transform matrix
|
||||
Material material; // Shader and textures data
|
||||
/*
|
||||
Mesh *meshes; // Vertex data buffers (RAM and VRAM)
|
||||
int meshCount;
|
||||
|
||||
Material *materials; // Shader and textures data
|
||||
int materialCount;
|
||||
|
||||
int *meshMaterial; // Material assigned to every mesh
|
||||
*/
|
||||
} Model;
|
||||
|
||||
// Ray type (useful for raycast)
|
||||
typedef struct Ray
|
||||
{
|
||||
typedef struct Ray {
|
||||
Vector3 position; // Ray position (origin)
|
||||
Vector3 direction; // Ray direction
|
||||
} Ray;
|
||||
|
||||
// Raycast hit information
|
||||
typedef struct RayHitInfo
|
||||
{
|
||||
typedef struct RayHitInfo {
|
||||
bool hit; // Did the ray hit something?
|
||||
float distance; // Distance to nearest hit
|
||||
Vector3 position; // Position of nearest hit
|
||||
|
|
@ -442,8 +393,7 @@ typedef struct RayHitInfo
|
|||
} RayHitInfo;
|
||||
|
||||
// Wave type, defines audio wave data
|
||||
typedef struct Wave
|
||||
{
|
||||
typedef struct Wave {
|
||||
unsigned int sampleCount; // Number of samples
|
||||
unsigned int sampleRate; // Frequency (samples per second)
|
||||
unsigned int sampleSize; // Bit depth (bits per sample): 8, 16, 32 (24 not supported)
|
||||
|
|
@ -452,8 +402,7 @@ typedef struct Wave
|
|||
} Wave;
|
||||
|
||||
// Sound source type
|
||||
typedef struct Sound
|
||||
{
|
||||
typedef struct Sound {
|
||||
void *audioBuffer; // Pointer to internal data used by the audio system
|
||||
|
||||
unsigned int source; // Audio source id
|
||||
|
|
@ -467,8 +416,7 @@ typedef struct MusicData *Music;
|
|||
|
||||
// Audio stream type
|
||||
// NOTE: Useful to create custom audio streams not bound to a specific file
|
||||
typedef struct AudioStream
|
||||
{
|
||||
typedef struct AudioStream {
|
||||
unsigned int sampleRate; // Frequency (samples per second)
|
||||
unsigned int sampleSize; // Bit depth (bits per sample): 8, 16, 32 (24 not supported)
|
||||
unsigned int channels; // Number of channels (1-mono, 2-stereo)
|
||||
|
|
@ -481,8 +429,7 @@ typedef struct AudioStream
|
|||
} AudioStream;
|
||||
|
||||
// Head-Mounted-Display device parameters
|
||||
typedef struct VrDeviceInfo
|
||||
{
|
||||
typedef struct VrDeviceInfo {
|
||||
int hResolution; // HMD horizontal resolution in pixels
|
||||
int vResolution; // HMD vertical resolution in pixels
|
||||
float hScreenSize; // HMD horizontal size in meters
|
||||
|
|
@ -496,8 +443,7 @@ typedef struct VrDeviceInfo
|
|||
} VrDeviceInfo;
|
||||
|
||||
// VR Stereo rendering configuration for simulator
|
||||
typedef struct VrStereoConfig
|
||||
{
|
||||
typedef struct VrStereoConfig {
|
||||
RenderTexture2D stereoFbo; // VR stereo rendering framebuffer
|
||||
Shader distortionShader; // VR stereo rendering distortion shader
|
||||
Matrix eyesProjection[2]; // VR stereo rendering eyes projection matrices
|
||||
|
|
@ -506,35 +452,32 @@ typedef struct VrStereoConfig
|
|||
int eyeViewportLeft[4]; // VR stereo rendering left eye viewport [x, y, w, h]
|
||||
} VrStereoConfig;
|
||||
|
||||
|
||||
|
||||
// IPAddress definition (in network byte order)
|
||||
typedef struct IPAddress
|
||||
{
|
||||
typedef struct IPAddress {
|
||||
unsigned long host; /* 32-bit IPv4 host address */
|
||||
unsigned short port; /* 16-bit protocol port */
|
||||
} IPAddress;
|
||||
|
||||
// An option ID, value, sizeof(value) tuple for setsockopt(2).
|
||||
typedef struct SocketOpt
|
||||
{
|
||||
typedef struct SocketOpt {
|
||||
int id;
|
||||
void *value;
|
||||
int valueLen;
|
||||
} SocketOpt;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
SOCKET_TCP = 1, // SOCK_STREAM
|
||||
SOCKET_UDP = 2 // SOCK_DGRAM
|
||||
} SocketType;
|
||||
|
||||
typedef struct UDPChannel
|
||||
{
|
||||
typedef struct UDPChannel {
|
||||
int numbound; // The total number of addresses this channel is bound to
|
||||
IPAddress address[SOCKET_MAX_UDPADDRESSES]; // The list of remote addresses this channel is bound to
|
||||
} UDPChannel;
|
||||
|
||||
typedef struct Socket
|
||||
{
|
||||
typedef struct Socket {
|
||||
int ready; // Is the socket ready? i.e. has information
|
||||
int status; // The last status code to have occured using this socket
|
||||
bool isServer; // Is this socket a server socket (i.e. TCP/UDP Listen Server)
|
||||
|
|
@ -544,15 +487,13 @@ typedef struct Socket
|
|||
struct UDPChannel bindings[SOCKET_MAX_UDPCHANNELS]; // The amount of channels (if UDP) this socket is bound to
|
||||
} Socket;
|
||||
|
||||
typedef struct SocketSet
|
||||
{
|
||||
typedef struct SocketSet {
|
||||
int numsockets;
|
||||
int maxsockets;
|
||||
struct Socket **sockets;
|
||||
} SocketSet;
|
||||
|
||||
typedef struct SocketDataPacket
|
||||
{
|
||||
typedef struct SocketDataPacket {
|
||||
int channel; /* The src/dst channel of the packet */
|
||||
unsigned char *data; /* The packet data */
|
||||
int len; /* The length of the packet data */
|
||||
|
|
@ -564,8 +505,7 @@ typedef struct SocketDataPacket
|
|||
// Configuration for a socket. Not all of these fields need to
|
||||
// be set, and ones omitted from a C99-style "designated initializer"
|
||||
// struct literal will be zeroed out and replaced with defaults.
|
||||
typedef struct SocketConfig
|
||||
{
|
||||
typedef struct SocketConfig {
|
||||
// Hostname and port, for TCP or UDP sockets. */
|
||||
char * host; // The host address in xxx.xxx.xxx.xxx form
|
||||
char * port; // The target port/server in the form "http" or "25565"
|
||||
|
|
@ -577,15 +517,13 @@ typedef struct SocketConfig
|
|||
} SocketConfig;
|
||||
|
||||
// Result from calling open with a given config.
|
||||
typedef struct SocketResult
|
||||
{
|
||||
typedef struct SocketResult {
|
||||
int status;
|
||||
Socket *socket;
|
||||
} SocketResult;
|
||||
|
||||
//
|
||||
typedef struct Packet
|
||||
{
|
||||
typedef struct Packet {
|
||||
uint32_t size; // The total size of bytes in data
|
||||
uint32_t offs; // The offset to data access
|
||||
uint32_t maxs; // The max size of data
|
||||
|
|
@ -605,8 +543,7 @@ typedef struct _SocketAddressStorage *SocketAddressStorage;
|
|||
|
||||
// System config flags
|
||||
// NOTE: Used for bit masks
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
FLAG_SHOW_LOGO = 1, // Set to show raylib logo at startup
|
||||
FLAG_FULLSCREEN_MODE = 2, // Set to run program in fullscreen
|
||||
FLAG_WINDOW_RESIZABLE = 4, // Set to allow resizable window
|
||||
|
|
@ -618,8 +555,7 @@ typedef enum
|
|||
} ConfigFlag;
|
||||
|
||||
// Trace log type
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
LOG_ALL, // Display all logs
|
||||
LOG_TRACE,
|
||||
LOG_DEBUG,
|
||||
|
|
@ -631,8 +567,7 @@ typedef enum
|
|||
} TraceLogType;
|
||||
|
||||
// Keyboard keys
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
// Alphanumeric keys
|
||||
KEY_APOSTROPHE = 39,
|
||||
KEY_COMMA = 44,
|
||||
|
|
@ -746,8 +681,7 @@ typedef enum
|
|||
} KeyboardKey;
|
||||
|
||||
// Android buttons
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
KEY_BACK = 4,
|
||||
KEY_MENU = 82,
|
||||
KEY_VOLUME_UP = 24,
|
||||
|
|
@ -755,16 +689,14 @@ typedef enum
|
|||
} AndroidButton;
|
||||
|
||||
// Mouse buttons
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
MOUSE_LEFT_BUTTON = 0,
|
||||
MOUSE_RIGHT_BUTTON = 1,
|
||||
MOUSE_MIDDLE_BUTTON = 2
|
||||
} MouseButton;
|
||||
|
||||
// Gamepad number
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
GAMEPAD_PLAYER1 = 0,
|
||||
GAMEPAD_PLAYER2 = 1,
|
||||
GAMEPAD_PLAYER3 = 2,
|
||||
|
|
@ -774,8 +706,7 @@ typedef enum
|
|||
// PS3 USB Controller Buttons
|
||||
// TODO: Provide a generic way to list gamepad controls schemes,
|
||||
// defining specific controls schemes is not a good option
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
GAMEPAD_PS3_BUTTON_TRIANGLE = 0,
|
||||
GAMEPAD_PS3_BUTTON_CIRCLE = 1,
|
||||
GAMEPAD_PS3_BUTTON_CROSS = 2,
|
||||
|
|
@ -794,8 +725,7 @@ typedef enum
|
|||
} GamepadPS3Button;
|
||||
|
||||
// PS3 USB Controller Axis
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
GAMEPAD_PS3_AXIS_LEFT_X = 0,
|
||||
GAMEPAD_PS3_AXIS_LEFT_Y = 1,
|
||||
GAMEPAD_PS3_AXIS_RIGHT_X = 2,
|
||||
|
|
@ -805,8 +735,7 @@ typedef enum
|
|||
} GamepadPS3Axis;
|
||||
|
||||
// Xbox360 USB Controller Buttons
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
GAMEPAD_XBOX_BUTTON_A = 0,
|
||||
GAMEPAD_XBOX_BUTTON_B = 1,
|
||||
GAMEPAD_XBOX_BUTTON_X = 2,
|
||||
|
|
@ -824,8 +753,7 @@ typedef enum
|
|||
|
||||
// Xbox360 USB Controller Axis,
|
||||
// NOTE: For Raspberry Pi, axis must be reconfigured
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
GAMEPAD_XBOX_AXIS_LEFT_X = 0, // [-1..1] (left->right)
|
||||
GAMEPAD_XBOX_AXIS_LEFT_Y = 1, // [1..-1] (up->down)
|
||||
GAMEPAD_XBOX_AXIS_RIGHT_X = 2, // [-1..1] (left->right)
|
||||
|
|
@ -835,8 +763,7 @@ typedef enum
|
|||
} GamepadXbox360Axis;
|
||||
|
||||
// Android Gamepad Controller (SNES CLASSIC)
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
GAMEPAD_ANDROID_DPAD_UP = 19,
|
||||
GAMEPAD_ANDROID_DPAD_DOWN = 20,
|
||||
GAMEPAD_ANDROID_DPAD_LEFT = 21,
|
||||
|
|
@ -855,8 +782,7 @@ typedef enum
|
|||
} GamepadAndroid;
|
||||
|
||||
// Shader location point type
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
LOC_VERTEX_POSITION = 0,
|
||||
LOC_VERTEX_TEXCOORD01,
|
||||
LOC_VERTEX_TEXCOORD02,
|
||||
|
|
@ -888,8 +814,7 @@ typedef enum
|
|||
#define LOC_MAP_SPECULAR LOC_MAP_METALNESS
|
||||
|
||||
// Shader uniform data types
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
UNIFORM_FLOAT = 0,
|
||||
UNIFORM_VEC2,
|
||||
UNIFORM_VEC3,
|
||||
|
|
@ -902,8 +827,7 @@ typedef enum
|
|||
} ShaderUniformDataType;
|
||||
|
||||
// Material map type
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
MAP_ALBEDO = 0, // MAP_DIFFUSE
|
||||
MAP_METALNESS = 1, // MAP_SPECULAR
|
||||
MAP_NORMAL = 2,
|
||||
|
|
@ -922,8 +846,7 @@ typedef enum
|
|||
|
||||
// Pixel formats
|
||||
// NOTE: Support depends on OpenGL version and platform
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
UNCOMPRESSED_GRAYSCALE = 1, // 8 bit per pixel (no alpha)
|
||||
UNCOMPRESSED_GRAY_ALPHA, // 8*2 bpp (2 channels)
|
||||
UNCOMPRESSED_R5G6B5, // 16 bpp
|
||||
|
|
@ -950,8 +873,7 @@ typedef enum
|
|||
// Texture parameters: filter mode
|
||||
// NOTE 1: Filtering considers mipmaps if available in the texture
|
||||
// NOTE 2: Filter is accordingly set for minification and magnification
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
FILTER_POINT = 0, // No filter, just pixel aproximation
|
||||
FILTER_BILINEAR, // Linear filtering
|
||||
FILTER_TRILINEAR, // Trilinear filtering (linear with mipmaps)
|
||||
|
|
@ -961,8 +883,7 @@ typedef enum
|
|||
} TextureFilterMode;
|
||||
|
||||
// Cubemap layout type
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
CUBEMAP_AUTO_DETECT = 0, // Automatically detect layout type
|
||||
CUBEMAP_LINE_VERTICAL, // Layout is defined by a vertical line with faces
|
||||
CUBEMAP_LINE_HORIZONTAL, // Layout is defined by an horizontal line with faces
|
||||
|
|
@ -972,8 +893,7 @@ typedef enum
|
|||
} CubemapLayoutType;
|
||||
|
||||
// Texture parameters: wrap mode
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
WRAP_REPEAT = 0, // Repeats texture in tiled mode
|
||||
WRAP_CLAMP, // Clamps texture to edge pixel in tiled mode
|
||||
WRAP_MIRROR_REPEAT, // Mirrors and repeats the texture in tiled mode
|
||||
|
|
@ -981,16 +901,14 @@ typedef enum
|
|||
} TextureWrapMode;
|
||||
|
||||
// Font type, defines generation method
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
FONT_DEFAULT = 0, // Default font generation, anti-aliased
|
||||
FONT_BITMAP, // Bitmap font generation, no anti-aliasing
|
||||
FONT_SDF // SDF font generation, requires external shader
|
||||
} FontType;
|
||||
|
||||
// Color blending modes (pre-defined)
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
BLEND_ALPHA = 0, // Blend textures considering alpha (default)
|
||||
BLEND_ADDITIVE, // Blend textures adding colors
|
||||
BLEND_MULTIPLIED // Blend textures multiplying colors
|
||||
|
|
@ -998,8 +916,7 @@ typedef enum
|
|||
|
||||
// Gestures type
|
||||
// NOTE: It could be used as flags to enable only some gestures
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
GESTURE_NONE = 0,
|
||||
GESTURE_TAP = 1,
|
||||
GESTURE_DOUBLETAP = 2,
|
||||
|
|
@ -1014,8 +931,7 @@ typedef enum
|
|||
} GestureType;
|
||||
|
||||
// Camera system modes
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
CAMERA_CUSTOM = 0,
|
||||
CAMERA_FREE,
|
||||
CAMERA_ORBITAL,
|
||||
|
|
@ -1024,15 +940,13 @@ typedef enum
|
|||
} CameraMode;
|
||||
|
||||
// Camera projection modes
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
CAMERA_PERSPECTIVE = 0,
|
||||
CAMERA_ORTHOGRAPHIC
|
||||
} CameraType;
|
||||
|
||||
// Head Mounted Display devices
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
HMD_DEFAULT_DEVICE = 0,
|
||||
HMD_OCULUS_RIFT_DK2,
|
||||
HMD_OCULUS_RIFT_CV1,
|
||||
|
|
@ -1042,8 +956,7 @@ typedef enum
|
|||
} VrDeviceType;
|
||||
|
||||
// Type of n-patch
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
NPT_9PATCH = 0, // Npatch defined by 3x3 tiles
|
||||
NPT_3PATCH_VERTICAL, // Npatch defined by 1x3 tiles
|
||||
NPT_3PATCH_HORIZONTAL // Npatch defined by 3x1 tiles
|
||||
|
|
@ -1053,8 +966,7 @@ typedef enum
|
|||
typedef void (*TraceLogCallback)(int logType, const char *text, va_list args);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{ // Prevents name mangling of functions
|
||||
extern "C" { // Prevents name mangling of functions
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
|
|
@ -1072,6 +984,7 @@ extern "C"
|
|||
RLAPI void CloseWindow(void); // Close window and unload OpenGL context
|
||||
RLAPI bool IsWindowReady(void); // Check if window has been initialized successfully
|
||||
RLAPI bool IsWindowMinimized(void); // Check if window has been minimized (or lost focus)
|
||||
RLAPI bool IsWindowResized(void); // Check if window has been resized
|
||||
RLAPI bool IsWindowHidden(void); // Check if window is currently hidden
|
||||
RLAPI void ToggleFullscreen(void); // Toggle fullscreen mode (only PLATFORM_DESKTOP)
|
||||
RLAPI void UnhideWindow(void); // Show the window
|
||||
|
|
@ -1369,7 +1282,8 @@ extern "C"
|
|||
RLAPI void DrawText(const char *text, int posX, int posY, int fontSize, Color color); // Draw text (using default font)
|
||||
RLAPI void DrawTextEx(Font font, const char *text, Vector2 position, float fontSize, float spacing, Color tint); // Draw text using font and additional parameters
|
||||
RLAPI void DrawTextRec(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint); // Draw text using font inside rectangle limits
|
||||
RLAPI void DrawTextRecEx(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint, int selectStart, int selectLength, Color selectText, Color selectBack); // Draw text using font inside rectangle limits with support for text selection
|
||||
RLAPI void DrawTextRecEx(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint,
|
||||
int selectStart, int selectLength, Color selectText, Color selectBack); // Draw text using font inside rectangle limits with support for text selection
|
||||
|
||||
// Text misc. functions
|
||||
RLAPI int MeasureText(const char *text, int fontSize); // Measure string width for default font
|
||||
|
|
@ -1635,7 +1549,6 @@ extern "C"
|
|||
uint32_t PacketRead32(Packet *packet);
|
||||
uint64_t PacketRead64(Packet *packet);
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
36
src/rlgl.h
36
src/rlgl.h
|
|
@ -728,6 +728,8 @@ typedef struct DrawCall {
|
|||
//unsigned int vaoId; // Vertex Array id to be used on the draw
|
||||
//unsigned int shaderId; // Shader id to be used on the draw
|
||||
unsigned int textureId; // Texture id to be used on the draw
|
||||
// TODO: Support additional texture units?
|
||||
|
||||
//Matrix projection; // Projection matrix for this draw
|
||||
//Matrix modelview; // Modelview matrix for this draw
|
||||
} DrawCall;
|
||||
|
|
@ -2725,18 +2727,18 @@ void rlDrawMesh(Mesh mesh, Material material, Matrix transform)
|
|||
// Unload mesh data from CPU and GPU
|
||||
void rlUnloadMesh(Mesh *mesh)
|
||||
{
|
||||
if (mesh->vertices != NULL) free(mesh->vertices);
|
||||
if (mesh->texcoords != NULL) free(mesh->texcoords);
|
||||
if (mesh->normals != NULL) free(mesh->normals);
|
||||
if (mesh->colors != NULL) free(mesh->colors);
|
||||
if (mesh->tangents != NULL) free(mesh->tangents);
|
||||
if (mesh->texcoords2 != NULL) free(mesh->texcoords2);
|
||||
if (mesh->indices != NULL) free(mesh->indices);
|
||||
free(mesh->vertices);
|
||||
free(mesh->texcoords);
|
||||
free(mesh->normals);
|
||||
free(mesh->colors);
|
||||
free(mesh->tangents);
|
||||
free(mesh->texcoords2);
|
||||
free(mesh->indices);
|
||||
|
||||
if (mesh->baseVertices != NULL) free(mesh->baseVertices);
|
||||
if (mesh->baseNormals != NULL) free(mesh->baseNormals);
|
||||
if (mesh->weightBias != NULL) free(mesh->weightBias);
|
||||
if (mesh->weightId != NULL) free(mesh->weightId);
|
||||
free(mesh->baseVertices);
|
||||
free(mesh->baseNormals);
|
||||
free(mesh->weightBias);
|
||||
free(mesh->weightId);
|
||||
|
||||
rlDeleteBuffers(mesh->vboId[0]); // vertex
|
||||
rlDeleteBuffers(mesh->vboId[1]); // texcoords
|
||||
|
|
@ -4132,9 +4134,13 @@ static void DrawBuffersDefault(void)
|
|||
|
||||
glUniformMatrix4fv(currentShader.locs[LOC_MATRIX_MVP], 1, false, MatrixToFloat(matMVP));
|
||||
glUniform4f(currentShader.locs[LOC_COLOR_DIFFUSE], 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
glUniform1i(currentShader.locs[LOC_MAP_DIFFUSE], 0);
|
||||
glUniform1i(currentShader.locs[LOC_MAP_DIFFUSE], 0); // Provided value refers to the texture unit (active)
|
||||
|
||||
// NOTE: Additional map textures not considered for default buffers drawing
|
||||
// TODO: Support additional texture units on custom shader
|
||||
//if (currentShader->locs[LOC_MAP_SPECULAR] > 0) glUniform1i(currentShader.locs[LOC_MAP_SPECULAR], 1);
|
||||
//if (currentShader->locs[LOC_MAP_NORMAL] > 0) glUniform1i(currentShader.locs[LOC_MAP_NORMAL], 2);
|
||||
|
||||
// NOTE: Right now additional map textures not considered for default buffers drawing
|
||||
|
||||
int vertexOffset = 0;
|
||||
|
||||
|
|
@ -4165,6 +4171,10 @@ static void DrawBuffersDefault(void)
|
|||
{
|
||||
glBindTexture(GL_TEXTURE_2D, draws[i].textureId);
|
||||
|
||||
// TODO: Find some way to bind additional textures --> Use global texture IDs? Register them on draw[i]?
|
||||
//if (currentShader->locs[LOC_MAP_SPECULAR] > 0) { glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, textureUnit1_id); }
|
||||
//if (currentShader->locs[LOC_MAP_SPECULAR] > 0) { glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, textureUnit2_id); }
|
||||
|
||||
if ((draws[i].mode == RL_LINES) || (draws[i].mode == RL_TRIANGLES)) glDrawArrays(draws[i].mode, vertexOffset, draws[i].vertexCount);
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
*
|
||||
* DEPENDENCIES:
|
||||
* raylib.h - TraceLog
|
||||
* sysnet.h - platform-specific network includes
|
||||
* rnet.h - platform-specific network includes
|
||||
*
|
||||
* CONTRIBUTORS:
|
||||
* Jak Barnes (github: @syphonx) (Feb. 2019):
|
||||
|
|
@ -44,7 +44,7 @@
|
|||
# include <stdarg.h>
|
||||
#else
|
||||
# include "raylib.h"
|
||||
# include "sysnet.h"
|
||||
# include "rnet.h"
|
||||
# if !defined(EXTERNAL_CONFIG_FLAGS)
|
||||
# include "config.h" // Defines module configuration flags
|
||||
# endif
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/**********************************************************************************************
|
||||
*
|
||||
* sysnet - Provides cross-platform network defines, macros etc
|
||||
* rnet - Provides cross-platform network defines, macros etc
|
||||
*
|
||||
* DEPENDENCIES:
|
||||
* <limits.h> - Used for cross-platform type specifiers
|
||||
|
|
@ -688,7 +688,6 @@ void UnloadFont(Font font)
|
|||
{
|
||||
for (int i = 0; i < font.charsCount; i++)
|
||||
{
|
||||
if(font.chars[i].data != NULL)
|
||||
free(font.chars[i].data);
|
||||
}
|
||||
UnloadTexture(font.texture);
|
||||
|
|
@ -1327,13 +1326,11 @@ int TextToInteger(const char *text)
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module specific Functions Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
#if defined(SUPPORT_FILEFORMAT_FNT)
|
||||
// Load a BMFont file (AngelCode font file)
|
||||
static Font LoadBMFont(const char *fileName)
|
||||
|
|
|
|||
|
|
@ -353,7 +353,7 @@ Image LoadImageRaw(const char *fileName, int width, int height, int format, int
|
|||
{
|
||||
TraceLog(LOG_WARNING, "[%s] RAW image data can not be read, wrong requested format or size", fileName);
|
||||
|
||||
if (image.data != NULL) free(image.data);
|
||||
free(image.data);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -414,10 +414,7 @@ RenderTexture2D LoadRenderTexture(int width, int height)
|
|||
// Unload image from CPU memory (RAM)
|
||||
void UnloadImage(Image image)
|
||||
{
|
||||
if (image.data != NULL) free(image.data);
|
||||
|
||||
// NOTE: It becomes anoying every time a texture is loaded
|
||||
//TraceLog(LOG_INFO, "Unloaded image data");
|
||||
free(image.data);
|
||||
}
|
||||
|
||||
// Unload texture from GPU memory (VRAM)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user