1
0
forked from 0ad/0ad
0ad/source/renderer/WaterManager.h
janwas c0ed950657 had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).

it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.

after several hours, the code now requires fewer casts and less
guesswork.

other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.

This was SVN commit r5942.
2008-05-11 18:48:32 +00:00

93 lines
2.3 KiB
C++

/**
* =========================================================================
* File : WaterManager.h
* Project : Pyrogenesis
* Description : Water settings (speed, height) and texture management
* =========================================================================
*/
#ifndef INCLUDED_WATERMANAGER
#define INCLUDED_WATERMANAGER
#include "ps/Overlay.h"
#include "maths/Matrix3D.h"
#include "lib/ogl.h"
/**
* Class WaterManager: Maintain water settings and textures.
*
* This could be extended to provide more advanced water rendering effects
* (refractive/reflective water) in the future.
*/
class WaterManager
{
public:
Handle m_WaterTexture[60];
Handle m_NormalMap[60];
int m_WaterCurrentTex;
CColor m_WaterColor;
bool m_RenderWater;
bool m_WaterScroll;
float m_WaterHeight;
float m_WaterMaxAlpha;
float m_WaterFullDepth;
float m_WaterAlphaOffset;
float m_SWaterSpeed;
float m_TWaterSpeed;
float m_SWaterTrans;
float m_TWaterTrans;
float m_SWaterScrollCounter;
float m_TWaterScrollCounter;
double m_WaterTexTimer;
// Reflection and refraction textures for fancy water
GLuint m_ReflectionTexture;
GLuint m_RefractionTexture;
size_t m_ReflectionTextureSize;
size_t m_RefractionTextureSize;
// Model-view-projection matrices for reflected & refracted cameras
// (used to let the vertex shader do projective texturing)
CMatrix3D m_ReflectionMatrix;
CMatrix3D m_RefractionMatrix;
// Shader parameters for fancy water
CColor m_WaterTint;
float m_RepeatPeriod;
float m_Shininess;
float m_SpecularStrength;
float m_Waviness;
float m_Murkiness;
CColor m_ReflectionTint;
float m_ReflectionTintStrength;
public:
WaterManager();
~WaterManager();
/**
* LoadWaterTextures: Load water textures from within the
* progressive load framework.
*
* @return 0 if loading has completed, a value from 1 to 100 (in percent of completion)
* if more textures need to be loaded and a negative error value on failure.
*/
int LoadWaterTextures();
/**
* UnloadWaterTextures: Free any loaded water textures and reset the internal state
* so that another call to LoadWaterTextures will begin progressive loading.
*/
void UnloadWaterTextures();
private:
/// State of progressive loading (in # of loaded textures)
size_t cur_loading_water_tex;
size_t cur_loading_normal_map;
};
#endif // INCLUDED_WATERMANAGER