Commit graph

61 commits

Author SHA1 Message Date
Vincent Pelletier
f8c72b5967 TINYGL: Move texture resampling from create time to render time
Thanks to pixel repacking using cpu data cache, this has a low runtime
cost even for TGL_LINEAR.
Adds support for TGL_NEAREST.
Adds support for TGL_MIRRORED_REPEAT, TGL_CLAMP_TO_EDGE and TGL_REPEAT.
Also, add support for more texture clamping and resampling options.

Mipmaps are not supported, although their sampling modes will be
applied - but to the full-size texture instead of selected mipmap.

Note: Texture sampler is still chosen at texture creation time.
2020-11-12 08:15:39 +01:00
Vincent Pelletier
bcd1066540 TINYGL: Move initialisation code outside of loop
Readability-only change.
Clarifies that these variables will be initialised before they get
accessed in the loop.
Also, initialise update_left and update_right to true, and only clear the
one needed for given triangle.
2017-07-20 01:56:35 +00:00
Vincent Pelletier
218d3214d7 TINYGL: Move remaining line counter decrement near y increment
Readability-only change.
Both represent the same notion, and nb_lines is only accessed as loop
condition.
2017-07-20 01:53:34 +00:00
Vincent Pelletier
290d6a3b6d TINYGL: Initialise a1 in fillTriangleFlat code path
fillTriangleFlat has kDrawLogic == DRAW_FLAT and interpRGB == false,
causing this variable to be used uninitialised.
Found by removing default values on all locals.
2017-05-02 09:42:06 +00:00
Vincent Pelletier
054a2bd920 TINYGL: Fix line color
As in ztriangle, vertex color must be shifted from internal 16-bits
fixed-point format to 8-bits colors.
To do so, define values similar to the ones describing for ST fixed-point
format.
Also, use these in tglClear instead of hard-coded multiplicands, as is
done in tglColor4f and gl_transform_to_viewport.
Also, make tglClear take into account requested clear depth.
2017-05-01 02:21:40 +00:00
Vincent Pelletier
cc42d5cb24 TINYGL: Fix scissor testing in ztriangle.
When dirty rectangles are enabled, fixes drawing outside (below) set scissor
rectangle.
y and pp1 must stay consistent for scissor testing to be relevant. y is
already incremented along with pp1, and pp1 does not get re-assigned on
part == 2, so do not set y either.
2017-04-23 10:35:04 +00:00
Vincent Pelletier
e7e1df886e TINYGL: Merge dead kInterpST code path into kInterpSTZ one.
Texture coordinates interpolation along Z coordinate is an extra behaviour
over texture coordinates interpolation along X and Y coordinates.
2016-07-28 02:46:41 +00:00
Vincent Pelletier
369332e464 TINYGL: Treat alpha the same way as other color components.
When kLightsMode (aka kInterpRGB) is false, "a" is always 0 (vertice data is
not used in caller in corresponding branches), so taking it into account makes
all triangles transparent.
This is not visible in practice, because putPixelTextureMappingPerspective is
only called when (kInterpST || kInterpSTZ) is true, and kInterpRGB is always
true when that's the case. But unifying color processing allows further code
simplification.
2016-07-28 01:55:14 +00:00
Vincent Pelletier
0065f38251 TINYGL: Reuse global const. 2016-07-28 01:55:14 +00:00
Vincent Pelletier
e1d5b811e1 Revert "GRIM: fixed transparency in TinyGL renderer"
This reverts commit b8bddf64da.

Since 9b7548ccf7, alpha test is enabled
when drawing model faces, fixing transparency issues in GRIM which were
corrected by reverted commit.
It is incorrect to test transparency when caller did not enable it.
Also, this change bypasses increments done at the end of
putPixelTextureMappingPerspective, so transparent textures in 16 bits mode
would be stuck on the transparent pixel for the current line's 8-pixel run
in filTriangle, and would ignore z coordinate.
2016-07-28 01:55:14 +00:00
Vincent Pelletier
8b6d362c58 TINYGL: Reuse _enableScissor property.
Should have been part of:
  commit db764b1ca5
  TINYGL: Entirely avoid calling scissorPixel in putPixel when possible.
