Commit Graph

3273 Commits (9b9d9e378f2a6157f5521073af273d5dfd36367d)

Author SHA1 Message Date
Armin Burgmeier 988fe15e29 Use VBOs to draw sprite graphics
I don't expect much of a performance benefit from this, but it works toward
removal of legacy OpenGL usage. Note that we are already using VBOs for
meshes, so this does not require any functionality that we don't require
already.
2016-01-01 22:26:41 -08:00
Armin Burgmeier 9fd7e88afd Fix crash when changing mesh material of incomplete mesh
Changing the mesh material to something that does not use alpha blending
restores the originial face order. This caused a crash for meshes with
Completion below 1, since all original faces were copied, but the buffer
in the mesh instance was only large enough to hold the number of faces of
the incompleted mesh. To fix this, simply run the standard
select-faces-for-a-given-completion-value procedure.
2016-01-01 17:01:10 -08:00
Armin Burgmeier 795740c6ee C4Surface: fix texture restore on IntUnlock (#1526) 2016-01-01 14:48:33 -08:00
Günther Brammer 38c6242bce Fix out-of-bounds check and bounds collision for non-centric object shapes
The proper way to measure from the center to the right is X+Wdt, not -X
or Wdt/2. And the proper way to measure to the left is -X, not -Wdt/2.
2016-01-01 22:18:41 +01:00
Günther Brammer 00a4c6c428 Replace BorderBound DefCore value with BorderBound object property 2016-01-01 22:18:41 +01:00
Günther Brammer 690b4f9ba0 Move comparison out of C4Object::TargetBounds
This probably enlarges the maximum landscape height for borderbound objects.
The "infinity" constant +1000000 is larger than the biggest C4Fixed, so
would have been truncated to 16960.
2016-01-01 22:18:41 +01:00
Günther Brammer 87c9fc965f Inline pointless ForceLimits function
In the time it took to understand the API of that function, one can read
the entire TargetBounds function which was its sole user.
2016-01-01 22:18:41 +01:00
Armin Burgmeier 26cfbdb059 Fix assertion failure when rendering mesh with degenerate transform (#1519)
The DynamiteBox sets the PictureTransformation to a degenerate matrix, to
prevent it from being rendered. Exit early in this case, since we are not
going to render anything anyway, and avoid the assertion when inverting the
matrix.
2016-01-01 11:34:04 -08:00
Günther Brammer 5db59e8665 Fix C4MessageBoard key binding lifetime
I think C4Game::InitKeyboard relies on the callback targets outliving the
keybindings and every other class is prepared to be deleted before
C4KeyboardInput::Clear(), so needs to hold a ref to the keybinding to
delete that in its destructor.

C4KeyBinding is the class that is used for that, and it sets the reference
count to 1 in the constructor, to represent the reference held in the
owning class.

On the other hand, C4CustomKey gets immediately forgotten by C4Game and the
only reference is held in the keymap.

To prevent this from happening again, make the C4CustomKey constructors
protected and C4Game a friend of the class.

Also remove an unused C4CustomKey constructor.
2016-01-01 16:24:43 +01:00
Armin Burgmeier c0844c10ff Add support for generic attributes to C4Shader
Replace the hardcoded VAI_ constants with that. The VAI constants are now
moved to C4DrawGL as C4SSA_ constants, similar to the C4SSU ones. This allows
to introduce other attributes to replace vertex positions, normals, colors
and texture coordinates with attributes in later commits. This, in turn, is
needed because the built-in attributes are no longer available in the OpenGL
core profile.

Also, while at it, cleanup C4Shader a bit. Use std::vector<> instead of
maintaining an own array of uniform names. Delete the vertex and fragment
objects after the full shader program has been linked. Make sure that
C4Shader::Init keeps the old program in place if the new one cannot be
compiled or linked.
2015-12-31 22:28:23 -08:00
Armin Burgmeier c043795552 Fix memory leak in FoW surfaces
Surfaces are initially created in locked state, and only when unlocked the
memory buffer with the surface data is uploaded to the GPU. The FoW code
however never unlocks the surface but instead operates on the OpenGL texture
directly. To fix this, introduce a new flag for C4Surface to create it in an
unlocked state.

This is not a memory leak in the traditional sense as a pointer to the buffer
is still available and is being freed when the surface is being destructed
at the end of the game. However, during the game there might be several
megabytes allocated that are never used.

I'm not really sold by this Lock/Unlock mechanism. Instead, there should
simply be a function to obtain the current texture data, and a function to
upload new texture data. That's for another time though...
2015-12-31 18:40:38 -08:00
Armin Burgmeier fc4679e3ea Don't upload all texture data twice
For some reason, the C4TexRef constructor first uploaded a set of nulled
texture data, just to be replaced by the actual image data when Unlock()
is called. Skip the unnecessary step and instead just reserve the video
memory in the constructor.
2015-12-31 17:58:22 -08:00
Armin Burgmeier 8766f5123b Remove other usages of built-in GL matrices
Primarily for the FoW rendering, which now also uses (simple) shaders
without ftransform() everywhere. This also removes all GLU calls.
2015-12-31 17:30:21 -08:00
Maikel de Vries a6efefaecc fix float physics for objects moving out of a liquid surface (#1523)
This also fixes objects which previously jumped out of the water continuously, by adding an extra check to also capture faster moving objects. It could be made speed dependent, but that seems to be overkill for the situation.
2015-12-30 12:54:04 +01:00
Nicolas Hake 9b34bf2634 Remove arbitrary inline forward declarations of StdBuf (and derivatives) 2015-12-29 21:42:46 +01:00
Nicolas Hake c0befc6ba0 Remove C4RTF
The only use of C4RTF in its final moments was parsing out plain text
from RTF files anyway, so why even go to all the trouble instead of just
storing plain text in the beginning?
2015-12-29 17:51:43 +01:00
Günther Brammer 77a71c39d3 Require some C++14 support (make_unique, index_sequence) 2015-12-29 15:47:55 +01:00
Günther Brammer 16ef28e05f Drop unused C4VERSIONBUILDNAME and C4ENGINEINFO
This was used to name snapshot releases of the Network2 branch, and has
seen almost no use since.

C4ENGINEINFO(LONG) was a duplicate of C4ENGINENAME and C4ENGINECAPTION.
2015-12-29 15:47:55 +01:00
Nicolas Hake 500229c302 C4Extra: Make ownership of ExtraGroups more explicit 2015-12-29 13:56:06 +01:00
Nicolas Hake d0cd244077 C4Extra: Merge ctor/Default, dtor/Clear 2015-12-29 02:59:02 +01:00
Nicolas Hake 3da14127a4 C4TransferZone: Merge ctor/Default, dtor/Clear 2015-12-29 02:59:01 +01:00
Nicolas Hake 63ab46e293 C4Player: Merge ctor/Default, dtor/Clear 2015-12-29 02:59:00 +01:00
Nicolas Hake 90293d019d C4FoWRegion: Make more private
Code outside of C4FoWRegion should not care about the internals of the
class. Therefore, we remove direct access to the backing surface (and
secondary buffer surface) and replace it instead with accessors that
return those few values that are required by outside code.
2015-12-28 21:45:21 +01:00
Nicolas Hake 5a9baeddbf C4FoWRegion: Turn some owned pointers into std::unique_ptr 2015-12-28 21:45:19 +01:00
Nicolas Hake 46abecded7 C4FoWRegion: Merge Clear() into dtor 2015-12-28 21:45:15 +01:00
Nicolas Hake ddd068c830 C4Viewport: Turn some owned pointers into std::unique_ptr 2015-12-28 21:45:14 +01:00
Nicolas Hake 3590dda85a C4Viewport: Merge ctor/Default, dtor/Clear 2015-12-28 21:43:03 +01:00
Günther Brammer 6a53066c36 Include config.h only from PlatformAbstraction.h
In order to avoid duplication, PlatformAbstraction.h has to be included at
the start of every source file, so that various headers can rely on it
being there. To avoid confusion, always rely on that, instead of sometimes
randomly including it or parts of it again.
2015-12-28 18:50:31 +01:00
Günther Brammer 30e0cdb418 CMake: Re-enable readline support for openclonk-server 2015-12-28 18:48:45 +01:00
Nicolas Hake d737dc1b05 Remove C4Video, StdVideo
Video recording and playback only worked on Windows, and recording only
handled video, not game audio. As such, it was of fairly limited use,
and there's lots of software available these days that handle both.
2015-12-28 11:43:41 +01:00
Nicolas Hake 7475b89bd2 C4MessageBoard: Merge Default/Clear into ctor/dtor 2015-12-28 11:43:40 +01:00
Nicolas Hake 24a7c75a1b C4MessageBoard: Remove unimplemented member DrawLoader 2015-12-28 11:43:39 +01:00
Nicolas Hake fc1189dfe4 C4UpperBoard: Remove empty Default/Clear 2015-12-28 11:43:38 +01:00
Nicolas Hake d65af91694 C4GraphicsSystem: Remove unused function 2015-12-28 11:43:37 +01:00
Nicolas Hake 3c625a00dd C4Game: Turn some owned pointers into std::unique_ptr
Using std::unique_ptr instead of raw pointers makes ownership clear and
avoids leaks.
2015-12-28 11:43:37 +01:00
Nicolas Hake d063e02a3c C4FullScreen: Remove several unimplemented function declarations 2015-12-27 16:49:41 +01:00
Nicolas Hake 4980572c79 C4Game: Remove several unimplemented function declarations 2015-12-27 16:49:41 +01:00
David Dormagen 65dc58c77d fixed wrong positioning of script GUI windows with the GUI_Multiple flag on startup (#1477)
GUI_Multiple windows are supposed to be updated from the root window in a full refresh. However, they also had the "dirty" flag set (that is only used for non GUI_Multiple windows after the initial startup), but they did not unset it when updating.
So they were first updated with the correct parent width (full screen) and then, because of the dirty flag, were updated again like a non GUI_Multiple window with the parent's size. That was incorrect. Only another update would then fix it again (because the "dirty" flag would then have been unset).
2015-12-27 15:48:32 +01:00
Nicolas Hake 33e2626649 Win32: Stop trying to steal focus from other apps
If the user switched away from OC while it was loading, there was
probably a reason for that. We'll no longer assume we're the most
important app in the world and steal the focus away from whatever the
user was doing.
2015-12-27 13:22:18 +01:00
Nicolas Hake f7ed26eb9e Make OpenAL extension init log entry slightly less useless
It's still pretty useless because nobody cares in the slightest about
which extensions are available and which ones aren't, but at least now
it doesn't throw an unintelligible list of numbers at you.
2015-12-27 01:54:44 +01:00
Nicolas Hake cbdeca56de Temporarily change to C locale before formatting shader floats
In the game initialization code, we're setting the thread locale to the
user's default locale. This is bad when generating shader code because
it may lead to floats being written with commas instead of dots for the
decimal separator, which in turn confuses the GLSL compiler (because it
parses the comma as the comma operator). So now we just temporarily set
the C locale while generating shader code.
2015-12-27 01:54:42 +01:00
Nicolas Hake b36a9ec5b5 C4Draw: Remove C4Draw::IsShaderific()
In a surprising touch, using shaders to affect pretty much every pixel
that gets drawn on screen means there is little reason for code to ask
the renderer if it knows about shaders.
2015-12-27 01:54:41 +01:00
Nicolas Hake 73c26114cb C4Draw: Remove C4Draw::IsOpenGL()
Nobody was interested in testing whether the renderer was GL or something
else, so the function is superfluous.
2015-12-27 01:54:06 +01:00
Armin Burgmeier de3ed60aa8 Avoid built-in GL matrices for mesh rendering
Instead, compute the projection, modelview and normal matrices explictly
and upload them as shader uniforms.
2015-12-24 23:02:03 -08:00
Armin Burgmeier a487457563 Add a 4x4 matrix class (StdProjectionMatrix)
This makes it easier to convert the projection and modelview matrices
to GLSL uniforms.
2015-12-24 23:01:52 -08:00
Armin Burgmeier 43e50f9320 Drop usage of gluErrorString
There are only a couple of error values worth considering, so we can just
write out own function for it. Disable error checking in C4FoWRegion.cpp as
well, since we have the --debug-opengl flag now.

This should allow us to get rid of the GLU dependency soon.
2015-12-24 16:26:52 -08:00
Armin Burgmeier d7a5ac373d Fix the console build on Mac
cmake still does not create a nice bundle for it, but at least
the build does not fail anymore.
2015-12-23 16:31:19 -08:00
Günther Brammer 249715bbcc Script: The Prototype of effects is readonly
The new effect API will be triggered by the effect having a prototype, and
doing that accidentally would be far too confusing.
2015-12-22 18:07:38 +01:00
Günther Brammer 8e889479cc Script: Find_Property can also search for engine-defined properties
Previously it used a C4PropList API that only checked the properties
set by script.
2015-12-22 18:07:38 +01:00
Armin Burgmeier eab0f2850a Clear Relight markers in C4Landscape::Clear (#1510)
Otherwise, when starting the next scenario, random spots would be initially
re-lighted. That's not necessarily a problem, but unnecessary work, and it
triggered the assertion in C4FowAmbient::UpdateFromLandscape if the relight
was scheduled for a region that's outside of the landscape boundaries of the
second scenario.
2015-12-21 19:35:43 -08:00