Commit Graph

333 Commits

Author SHA1 Message Date
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
Vincent Pelletier
ce5af40a0b TinyGL: Store spot direction in eye coordinates.
As per OpenGL specifications:
  The spot direction is transformed by the upper 3x3 of the modelview
  matrix when glLight is called, and it is stored in eye coordinates.
2015-05-06 19:49:35 +02:00
Pawel Kolodziejski
f039ccd474 TINYGL: make consistent between allocation and free resource 2014-12-27 23:28:11 +01:00
Pawel Kolodziejski
b8bddf64da GRIM: fixed transparency in TinyGL renderer 2014-12-25 15:16:50 +01:00
Pawel Kolodziejski
c2a9a394c3 MYST3, TINYGL: fixed endian issue 2014-12-23 20:40:59 +01:00
Dries Harnie
06d077d00d TINYGL: Rename glColor3fv to tglColor3fv
Linking TinyGL and OpenGL into the same binary could cause conflicts
because both have a glColor3fv function.
It is currently not used in ResidualVM, so it is safe to change this.
2014-09-28 12:14:44 +02:00
Pawel Kolodziejski
6fc28fe37d TINYGL: gl -> tgl rename 2014-09-21 15:05:17 +02:00
Pawel Kolodziejski
e20ef7a4f8 TINYGL: added support for alpha channel for non texture triangles. 2014-09-12 06:50:17 +02:00
Paweł Kołodziejski
df14a526f2 Merge pull request #1033 from subr3v/master-changlog
TINYGL: Updated changelog.
2014-08-16 18:26:03 +02:00
Stefano Musumeci
f615ba388b TINYGL: Updated changelog. 2014-08-16 18:25:23 +02:00
Paweł Kołodziejski
30c5e793f2 Merge pull request #1010 from subr3v/myst3-subtitles-fix
TINYGL: Fixed support to RGB textures.
2014-08-16 17:35:11 +02:00
Stefano Musumeci
3beb5ff233 TINYGL: Reordered expression to make it more readable. 2014-08-16 17:31:54 +02:00
Stefano Musumeci
23385b3a4a TINYGL: Fixed compiler warnings. 2014-08-16 16:04:20 +02:00
Stefano Musumeci
5bd0a864f5 TINYGL: Fixed line breaks. 2014-08-16 16:04:16 +02:00
Stefano Musumeci
974f47fa42 TINYGL: Added a way to disable or enable dirty rectangles at runtime. 2014-08-16 16:04:10 +02:00
Stefano Musumeci
e1aea3a1f3 TINYGL: Added safety checks to Linear Allocator. 2014-08-16 16:04:05 +02:00
Stefano Musumeci
41737fcc21 TINYGL: Added/Updated license header in tinyGL files. 2014-08-16 16:03:54 +02:00