Commit Graph

658 Commits

Author SHA1 Message Date
Ray
3adfde42f7 REVIEWED: rlLoadTeexture(), max mipmap levels to use #5400 2025-12-10 09:21:33 +01:00
Ray
47a8b554bc **NEW**: PLATFORM_MEMORY backend
New platform backend for software rendering directly on RAM memory buffer
2025-11-24 15:38:58 +01:00
Ray
e1b9857b14 Some TODOs and format reviews 2025-11-23 21:40:39 +01:00
3f92c396a0 Fixed typo (#5364) 2025-11-19 08:56:32 +01:00
Ray
78870335e6 Update rlgl.h 2025-10-28 19:55:35 +01:00
Ray
1664204291 REVIEWED: New Win32 platform backend to accomodate rlsw Software Renderer 2025-10-20 19:10:41 +02:00
Ray
9ed785c2e1 Update rlgl.h 2025-10-17 10:04:21 +02:00
Ray
601ff4f02e REVIEW: Naming tweaks and comments added #5271 2025-10-17 09:54:49 +02:00
Ray
18e4d1d44f Reviewed formating 2025-10-15 19:20:11 +02:00
Ray
0e57a572b4 REVIEWED: rlsw module and related files 2025-09-29 18:05:07 +02:00
584bc14929 [rlgl] Add Software Rendering Support (#4832)
* add base of rlsw.h

* implement state support
Also replace the triangle rasterization functions with macros that generate specific functions for each state of the rendering system.
Also, add the OpenGL definitions in order to add a binding for rlgl.

* branchless float saturation

* apply perspective correction to colors

* impl line clipping and rasterization
+ tweak function names

* impl face culling

* impl color blending

* fixes and tweaks

* add clear buffer bitmasks

* small optimizations / tweaks

* review ndc to screen projection

* avoid to recalculate MVP when its not needed + tweaks

* review the loading and management of textures
to be closer to the OpenGL API

* texture sampling optimization

* review get pixel functions
+ review unorm/float conversion

* add several buffer format support
Several depth and color formats have been added for the framebuffer.

8-bit, 16-bit, and 24-bit formats are now available for depth.

RGB 8-bit (332), RGB 16-bit (565), and RGB 24-bit (888) formats are now available for color.

Alpha support is no longer present for the framebuffer at the moment, but it can easily be restored by adding the formats and reinterpolating the alpha in the areas that do not perform color blending.

Additionally, this commit brings performance improvements.

* tweaks

* impl line width

* impl points + point size

* fix and improve polygon clipping functions

* impl polygone modes

* add some not planned functions
- `glDepthMask`
- `glColorMask`

* framebuffer resizing + handle init failure

* add quick notes about line clipping algorithms used

* start to impl scissor test + review line clipping
The support for the scissor test has been implemented for clearing as well as for triangle clipping.
The implementation for lines and points is still missing.

I also removed the 2D clipping of lines that used the Cohen-Sutherland algorithm, opting instead to always use the Liang-Barsky algorithm in all cases.
This simplifies the implementation, and the 2D version would have caused issues when interpolating vertices in the future if we want to implement additional features.

* review scissor clear

* review `swScissor`

* impl line scissor clipping

* round screen coordinate (line rasterization)

* impl point scissor clipping

* remove unused defs

* add getter functions

* gl binding

* add `glHint` and `glShadeModel` macros (not implmented)

* binding tweaks

* impl copy framebuffer function + glReadPixels

* review `swCopyFramebuffer`

* update rlgl.h

* update rlgl.h

* texture copy support

* fix typo..

* add get error function

* def sw alloc macros

* reimpl get color buffer func
just in case

* remove normal interpolation

* review texture wrap

* fix ndc projection (viewport/scissor)

* impl framebuffer blit function

* reduce matrix compuations and memory usage

* swBegin tweaks

* preventing a possible division by zero

* remove useless scissor related data

* review color blending system

* greatly improve float saturation

* tweak lerp vertex function

* use opitmized fract function in sw_texture_map

* tweak framebuffer functions for better readability

* optimized copy/blit functions for each dst format

* review framebuffer filling functions

* impl specific quad rendering func

* use of a single global vertex buffer

* fix 'sw_poly_point_render'

* added `SW_RESTRICT` and redesigned `sw_lerp_vertex_PNCTH`

* tweak the pipeline flow regarding the face culling
avoids misprediction, improves vectorization if possible

* new rendering path for axis aligned quads

* oops, translating some comments

* use of `restrict` for blending function parameters

* update rlgl.h

* adding `GRAPHICS_API_OPENGL_11_SOFTWARE` in `DrawMesh`

* add `RL_OPENGL_11_SOFTWARE` enum

* temp tweak

* build fixes

* fix DrawMesh for GL 1.1

* update swClose

* review texture format + fix copy

* set minimum req vertices to 3 (quads)

* check swInit

* review pixelformat

* tweaks

* fix animNormals (DrawMesh)

* fallback color/texcoord (swDrawArrays)

* review swMultMatrixf

* fix texture pool alloc..

* review triangle scanlines
increment all data

* fix `sw_quad_sort_cw`

* impl sdl platform

* rm def

* increase max clipped polygon vertices

* improve triangle rasterization along Y axis
improved robustness against numerical errors
incremental interpolation along Y
simplified function, fewer jumps

* review current vertex data
+ increase max clipped polygon vertices (for extreme cases)

* fix and improve polygon clipping
Sets the vertex count to zero when the polygon is invalid
Stops clipping when the vertex count drops below 3

* fix gradient calculation

* cache texture size minus one + comments

* tweaks

* BGRA copy support

* adding software backend option (cmake)

* update Makefile

* fix face culling

* excluse some exemple with the software backend

* review SW_CLAMP case in sw_texture_map

* review sw_saturate

* review line raster

* fix sw_quad_is_aligned

* review sw_raster_quad_axis_aligned

* tweaks

* codepoint fix (?)

* fix var name...

* rcore_drm software renderering

* cleanup and tweaks

* adding support for `GL_POINT_SIZE` and `GL_LINE_WIDTH` get

* fix sampling issue

* fix swBlendFunc

---------

Co-authored-by: Ray <raysan5@gmail.com>
2025-09-29 10:28:20 +02:00
f36c8ddc56 [rlgl] Allow tint colors in GL_LINE (wires) and GL_POINT (points) draw modes on OpenGL 1.1 clean (#5207)
* gate with OPENGL_11 prototype and definition for rlSetPointSize and rlGetPointSize

* gate with OPENGL_11 prototype and definition for rlSetPointSize and rlGetPointSize

* more coverage for fixing expected texcoords, normals, and colors

* fix guard styling

* fix guard issue, and remove fallback unneccessary else clause (default shader ill work)

* opengl3.3 and es2 need the color array allocated in order to allow for updates later (unlike opengl11)
2025-09-28 19:34:38 +02:00
2554dcba9b fix rlSetTexture not overriding default mode (#5200) 2025-09-24 10:22:03 +02:00
Ray
bd6065a4fd Update rlgl.h 2025-09-18 15:29:13 +02:00
Ray
d0c39db6c2 Update rlgl.h 2025-09-12 13:02:13 +02:00
Ray
5a54fc12a2 REVIEWED: Prioritize calloc() calls than malloc() on some cases 2025-09-10 21:03:06 +02:00
Ray
8f32c502a7 REVIEWED: Code sections definition 2025-09-02 12:10:40 +02:00
4a4997c615 fix unnecessary warnings in some files (#5152) 2025-08-28 22:28:56 +02:00
Ray
a9970484f3 Remove trailing spaces 2025-08-14 20:37:18 +02:00
Ray
095319602c REVIEWED: Compule for OpenGL 1.1 #5088 2025-08-06 13:09:56 +02:00
d6a897e551 [rlgl]: Add rlGetProcAddress 2025-07-23 21:41:45 +03:00
901afadbf1 fix warning log macro in rlgl 2025-07-14 15:36:02 +02:00
Ray
b677376088 Delete shader in case compilation fails 2025-06-22 23:52:34 +02:00
Ray
3e336e4470 Reviewed warning 2025-06-11 19:52:35 +02:00
Ray
59bcf680aa Code gardening... 2025-06-07 20:14:24 +02:00
Ray
21f0fe2a73 Removed some spaces 2025-05-21 19:06:04 +02:00
461c9c9d90 review tabs 2025-04-22 15:02:09 +02:00
a7333a9dae review near/far 2025-04-22 15:00:54 +02:00
Ray
3d83c1c796 Format tweak 2025-03-25 19:27:55 +01:00
Ray
63e608d485 comment tweak 2025-03-24 15:07:36 +01:00
Ray
46cd07d2c7 WARNING: REVERTED CHANGE THAT BROKE BATCHING!!! #4849
I'm sorry... I did not detect this change was breaking batching... :(
2025-03-21 17:17:45 +01:00
Ray
cb830bed72 Increased depth size and clip distances to avoid z-fighting issues 2025-03-13 16:34:39 +01:00
Ray
bd8e59f18d Replace size_t by unsigned int 2025-03-10 17:07:18 +01:00
Ray
4c8c72778d Remove trailing spaces 2025-03-10 17:04:29 +01:00
Ray
da8a08006a Added some comments on latest change 2025-02-25 12:46:06 +01:00
27af359d1c [rlgl] Preserve texture on mode switching (#4364)
* Fix textures on draw mode switch

* formatting fix

* ident
2025-02-25 12:39:00 +01:00
Ray
a979b10966 Minor format tweak 2025-02-25 11:43:22 +01:00
Ray
313067d749 Update rlgl.h 2025-01-16 19:47:21 +01:00
5d9aed5d40 [rlgl] Optimize rlReadScreenPixels (#4667)
This optimization works in the following ways:

1. Reduces calls to malloc to 1. Instead of needing an extra array, we
can just swap the top half with the bottom half of the one array.

2. Unroll the inner for loop and remove a condition. Unrolling loops
buys some performance wins, but the real goal was to remove the if check
and just set the alpha channel to 255.

On my hidpi arm64 laptop, I saw ~60% improvement in performance in my
debug build (29 FPS vs 47 FPS). When optimized, the gains were roughly
10% (75 FPS vs 83%).

Signed-off-by: K. Adam Christensen <pope@shifteleven.com>
2025-01-08 18:53:27 +01:00
05c4d8a652 [rlgl.h] Fixed typo in top comment (#4658)
"renderer" to "rendered"
2025-01-05 12:29:31 +01:00
Ray
fa0eada61a Update year to 2025 2025-01-01 00:02:52 +01:00
0212ed0a4b setting MAX_LEVEL based on actual mipcount input (#4622) 2024-12-20 14:14:13 +01:00
79facde353 fix rlActiveDrawBuffers for OpenGL ES 3 (#4605) 2024-12-16 00:51:42 +01:00
d2cd2a0152 [rlgl][rmodels] Add instranceTransform shader location index #4538 (#4579) 2024-12-08 12:48:54 +01:00
ff71e3a513 use unused variable. Fixes #4560 (#4561) 2024-12-01 23:22:46 +01:00
Ray
26548c1062 Remove trail-spaces 2024-11-19 12:33:13 +01:00
Ray
10789a4d49 Update rlgl.h 2024-11-19 12:31:14 +01:00
0e1fc33c5c Fix signed/unsigned mismatch in rlgl (#4443) 2024-10-26 22:59:50 +02:00
Ray
1f6b3384fa Reviewed formatting, remove end-line points, for consistency with comments 2024-10-26 12:26:00 +02:00
Ray
80b490c8f1 Reviewed formating to follow raylib conventions #4429 2024-10-26 12:15:06 +02:00