2016-07-28 01:55:14 +00:00
Vincent Pelletier
18342118dc TINYGL: Fix y coordinate tracking when drawing triangles.
Increment y inside the loop, not outside.
Set y to the topmost vertex y coordinate, which depends on which half of
the triangle is being drawn.
Should have been part of:
  commit 3c2689a65f
  TINYGL: Optimise scissorPixel.

This does not (should not) fix any visible regression, as pixel scissor is
only (?) used when dirty rectangle mecanism is enabled (and it is disabled).
2016-07-28 01:55:10 +00:00
Vincent Pelletier
0a41574079 TINYGL: Process colors in RGBA 32bits internaly. 2016-07-24 01:20:50 +02:00
Vincent Pelletier
cf53e8871d TINYGL: Unroll DRAW_SHADOW and DRAW_SHADOW_MASK.
Also, update z in the second DRAW_SHADOW loop like it is done in the first.
Also, check each shadow mask pixel in DRAW_SHADOW, instead of 1 every 4.
2016-07-22 14:49:16 +02:00
Vincent Pelletier
3c2689a65f TINYGL: Optimise scissorPixel.
Scissor operations happen in a 2d rectangle, but it used to take a buffer
offset as a parameter. As a result, it had to divide that value with its
width, which is an expensive operation, which has to be done for each
pixel candidate for display (even before z-buffer comparison when
applicable, in current implementatoin).
But callers actually generate the buffer offset from rectangular
coordinates, so propagate these instead.
This sadly increases API redundancy, but saves a lot of time in a very
frequent occurrence (especially when enabling dirty rect mechanism,
which is not yet enabled by default).
2016-07-21 15:56:29 +02:00
Vincent Pelletier
03da50312b TINYGL: Move the task of writing to z-buffer to FrameBuffer::writePixel.
Because writePixel may decide to not write anything (alpha test), in which
case no z-buffer write should happen.
Factorises code.
Fixes apparent back-face culling in GRIM behind transparent textures, like
the tube (the 3d-shape Manny takes out, not the flat image in foreground)
in set mo.
2016-07-14 21:30:18 +00:00
Pawel Kolodziejski
b8bddf64da GRIM: fixed transparency in TinyGL renderer 2014-12-25 15:16:50 +01:00
Pawel Kolodziejski
e20ef7a4f8 TINYGL: added support for alpha channel for non texture triangles. 2014-09-12 06:50:17 +02:00
Stefano Musumeci
2cf70d6d76 Merge branch 'master' into tinygl-dirty-rects-fixed
Conflicts:
	graphics/tinygl/ztriangle.cpp
