Commit Graph
399 Commits
Author SHA1 Message Date
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 a577b4c6a6 TINYGL: Free disposed textures before images.
Reusing function already defined in zdirtyrect.cpp doing both.
2016-07-28 01:55:48 +00:00
Vincent Pelletier 47a1e826e7 TINYGL: Free draw call lists in glClose. 2016-07-28 01:55:48 +00:00
Vincent Pelletier 3221146de9 TINYGL: Always initialise normal and eye coordinates (valgrind) 2016-07-28 01:55:48 +00:00
Vincent Pelletier 786311652a TINYGL: Initialise all light properties (valgrind).
Also, sort initialisation in the same order as declaration, for easier
difference-spotting.
2016-07-28 01:55:48 +00:00
Vincent Pelletier f272c85704 TINYGL: Initialise z buffer (valgrind) 2016-07-28 01:55:48 +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
Paweł Kołodziejski ac9986452e Merge pull request #1279 from vpelletier/tinygl_reunroll
TINYGL: reduce code duplication in ztriangles (was: [RFC] TINYGL: unroll some loops)
2016-07-23 13:59:14 +02:00
Vincent Pelletier 80983c1b69 TINYGL: Unroll FrameBuffer::blitOffscreenBuffer.
This method is used to blit large buffers, so a large unrolling is still
beneficial. As it is the second hottest-spot in grim, the frame rate
increase is most significant there (compared to emi).
2016-07-22 14:58:58 +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 93c6dc6027 TINYGL: Avoid calling memset_{s,l} when possible.
It is possible to convert calls to memset_{s,l} into call to memset when
all bytes of the depth or color value are the same (which is the likely
case), improving buffer clearing speed.
2016-07-22 07:19:48 +02:00
Paweł Kołodziejski 74ffd37dbe Merge pull request #1278 from vpelletier/tinygl_scissorpixel
Tinygl: optimise scissorpixel
2016-07-21 21:57:05 +02:00
Paweł Kołodziejski 4ffde5f680 Merge pull request #1282 from vpelletier/tinygl_loaddata_pixelformat
TINYGL: Expect colorKey in the same pixel format as surface.
2016-07-21 18:30:02 +02:00
Vincent Pelletier 46329cca87 TINYGL: Do not compute dirty region when its result is not used. 2016-07-21 16:42:24 +02:00
Vincent Pelletier d2defcd1cc TINYGL: Actually check if alpha test and blending are enabled. 2016-07-21 16:42:10 +02:00
Vincent Pelletier a1418732ec TINYGL: Typo in disabled code. 2016-07-21 16:41:24 +02:00
Vincent Pelletier 8ec310468d TINYGL: Replace multiplications by iterative additions.
As an iteration is done already anyway.
2016-07-21 16:41:18 +02:00
Vincent Pelletier a831238a96 TINYGL: Drop some unused locals. 2016-07-21 16:40:36 +02:00
Vincent Pelletier 4ff03d060e TINYGL: Call tglColor4f from tglColor4fv. 2016-07-21 16:40:07 +02:00
Vincent Pelletier d437892538 TINYGL: Get rid of PSZB as it duplicates pixelbytes. 2016-07-21 16:39:40 +02:00
Vincent Pelletier 7c1a15c6e8 TINYGL: Expect colorKey in the same pixel format as surface.
So caller does not have to depend on the pixel format used internally to
BlitImage.
Update callers which do request for color keying (GRIM/EMI only).
Also, remove a special-casing of transparent color when converting image
format which sets a color in a packed format independent from actual
destination format.
Also, in GfxTinyGL::createTextObject, prefer changing invisible colorKey
value than actually-visible color.
2016-07-21 16:17:32 +02:00
Vincent Pelletier db764b1ca5 TINYGL: Entirely avoid calling scissorPixel in putPixel when possible. 2016-07-21 16:02:22 +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
Paweł Kołodziejski d1be78ca49 Merge pull request #1269 from vpelletier/tinygl_optimise_light
Tinygl: optimise gl_shade_vertex
2016-07-20 14:39:05 +02:00
Paweł Kołodziejski 9acb1b9039 Merge pull request #1275 from vpelletier/valgrind
TINYGL, GRIM: Fix various errors (mostly memory leaks) found by valgrind
2016-07-20 14:09:52 +02:00
Vincent Pelletier 638b841c74 TINYGL: Simplify zline.cpp .
drawLine was broken for dx = 0 lines.
Also, the split between fillLineGeneric and drawLine, along with the many
parameters exchanged (with obscure names with subtle differences), made
the code hard to understand.
This implementation should be easier to check.
There was no visible CPU usage change.
Fixes GRIM's ticket printer, which are composed of a lot of vertical
segments.
2016-07-18 15:55:08 +02:00
Paweł Kołodziejski d467980499 Merge pull request #1262 from vpelletier/tinygl_dirty2d
GRIM: Fix drawLine/Rect/Polygon in TinyGL renderer
2016-07-18 05:17:35 +02:00
Vincent Pelletier db8cee2a69 TINYGL: Free BlitImage memory on close. 2016-07-18 04:36:37 +02:00
Vincent Pelletier 97dc3881e0 TINYGL: Add free_texture variant taking a GLTexture * argument.
To avoid looking texture up in the hash table when caller has a pointer to
it already. Aka, O(0) is better than O(1).
2016-07-18 04:34:09 +02:00
Vincent Pelletier 306fdff963 TINYGL: Dispose of textures beyond the first hash table entry. 2016-07-17 15:06:30 +00:00
Vincent Pelletier 95cc5127e0 TINYGL: Consistently consider Texture::handle as unsigned.
Texture handles are unsigned integers everywhere else.
2016-07-17 15:06:30 +00:00
Vincent Pelletier ed2fdb3aba TINYGL: Correct dot-product after its sign is known.
Normalising d when light is not in front of surface (nor behind when in
two-sides mode) is not needed as the value will not be used.
The same optimisation is already done when handling specular lights.
Also, remove "if (... > 1E-3)" conditions: as dot-product is not zero,
neither operand is zero, so this test (as a divide-by-zero protection) can
be removed.
2016-07-16 14:38:41 +00:00
Vincent Pelletier f66026a8aa TINYGL: Only do spotlight & specular computations when actually needed.
Spotlight and specular requires normalized d.
Skip specular if the light source or the material have no specular
component.
2016-07-16 12:17:59 +00:00
Vincent Pelletier 411e16fba5 TINYGL: Fix default diffuse and specular values for lights > 0. 2016-07-16 12:17:59 +00:00
Vincent Pelletier 342cf9a60d TINYGL: Simplify a bit updateTmp . 2016-07-15 22:20:41 +00: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
Vincent Pelletier a336422811 TINYGL: Fix clipped triangle vertices alpha channel.
In all 4 updateTmp call places, q is not initialised, so there is nothing
of value in the alpha channel (it's 0). So just apply the same rule as for
other color channels.
2016-07-14 15:36:28 +00:00
Vincent Pelletier 46fa5eb373 TINYGL: Fix off-by-one in TGL_LINE_LOOP/TGL_LINE_STRIP .
Also, draw last line from last point to first instead of first point to
last as the latter leaves an unpainted pixel for some reason.
2016-07-11 14:52:36 +00:00
Vincent Pelletier 98696865df TINYGL: Fix TGL_QUADS with more than one quad.
Fixes checkbox border on Copal's computer.
2016-07-11 00:30:58 +00:00
Vincent Pelletier e72db42ef0 TINYGL: Fix tglOrtho matrix definition.
As per glOrtho documentation, bottom-right must be 1.
Also, in TinyGL, matrices are row-major, so m._m[0][3] is r[3], not
r[12].
2016-07-11 00:00:30 +00:00
Vincent Pelletier 6f1e46d6b4 TINYGL: Implement tglColor3ub. 2016-07-11 00:00:30 +00:00
Vincent Pelletier 93d23656fa TINYGL: Do not clear matrix_model_projection_updated in gl_matrix_update.
Changing texture or color matrices must not prevent a model projection
update, even if it is done last.
2016-07-10 13:19:45 +00:00
Vincent Pelletier f75767fc78 TINYGL: Always check if texture matrix need applying.
matrix_model_projection_updated is not set when texture matrix alone is
modified.
2016-07-10 13:13:46 +00:00
Vincent Pelletier f6bbbc7b28 TinyGL: Use standard initial diffuse and specular values.
As per OpenGL specifications, light 0 is the only light with full diffuse and
specular light initial state. This should not affect residualvm as all enabled
light properties are configured.
2016-01-01 17:37:23 +01:00
Vincent Pelletier 09478b1791 TinyGL: Use normalised position for directional lights.
So that dot-product result (used for attenuation) is between -1 and 1.
This should make no difference for GRIM: as far as I can see, all
direction vectors are already normalized in data files.
2016-01-01 17:29:19 +01:00