mirror of
https://github.com/raylib-zig/raylib-zig.git
synced 2026-02-13 12:58:20 +00:00
Bump raylib to master (#283)
This commit is contained in:
parent
1e257d1738
commit
163b1ef2e9
@ -39,6 +39,7 @@ pub const rlRenderBatch = extern struct {
|
||||
};
|
||||
|
||||
pub const rlGlVersion = enum(c_int) {
|
||||
rl_opengl_11_software = 0,
|
||||
rl_opengl_11 = 1,
|
||||
rl_opengl_21 = 2,
|
||||
rl_opengl_33 = 3,
|
||||
|
||||
@ -226,6 +226,7 @@ pub extern "c" fn DrawLineV(startPos: rl.Vector2, endPos: rl.Vector2, color: rl.
|
||||
pub extern "c" fn DrawLineEx(startPos: rl.Vector2, endPos: rl.Vector2, thick: f32, color: rl.Color) void;
|
||||
pub extern "c" fn DrawLineStrip(points: [*c]const rl.Vector2, pointCount: c_int, color: rl.Color) void;
|
||||
pub extern "c" fn DrawLineBezier(startPos: rl.Vector2, endPos: rl.Vector2, thick: f32, color: rl.Color) void;
|
||||
pub extern "c" fn DrawLineDashed(startPos: rl.Vector2, endPos: rl.Vector2, dashSize: c_int, spaceSize: c_int, color: rl.Color) void;
|
||||
pub extern "c" fn DrawCircle(centerX: c_int, centerY: c_int, radius: f32, color: rl.Color) void;
|
||||
pub extern "c" fn DrawCircleSector(center: rl.Vector2, radius: f32, startAngle: f32, endAngle: f32, segments: c_int, color: rl.Color) void;
|
||||
pub extern "c" fn DrawCircleSectorLines(center: rl.Vector2, radius: f32, startAngle: f32, endAngle: f32, segments: c_int, color: rl.Color) void;
|
||||
|
||||
1
lib/raylib.h
vendored
1
lib/raylib.h
vendored
@ -1262,6 +1262,7 @@ RLAPI void DrawLineV(Vector2 startPos, Vector2 endPos, Color color);
|
||||
RLAPI void DrawLineEx(Vector2 startPos, Vector2 endPos, float thick, Color color); // Draw a line (using triangles/quads)
|
||||
RLAPI void DrawLineStrip(const Vector2 *points, int pointCount, Color color); // Draw lines sequence (using gl lines)
|
||||
RLAPI void DrawLineBezier(Vector2 startPos, Vector2 endPos, float thick, Color color); // Draw line segment cubic-bezier in-out interpolation
|
||||
RLAPI void DrawLineDashed(Vector2 startPos, Vector2 endPos, int dashSize, int spaceSize, Color color); // Draw a dashed line
|
||||
RLAPI void DrawCircle(int centerX, int centerY, float radius, Color color); // Draw a color-filled circle
|
||||
RLAPI void DrawCircleSector(Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color); // Draw a piece of a circle
|
||||
RLAPI void DrawCircleSectorLines(Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color); // Draw circle sector outline
|
||||
|
||||
@ -3665,6 +3665,11 @@ pub fn drawLineBezier(startPos: Vector2, endPos: Vector2, thick: f32, color: Col
|
||||
cdef.DrawLineBezier(startPos, endPos, thick, color);
|
||||
}
|
||||
|
||||
/// Draw a dashed line
|
||||
pub fn drawLineDashed(startPos: Vector2, endPos: Vector2, dashSize: i32, spaceSize: i32, color: Color) void {
|
||||
cdef.DrawLineDashed(startPos, endPos, @as(c_int, dashSize), @as(c_int, spaceSize), color);
|
||||
}
|
||||
|
||||
/// Draw a color-filled circle
|
||||
pub fn drawCircle(centerX: i32, centerY: i32, radius: f32, color: Color) void {
|
||||
cdef.DrawCircle(@as(c_int, centerX), @as(c_int, centerY), radius, color);
|
||||
|
||||
118
lib/raymath.h
vendored
118
lib/raymath.h
vendored
@ -2552,65 +2552,91 @@ RMAPI int QuaternionEquals(Quaternion p, Quaternion q)
|
||||
return result;
|
||||
}
|
||||
|
||||
// Decompose a transformation matrix into its rotational, translational and scaling components
|
||||
// Decompose a transformation matrix into its rotational, translational and scaling components and remove shear
|
||||
RMAPI void MatrixDecompose(Matrix mat, Vector3 *translation, Quaternion *rotation, Vector3 *scale)
|
||||
{
|
||||
// Extract translation.
|
||||
float eps = (float)1e-9;
|
||||
|
||||
// Extract Translation
|
||||
translation->x = mat.m12;
|
||||
translation->y = mat.m13;
|
||||
translation->z = mat.m14;
|
||||
|
||||
// Extract upper-left for determinant computation
|
||||
const float a = mat.m0;
|
||||
const float b = mat.m4;
|
||||
const float c = mat.m8;
|
||||
const float d = mat.m1;
|
||||
const float e = mat.m5;
|
||||
const float f = mat.m9;
|
||||
const float g = mat.m2;
|
||||
const float h = mat.m6;
|
||||
const float i = mat.m10;
|
||||
const float A = e*i - f*h;
|
||||
const float B = f*g - d*i;
|
||||
const float C = d*h - e*g;
|
||||
// Matrix Columns - Rotation will be extracted into here.
|
||||
Vector3 matColumns[3] = { { mat.m0, mat.m4, mat.m8 },
|
||||
{ mat.m1, mat.m5, mat.m9 },
|
||||
{ mat.m2, mat.m6, mat.m10 } };
|
||||
|
||||
// Extract scale
|
||||
const float det = a*A + b*B + c*C;
|
||||
Vector3 abc = { a, b, c };
|
||||
Vector3 def = { d, e, f };
|
||||
Vector3 ghi = { g, h, i };
|
||||
// Shear Parameters XY, XZ, and YZ (extract and ignored)
|
||||
float shear[3] = { 0 };
|
||||
|
||||
float scalex = Vector3Length(abc);
|
||||
float scaley = Vector3Length(def);
|
||||
float scalez = Vector3Length(ghi);
|
||||
Vector3 s = { scalex, scaley, scalez };
|
||||
// Normalized Scale Parameters
|
||||
Vector3 scl = { 0 };
|
||||
|
||||
if (det < 0) s = Vector3Negate(s);
|
||||
|
||||
*scale = s;
|
||||
|
||||
// Remove scale from the matrix if it is not close to zero
|
||||
Matrix clone = mat;
|
||||
if (!FloatEquals(det, 0))
|
||||
// Max-Normalizing helps numerical stability
|
||||
float stabilizer = eps;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
clone.m0 /= s.x;
|
||||
clone.m4 /= s.x;
|
||||
clone.m8 /= s.x;
|
||||
clone.m1 /= s.y;
|
||||
clone.m5 /= s.y;
|
||||
clone.m9 /= s.y;
|
||||
clone.m2 /= s.z;
|
||||
clone.m6 /= s.z;
|
||||
clone.m10 /= s.z;
|
||||
stabilizer = fmaxf(stabilizer, fabsf(matColumns[i].x));
|
||||
stabilizer = fmaxf(stabilizer, fabsf(matColumns[i].y));
|
||||
stabilizer = fmaxf(stabilizer, fabsf(matColumns[i].z));
|
||||
};
|
||||
matColumns[0] = Vector3Scale(matColumns[0], 1.0f / stabilizer);
|
||||
matColumns[1] = Vector3Scale(matColumns[1], 1.0f / stabilizer);
|
||||
matColumns[2] = Vector3Scale(matColumns[2], 1.0f / stabilizer);
|
||||
|
||||
// Extract rotation
|
||||
*rotation = QuaternionFromMatrix(clone);
|
||||
}
|
||||
else
|
||||
// X Scale
|
||||
scl.x = Vector3Length(matColumns[0]);
|
||||
if (scl.x > eps)
|
||||
{
|
||||
// Set to identity if close to zero
|
||||
*rotation = QuaternionIdentity();
|
||||
matColumns[0] = Vector3Scale(matColumns[0], 1.0f / scl.x);
|
||||
}
|
||||
|
||||
// Compute XY shear and make col2 orthogonal
|
||||
shear[0] = Vector3DotProduct(matColumns[0], matColumns[1]);
|
||||
matColumns[1] = Vector3Subtract(matColumns[1], Vector3Scale(matColumns[0], shear[0]));
|
||||
|
||||
// Y Scale
|
||||
scl.y = Vector3Length(matColumns[1]);
|
||||
if (scl.y > eps)
|
||||
{
|
||||
matColumns[1] = Vector3Scale(matColumns[1], 1.0f / scl.y);
|
||||
shear[0] /= scl.y; // Correct XY shear
|
||||
}
|
||||
|
||||
// Compute XZ and YZ shears and make col3 orthogonal
|
||||
shear[1] = Vector3DotProduct(matColumns[0], matColumns[2]);
|
||||
matColumns[2] = Vector3Subtract(matColumns[2], Vector3Scale(matColumns[0], shear[1]));
|
||||
shear[2] = Vector3DotProduct(matColumns[1], matColumns[2]);
|
||||
matColumns[2] = Vector3Subtract(matColumns[2], Vector3Scale(matColumns[1], shear[2]));
|
||||
|
||||
// Z Scale
|
||||
scl.z = Vector3Length(matColumns[2]);
|
||||
if (scl.z > eps)
|
||||
{
|
||||
matColumns[2] = Vector3Scale(matColumns[2], 1.0f / scl.z);
|
||||
shear[1] /= scl.z; // Correct XZ shear
|
||||
shear[2] /= scl.z; // Correct YZ shear
|
||||
}
|
||||
|
||||
// matColumns are now orthonormal in O(3). Now ensure its in SO(3) by enforcing det = 1.
|
||||
if (Vector3DotProduct(matColumns[0], Vector3CrossProduct(matColumns[1], matColumns[2])) < 0)
|
||||
{
|
||||
scl = Vector3Negate(scl);
|
||||
matColumns[0] = Vector3Negate(matColumns[0]);
|
||||
matColumns[1] = Vector3Negate(matColumns[1]);
|
||||
matColumns[2] = Vector3Negate(matColumns[2]);
|
||||
}
|
||||
|
||||
// Set Scale
|
||||
*scale = Vector3Scale(scl, stabilizer);
|
||||
|
||||
// Extract Rotation
|
||||
Matrix rotationMatrix = { matColumns[0].x, matColumns[0].y, matColumns[0].z, 0,
|
||||
matColumns[1].x, matColumns[1].y, matColumns[1].z, 0,
|
||||
matColumns[2].x, matColumns[2].y, matColumns[2].z, 0,
|
||||
0, 0, 0, 1 };
|
||||
*rotation = QuaternionFromMatrix(rotationMatrix);
|
||||
}
|
||||
|
||||
#if defined(__cplusplus) && !defined(RAYMATH_DISABLE_CPP_OPERATORS)
|
||||
|
||||
@ -67,6 +67,8 @@ pub extern "c" fn rlDisableScissorTest() void;
|
||||
pub extern "c" fn rlScissor(x: c_int, y: c_int, width: c_int, height: c_int) void;
|
||||
pub extern "c" fn rlEnablePointMode() void;
|
||||
pub extern "c" fn rlDisablePointMode() void;
|
||||
pub extern "c" fn rlSetPointSize(size: f32) void;
|
||||
pub extern "c" fn rlGetPointSize() f32;
|
||||
pub extern "c" fn rlEnableWireMode() void;
|
||||
pub extern "c" fn rlDisableWireMode() void;
|
||||
pub extern "c" fn rlSetLineWidth(width: f32) void;
|
||||
@ -129,6 +131,8 @@ pub extern "c" fn rlLoadFramebuffer() c_uint;
|
||||
pub extern "c" fn rlFramebufferAttach(fboId: c_uint, texId: c_uint, attachType: c_int, texType: c_int, mipLevel: c_int) void;
|
||||
pub extern "c" fn rlFramebufferComplete(id: c_uint) bool;
|
||||
pub extern "c" fn rlUnloadFramebuffer(id: c_uint) void;
|
||||
pub extern "c" fn rlCopyFramebuffer(x: c_int, y: c_int, width: c_int, height: c_int, format: c_int, pixels: *anyopaque) void;
|
||||
pub extern "c" fn rlResizeFramebuffer(width: c_int, height: c_int) void;
|
||||
pub extern "c" fn rlLoadShaderCode(vsCode: [*c]const u8, fsCode: [*c]const u8) c_uint;
|
||||
pub extern "c" fn rlCompileShader(shaderCode: [*c]const u8, ty: c_int) c_uint;
|
||||
pub extern "c" fn rlLoadShaderProgram(vShaderId: c_uint, fShaderId: c_uint) c_uint;
|
||||
|
||||
133
lib/rlgl.h
vendored
133
lib/rlgl.h
vendored
@ -149,7 +149,8 @@
|
||||
#endif
|
||||
|
||||
// Security check in case no GRAPHICS_API_OPENGL_* defined
|
||||
#if !defined(GRAPHICS_API_OPENGL_11) && \
|
||||
#if !defined(GRAPHICS_API_OPENGL_11_SOFTWARE) && \
|
||||
!defined(GRAPHICS_API_OPENGL_11) && \
|
||||
!defined(GRAPHICS_API_OPENGL_21) && \
|
||||
!defined(GRAPHICS_API_OPENGL_33) && \
|
||||
!defined(GRAPHICS_API_OPENGL_43) && \
|
||||
@ -159,7 +160,7 @@
|
||||
#endif
|
||||
|
||||
// Security check in case multiple GRAPHICS_API_OPENGL_* defined
|
||||
#if defined(GRAPHICS_API_OPENGL_11)
|
||||
#if defined(GRAPHICS_API_OPENGL_11) || defined(GRAPHICS_API_OPENGL_11_SOFTWARE)
|
||||
#if defined(GRAPHICS_API_OPENGL_21)
|
||||
#undef GRAPHICS_API_OPENGL_21
|
||||
#endif
|
||||
@ -174,6 +175,11 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Software implementation uses OpenGL 1.1 functionality
|
||||
#if defined(GRAPHICS_API_OPENGL_11_SOFTWARE)
|
||||
#define GRAPHICS_API_OPENGL_11
|
||||
#endif
|
||||
|
||||
// OpenGL 2.1 uses most of OpenGL 3.3 Core functionality
|
||||
// WARNING: Specific parts are checked with #if defines
|
||||
#if defined(GRAPHICS_API_OPENGL_21)
|
||||
@ -427,7 +433,8 @@ typedef struct rlRenderBatch {
|
||||
|
||||
// OpenGL version
|
||||
typedef enum {
|
||||
RL_OPENGL_11 = 1, // OpenGL 1.1
|
||||
RL_OPENGL_11_SOFTWARE = 0, // Software rendering
|
||||
RL_OPENGL_11, // OpenGL 1.1
|
||||
RL_OPENGL_21, // OpenGL 2.1 (GLSL 120)
|
||||
RL_OPENGL_33, // OpenGL 3.3 (GLSL 330)
|
||||
RL_OPENGL_43, // OpenGL 4.3 (using GLSL 330)
|
||||
@ -644,10 +651,8 @@ RLAPI void rlEnableVertexBufferElement(unsigned int id); // Enable vertex buffer
|
||||
RLAPI void rlDisableVertexBufferElement(void); // Disable vertex buffer element (VBO element)
|
||||
RLAPI void rlEnableVertexAttribute(unsigned int index); // Enable vertex attribute index
|
||||
RLAPI void rlDisableVertexAttribute(unsigned int index); // Disable vertex attribute index
|
||||
#if defined(GRAPHICS_API_OPENGL_11)
|
||||
RLAPI void rlEnableStatePointer(int vertexAttribType, void *buffer); // Enable attribute state pointer
|
||||
RLAPI void rlDisableStatePointer(int vertexAttribType); // Disable attribute state pointer
|
||||
#endif
|
||||
|
||||
// Textures state
|
||||
RLAPI void rlActiveTextureSlot(int slot); // Select and active a texture slot
|
||||
@ -686,6 +691,8 @@ RLAPI void rlDisableScissorTest(void); // Disable scissor test
|
||||
RLAPI void rlScissor(int x, int y, int width, int height); // Scissor test
|
||||
RLAPI void rlEnablePointMode(void); // Enable point mode
|
||||
RLAPI void rlDisablePointMode(void); // Disable point mode
|
||||
RLAPI void rlSetPointSize(float size); // Set the point drawing size
|
||||
RLAPI float rlGetPointSize(void); // Get the point drawing size
|
||||
RLAPI void rlEnableWireMode(void); // Enable wire mode
|
||||
RLAPI void rlDisableWireMode(void); // Disable wire mode
|
||||
RLAPI void rlSetLineWidth(float width); // Set the line drawing width
|
||||
@ -768,6 +775,10 @@ RLAPI unsigned int rlLoadFramebuffer(void); // Loa
|
||||
RLAPI void rlFramebufferAttach(unsigned int fboId, unsigned int texId, int attachType, int texType, int mipLevel); // Attach texture/renderbuffer to a framebuffer
|
||||
RLAPI bool rlFramebufferComplete(unsigned int id); // Verify framebuffer is complete
|
||||
RLAPI void rlUnloadFramebuffer(unsigned int id); // Delete framebuffer from GPU
|
||||
#if defined(GRAPHICS_API_OPENGL_11_SOFTWARE)
|
||||
RLAPI void rlCopyFramebuffer(int x, int y, int width, int height, int format, void *pixels); // Copy framebuffer pixel data to internal buffer
|
||||
RLAPI void rlResizeFramebuffer(int width, int height); // Resize internal framebuffer
|
||||
#endif
|
||||
|
||||
// Shaders management
|
||||
RLAPI unsigned int rlLoadShaderCode(const char *vsCode, const char *fsCode); // Load shader from code strings
|
||||
@ -834,24 +845,32 @@ RLAPI void rlLoadDrawQuad(void); // Load and draw a quad
|
||||
#endif
|
||||
|
||||
#if defined(GRAPHICS_API_OPENGL_11)
|
||||
#if defined(__APPLE__)
|
||||
#include <OpenGL/gl.h> // OpenGL 1.1 library for OSX
|
||||
#include <OpenGL/glext.h> // OpenGL extensions library
|
||||
#if defined(GRAPHICS_API_OPENGL_11_SOFTWARE)
|
||||
#define RLSW_IMPLEMENTATION
|
||||
#define SW_MALLOC(sz) RL_MALLOC(sz)
|
||||
#define SW_REALLOC(ptr, newSz) RL_REALLOC(ptr, newSz)
|
||||
#define SW_FREE(ptr) RL_FREE(ptr)
|
||||
#include "external/rlsw.h" // OpenGL 1.1 software implementation
|
||||
#else
|
||||
// APIENTRY for OpenGL function pointer declarations is required
|
||||
#if !defined(APIENTRY)
|
||||
#if defined(_WIN32)
|
||||
#define APIENTRY __stdcall
|
||||
#else
|
||||
#define APIENTRY
|
||||
#if defined(__APPLE__)
|
||||
#include <OpenGL/gl.h> // OpenGL 1.1 library for OSX
|
||||
#include <OpenGL/glext.h> // OpenGL extensions library
|
||||
#else
|
||||
// APIENTRY for OpenGL function pointer declarations is required
|
||||
#if !defined(APIENTRY)
|
||||
#if defined(_WIN32)
|
||||
#define APIENTRY __stdcall
|
||||
#else
|
||||
#define APIENTRY
|
||||
#endif
|
||||
#endif
|
||||
// WINGDIAPI definition. Some Windows OpenGL headers need it
|
||||
#if !defined(WINGDIAPI) && defined(_WIN32)
|
||||
#define WINGDIAPI __declspec(dllimport)
|
||||
#endif
|
||||
#endif
|
||||
// WINGDIAPI definition. Some Windows OpenGL headers need it
|
||||
#if !defined(WINGDIAPI) && defined(_WIN32)
|
||||
#define WINGDIAPI __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
#include <GL/gl.h> // OpenGL 1.1 library
|
||||
#include <GL/gl.h> // OpenGL 1.1 library
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -1067,6 +1086,7 @@ typedef struct rlglData {
|
||||
Matrix stack[RL_MAX_MATRIX_STACK_SIZE];// Matrix stack for push/pop
|
||||
int stackCounter; // Matrix stack counter
|
||||
|
||||
unsigned int currentTextureId; // Current texture id to be used on glBegin
|
||||
unsigned int defaultTextureId; // Default texture used on shapes/poly drawing (required by shader)
|
||||
unsigned int activeTextureId[RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS]; // Active texture ids to be enabled on batch drawing (0 active by default)
|
||||
unsigned int defaultVShaderId; // Default vertex shader id (used by default shader program)
|
||||
@ -1485,8 +1505,8 @@ void rlBegin(int mode)
|
||||
if (RLGL.currentBatch->drawCounter >= RL_DEFAULT_BATCH_DRAWCALLS) rlDrawRenderBatch(RLGL.currentBatch);
|
||||
|
||||
RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode = mode;
|
||||
RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount = 0;
|
||||
RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].textureId = RLGL.State.defaultTextureId;
|
||||
RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].textureId = RLGL.State.currentTextureId;
|
||||
RLGL.State.currentTextureId = RLGL.State.defaultTextureId;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1651,6 +1671,7 @@ void rlSetTexture(unsigned int id)
|
||||
{
|
||||
rlDrawRenderBatch(RLGL.currentBatch);
|
||||
}
|
||||
RLGL.State.currentTextureId = RLGL.State.defaultTextureId;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
@ -1658,6 +1679,7 @@ void rlSetTexture(unsigned int id)
|
||||
#if defined(GRAPHICS_API_OPENGL_11)
|
||||
rlEnableTexture(id);
|
||||
#else
|
||||
RLGL.State.currentTextureId = id;
|
||||
if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].textureId != id)
|
||||
{
|
||||
if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount > 0)
|
||||
@ -1676,6 +1698,9 @@ void rlSetTexture(unsigned int id)
|
||||
RLGL.State.vertexCounter += RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment;
|
||||
|
||||
RLGL.currentBatch->drawCounter++;
|
||||
|
||||
RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode = RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 2].mode;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -2010,6 +2035,25 @@ float rlGetLineWidth(void)
|
||||
return width;
|
||||
}
|
||||
|
||||
// Set the point drawing size
|
||||
void rlSetPointSize(float size)
|
||||
{
|
||||
#if defined(GRAPHICS_API_OPENGL_11)
|
||||
glPointSize(size);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Get the point drawing size
|
||||
float rlGetPointSize(void)
|
||||
{
|
||||
float size = 1;
|
||||
#if defined(GRAPHICS_API_OPENGL_11)
|
||||
glGetFloatv(GL_POINT_SIZE, &size);
|
||||
#endif
|
||||
return size;
|
||||
|
||||
}
|
||||
|
||||
// Enable line aliasing
|
||||
void rlEnableSmoothLines(void)
|
||||
{
|
||||
@ -2257,6 +2301,7 @@ void rlglInit(int width, int height)
|
||||
// Init default white texture
|
||||
unsigned char pixels[4] = { 255, 255, 255, 255 }; // 1 pixel RGBA (4 bytes)
|
||||
RLGL.State.defaultTextureId = rlLoadTexture(pixels, 1, 1, RL_PIXELFORMAT_UNCOMPRESSED_R8G8B8A8, 1);
|
||||
RLGL.State.currentTextureId = RLGL.State.defaultTextureId;
|
||||
|
||||
if (RLGL.State.defaultTextureId != 0) TRACELOG(RL_LOG_INFO, "TEXTURE: [ID %i] Default texture loaded successfully", RLGL.State.defaultTextureId);
|
||||
else TRACELOG(RL_LOG_WARNING, "TEXTURE: Failed to load default texture");
|
||||
@ -2311,6 +2356,15 @@ void rlglInit(int width, int height)
|
||||
glShadeModel(GL_SMOOTH); // Smooth shading between vertex (vertex colors interpolation)
|
||||
#endif
|
||||
|
||||
#if defined(GRAPHICS_API_OPENGL_11_SOFTWARE)
|
||||
int result = swInit(width, height); // Initialize software renderer backend
|
||||
if (result == 0)
|
||||
{
|
||||
TRACELOG(RL_LOG_ERROR, "RLSW: Software renderer initialization failed!");
|
||||
exit(-1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
|
||||
// Store screen size into global variables
|
||||
RLGL.State.framebufferWidth = width;
|
||||
@ -2332,11 +2386,15 @@ void rlglClose(void)
|
||||
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
|
||||
rlUnloadRenderBatch(RLGL.defaultBatch);
|
||||
|
||||
rlUnloadShaderDefault(); // Unload default shader
|
||||
rlUnloadShaderDefault(); // Unload default shader
|
||||
|
||||
glDeleteTextures(1, &RLGL.State.defaultTextureId); // Unload default texture
|
||||
TRACELOG(RL_LOG_INFO, "TEXTURE: [ID %i] Default texture unloaded successfully", RLGL.State.defaultTextureId);
|
||||
#endif
|
||||
|
||||
#if defined(GRAPHICS_API_OPENGL_11_SOFTWARE)
|
||||
swClose(); // Unload sofware renderer resources
|
||||
#endif
|
||||
}
|
||||
|
||||
// Load OpenGL extensions
|
||||
@ -2646,7 +2704,10 @@ void *rlGetProcAddress(const char *procName)
|
||||
int rlGetVersion(void)
|
||||
{
|
||||
int glVersion = 0;
|
||||
#if defined(GRAPHICS_API_OPENGL_11)
|
||||
|
||||
#if defined(GRAPHICS_API_OPENGL_11_SOFTWARE)
|
||||
glVersion = RL_OPENGL_11_SOFTWARE;
|
||||
#elif defined(GRAPHICS_API_OPENGL_11)
|
||||
glVersion = RL_OPENGL_11;
|
||||
#endif
|
||||
#if defined(GRAPHICS_API_OPENGL_21)
|
||||
@ -3687,6 +3748,22 @@ void *rlReadTexturePixels(unsigned int id, int width, int height, int format)
|
||||
return pixels;
|
||||
}
|
||||
|
||||
#if defined(GRAPHICS_API_OPENGL_11_SOFTWARE)
|
||||
// Copy framebuffer pixel data to internal buffer
|
||||
void rlCopyFramebuffer(int x, int y, int width, int height, int format, void* pixels)
|
||||
{
|
||||
unsigned int glInternalFormat, glFormat, glType;
|
||||
rlGetGlTextureFormats(format, &glInternalFormat, &glFormat, &glType); // Get OpenGL texture format
|
||||
swCopyFramebuffer(x, y, width, height, glFormat, glType, pixels);
|
||||
}
|
||||
|
||||
// Resize internal framebuffer
|
||||
void rlResizeFramebuffer(int width, int height)
|
||||
{
|
||||
swResizeFramebuffer(width, height);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Read screen pixel data (color buffer)
|
||||
unsigned char *rlReadScreenPixels(int width, int height)
|
||||
{
|
||||
@ -3996,10 +4073,10 @@ void rlDrawVertexArrayElementsInstanced(int offset, int count, const void *buffe
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(GRAPHICS_API_OPENGL_11)
|
||||
// Enable vertex state pointer
|
||||
void rlEnableStatePointer(int vertexAttribType, void *buffer)
|
||||
{
|
||||
#if defined(GRAPHICS_API_OPENGL_11)
|
||||
if (buffer != NULL) glEnableClientState(vertexAttribType);
|
||||
switch (vertexAttribType)
|
||||
{
|
||||
@ -4010,14 +4087,16 @@ void rlEnableStatePointer(int vertexAttribType, void *buffer)
|
||||
//case GL_INDEX_ARRAY: if (buffer != NULL) glIndexPointer(GL_SHORT, 0, buffer); break; // Indexed colors
|
||||
default: break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// Disable vertex state pointer
|
||||
void rlDisableStatePointer(int vertexAttribType)
|
||||
{
|
||||
#if defined(GRAPHICS_API_OPENGL_11)
|
||||
glDisableClientState(vertexAttribType);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// Load vertex array object (VAO)
|
||||
unsigned int rlLoadVertexArray(void)
|
||||
@ -5285,4 +5364,4 @@ static Matrix rlMatrixInvert(Matrix mat)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // RLGL_IMPLEMENTATION
|
||||
#endif // RLGL_IMPLEMENTATION
|
||||
21
lib/rlgl.zig
21
lib/rlgl.zig
@ -39,6 +39,7 @@ pub const rlRenderBatch = extern struct {
|
||||
};
|
||||
|
||||
pub const rlGlVersion = enum(c_int) {
|
||||
rl_opengl_11_software = 0,
|
||||
rl_opengl_11 = 1,
|
||||
rl_opengl_21 = 2,
|
||||
rl_opengl_33 = 3,
|
||||
@ -589,6 +590,16 @@ pub fn rlDisablePointMode() void {
|
||||
cdef.rlDisablePointMode();
|
||||
}
|
||||
|
||||
/// Set the point drawing size
|
||||
pub fn rlSetPointSize(size: f32) void {
|
||||
cdef.rlSetPointSize(size);
|
||||
}
|
||||
|
||||
/// Get the point drawing size
|
||||
pub fn rlGetPointSize() f32 {
|
||||
return cdef.rlGetPointSize();
|
||||
}
|
||||
|
||||
/// Enable wire mode
|
||||
pub fn rlEnableWireMode() void {
|
||||
cdef.rlEnableWireMode();
|
||||
@ -899,6 +910,16 @@ pub fn rlUnloadFramebuffer(id: u32) void {
|
||||
cdef.rlUnloadFramebuffer(@as(c_uint, id));
|
||||
}
|
||||
|
||||
/// Copy framebuffer pixel data to internal buffer
|
||||
pub fn rlCopyFramebuffer(x: i32, y: i32, width: i32, height: i32, format: i32, pixels: *anyopaque) void {
|
||||
cdef.rlCopyFramebuffer(@as(c_int, x), @as(c_int, y), @as(c_int, width), @as(c_int, height), @as(c_int, format), pixels);
|
||||
}
|
||||
|
||||
/// Resize internal framebuffer
|
||||
pub fn rlResizeFramebuffer(width: i32, height: i32) void {
|
||||
cdef.rlResizeFramebuffer(@as(c_int, width), @as(c_int, height));
|
||||
}
|
||||
|
||||
/// Load shader from code strings
|
||||
pub fn rlLoadShaderCode(vsCode: [:0]const u8, fsCode: [:0]const u8) u32 {
|
||||
return @as(u32, cdef.rlLoadShaderCode(@as([*c]const u8, @ptrCast(vsCode)), @as([*c]const u8, @ptrCast(fsCode))));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user