2014-08-16 16:03:27 +02:00
Joni Vähämäki
5bdfbb29eb TINYGL: Do not write to the depth buffer if depth test is disabled. 2014-08-14 22:01:18 +03:00
Stefano Musumeci
f9332da316 TINYGL: Refactored if-else sequence with progressive function calls. 2014-08-13 22:38:24 +02:00
Pawel Kolodziejski
1b48414d7e TINYGL: cleanup license headers 2014-08-13 18:52:52 +02:00
Stefano Musumeci
6e75f6b594 TINYGL: Renamed rasterization functions template parameters with constants naming convention. 2014-08-10 20:31:07 +02:00
Stefano Musumeci
f107e7cf6b TINYGL: Renamed variables to camelCase. 2014-08-09 12:00:43 +02:00
Stefano Musumeci
a4b57371e2 TINYGL: Refactored out duplicated code. 2014-08-08 13:09:44 +02:00
Stefano Musumeci
8c94a65a70 TINYGL: Optimized rasterization routines by moving more data from dynamic evaluation to static evaluation. 2014-08-06 21:52:41 +02:00
Stefano Musumeci
4d2dc3f0aa TINYGL: Added pixel scissoring logic to triangle rasterization. 2014-08-05 13:21:25 +02:00
Pawel Kolodziejski
9a81f8997c TINYGL: properly handle color for FLAT mode and lines drawing. Respect FLAT/SMOOTH mode for triangle drawing 2014-07-05 20:54:14 +02:00
Pawel Kolodziejski
97b03aed01 TINYGL: changed code to allow initialize TinyGL with specific internal texture dimension.
Grim: 256x256, Myst3: 1024x1024
2014-07-05 13:08:34 +02:00
Pawel Kolodziejski
f477946646 TINYGL: allow change internal texture size at compilation time. Now it's 1024x1024 pixels. 2014-07-05 12:13:03 +02:00
Pawel Kolodziejski
2072e51813 Revert "TINYGL: fixing T texture cordinate"
This reverts commit 5d65e40e1f.
2014-07-05 11:08:30 +02:00
Pawel Kolodziejski
5d65e40e1f TINYGL: fixing T texture cordinate 2014-07-05 11:06:34 +02:00
Pawel Kolodziejski
e6924e894c TINYGL: eliminate not clear use of define 2014-07-05 09:29:38 +02:00
Pawel Kolodziejski
1b8dd28bc7 TINYGL: implemented tglDepthFunc 2014-07-04 23:14:44 +02:00
Stefano Musumeci
38aa730b76 TINYGL: Implemented tglDepthMask. 2014-07-03 17:02:01 +02:00
Pawel Kolodziejski
e350350908 TINYGL: formatting code 2014-07-02 07:59:22 +02:00
Stefano Musumeci
109767e513 TINYGL: Implemented alpha blending and color transformation in sprite blitting for Grim TinyGL renderer. 2014-07-02 00:09:13 +02:00
Stefano Musumeci
63fd685589 TINYGL: Implemented alpha interpolation in triangle rasterization routine. 2014-07-01 14:29:44 +02:00
Stefano Musumeci
03072c4b7b TINYGL: Encapsulated pixel access in FrameBuffer class, provided an implementation of glBlendFunc. 2014-07-01 14:27:40 +02:00
Stefano Musumeci
e373f12d64 TINYGL: Removed unnecessary files and updated changelog. 2014-06-29 19:13:18 +02:00
Stefano Musumeci
4555f10cd8 TINYGL: Refactored line drawing routines. 2014-06-29 19:13:18 +02:00
Stefano Musumeci
2d6940923a TINYGL: Removed all the macros from triangle draw routines. 2014-06-28 20:39:10 +02:00
Stefano Musumeci
e630fb398a TINYGL: Refactored shadow drawing routines 2014-06-28 20:39:10 +02:00
Stefano Musumeci
4f140b6520 TINYGL: Refactored the triangle function in a template fashion 2014-06-28 20:39:09 +02:00
Stefano Musumeci
b9e0b28ed9 TINYGL: Renamed ZBuffer into FrameBuffer 2014-06-28 20:39:08 +02:00
Stefano Musumeci
81b5d40588 TINYGL: Refactored fill functions inside ZBuffer struct. 2014-06-28 20:39:07 +02:00
Stefano Musumeci
2be487a1f0 TINYGL: Added assert to ensure correct texture format. 2014-06-28 20:39:07 +02:00
Stefano Musumeci
10c4d6d4f5 TINYGL: Refactored zTriangleFill texture access code. 2014-06-28 20:39:06 +02:00
Einar Johan Trøan Sømåen
698ef4a37c TINYGL: Use astyle to (semi-selectively) apply the code-formatting conventions to TinyGL. 2014-02-20 18:46:49 +01:00
Dries Harnie
6bd38b1801 TINYGL: Support ColorMask
Note, this is just basic support, it is either all or nothing.
Disabling select channels is not possible.
2013-07-02 00:22:59 +02:00