Remove hardcoded map visibility size from the ivis_opengl code.
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@4103 4a71c877-e1ca-e34f-864e-861f7616d084master
parent
3a05848aa4
commit
1b9ef4f995
|
@ -56,10 +56,6 @@
|
|||
#define INTERFACE_DEPTH (MAX_Z - 1)
|
||||
#define BUTTON_DEPTH 2000 // will be stretched to 16000
|
||||
|
||||
// Amount of visible terrain tiles in x/y direction
|
||||
#define VISIBLE_XTILES 64
|
||||
#define VISIBLE_YTILES 64
|
||||
|
||||
#define OLD_TEXTURE_SIZE_FIX 256.0f
|
||||
|
||||
//Render style flags for all pie draw functions
|
||||
|
@ -109,7 +105,8 @@ typedef struct {SDWORD texPage; SWORD tu, tv, tw, th;} PIEIMAGE; /**< An area of
|
|||
extern void pie_Draw3DShape(iIMDShape *shape, int frame, int team, PIELIGHT colour, PIELIGHT specular, int pieFlag, int pieData);
|
||||
extern void pie_DrawImage(PIEIMAGE *image, PIERECT *dest);
|
||||
|
||||
void pie_DrawTerrainDone(int mapx, int mapy);
|
||||
void pie_TerrainInit(int sizex, int sizey);
|
||||
void pie_DrawTerrain(int mapx, int mapy);
|
||||
void pie_DrawTerrainTriangle(int index, const TERRAIN_VERTEX *aVrts);
|
||||
void pie_DrawWaterTriangle(const TERRAIN_VERTEX *aVrts);
|
||||
|
||||
|
|
|
@ -42,13 +42,13 @@
|
|||
#define COLOUR_COMPONENTS 4
|
||||
#define TEXCOORD_COMPONENTS 2
|
||||
#define VERTEX_COMPONENTS 3
|
||||
#define TRIANGLES_PER_TILE 2
|
||||
#define VERTICES_PER_TILE (TRIANGLES_PER_TILE * VERTICES_PER_TRIANGLE)
|
||||
|
||||
#define MAP_TRIANGLES (VISIBLE_YTILES * VISIBLE_XTILES * 2) // two triangles per tile
|
||||
#define MAP_VERTICES (VERTICES_PER_TRIANGLE * MAP_TRIANGLES)
|
||||
|
||||
static GLubyte aColour[COLOUR_COMPONENTS * MAP_VERTICES];
|
||||
static GLfloat aTexCoord[TEXCOORD_COMPONENTS * MAP_VERTICES];
|
||||
static GLfloat aVertex[VERTEX_COMPONENTS * MAP_VERTICES];
|
||||
static GLubyte *aColour = NULL;
|
||||
static GLfloat *aTexCoord = NULL;
|
||||
static GLfloat *aVertex = NULL;
|
||||
static GLuint rowLength; ///< Length of one array table row in tiles
|
||||
|
||||
extern BOOL drawing_interface;
|
||||
|
||||
|
@ -827,7 +827,18 @@ void pie_DrawImage(PIEIMAGE *image, PIERECT *dest)
|
|||
glEnd();
|
||||
}
|
||||
|
||||
void pie_DrawTerrainDone(int mapx, int mapy)
|
||||
void pie_TerrainInit(int sizex, int sizey)
|
||||
{
|
||||
int size = sizex * sizey;
|
||||
|
||||
assert(sizex > 0 && sizey > 0);
|
||||
aColour = realloc(aColour, size * sizeof(GLubyte) * COLOUR_COMPONENTS * VERTICES_PER_TILE);
|
||||
aTexCoord = realloc(aTexCoord, size * sizeof(GLfloat) * TEXCOORD_COMPONENTS * VERTICES_PER_TILE);
|
||||
aVertex = realloc(aVertex, size * sizeof(GLfloat) * VERTEX_COMPONENTS * VERTICES_PER_TILE);
|
||||
rowLength = sizex;
|
||||
}
|
||||
|
||||
void pie_DrawTerrain(int mapx, int mapy)
|
||||
{
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
|
@ -848,8 +859,6 @@ void pie_DrawTerrainTriangle(int index, const TERRAIN_VERTEX *aVrts)
|
|||
{
|
||||
unsigned int i = 0, j = index * VERTICES_PER_TRIANGLE;
|
||||
|
||||
assert(index < MAP_TRIANGLES);
|
||||
assert(j < MAP_VERTICES);
|
||||
tileCount++;
|
||||
|
||||
for ( i = 0; i < 3; i++ )
|
||||
|
|
|
@ -201,7 +201,7 @@ static Vector3f alteredPoints[iV_IMD_MAX_POINTS];
|
|||
|
||||
//number of tiles visible
|
||||
// FIXME This should become dynamic! (A function of resolution, angle and zoom maybe.)
|
||||
const Vector2i visibleTiles = { VISIBLE_XTILES, VISIBLE_YTILES };
|
||||
Vector2i visibleTiles = { VISIBLE_XTILES, VISIBLE_YTILES };
|
||||
|
||||
UDWORD terrainMidX;
|
||||
UDWORD terrainMidY;
|
||||
|
@ -745,7 +745,7 @@ static void drawTiles(iView *player)
|
|||
drawTerrainTile(i, j, FALSE);
|
||||
}
|
||||
}
|
||||
pie_DrawTerrainDone(visibleTiles.x, visibleTiles.y);
|
||||
pie_DrawTerrain(visibleTiles.x, visibleTiles.y);
|
||||
|
||||
// Update height for water
|
||||
for (i = 0; i < visibleTiles.y + 1; i++)
|
||||
|
@ -887,7 +887,10 @@ BOOL init3DView(void)
|
|||
{
|
||||
/* Arbitrary choice - from direct read! */
|
||||
Vector3f theSun = { 225.0f, -600.0f, 450.0f };
|
||||
setTheSun( theSun );
|
||||
|
||||
setTheSun(theSun);
|
||||
visibleTiles.x = MIN(VISIBLE_XTILES, mapWidth);
|
||||
visibleTiles.y = MIN(VISIBLE_YTILES, mapHeight);
|
||||
|
||||
// the world centre - used for decaying lighting etc
|
||||
gridCentreX = player.p.x + world_coord(visibleTiles.x / 2);
|
||||
|
@ -902,6 +905,9 @@ BOOL init3DView(void)
|
|||
/* Make sure and change these to comply with map.c */
|
||||
imdRot.x = -35;
|
||||
|
||||
/* Initialize vertex arrays */
|
||||
pie_TerrainInit(mapWidth, mapHeight);
|
||||
|
||||
/* Get all the init stuff out of here? */
|
||||
initWarCam();
|
||||
|
||||
|
@ -1046,8 +1052,7 @@ static void flipsAndRots(unsigned int tileNumber, unsigned int i, unsigned int j
|
|||
/* Clips anything - not necessarily a droid */
|
||||
BOOL clipXY(SDWORD x, SDWORD y)
|
||||
{
|
||||
if (x > (SDWORD)player.p.x && x < (SDWORD)(player.p.x+(visibleTiles.x*
|
||||
TILE_UNITS)) &&
|
||||
if (x > (SDWORD)player.p.x && x < (SDWORD)(player.p.x+(visibleTiles.x * TILE_UNITS)) &&
|
||||
y > (SDWORD)player.p.z && y < (SDWORD)(player.p.z+(visibleTiles.y*TILE_UNITS)))
|
||||
return(TRUE);
|
||||
else
|
||||
|
|
|
@ -114,7 +114,7 @@ extern SDWORD mouseTileX, mouseTileY;
|
|||
|
||||
extern BOOL bRender3DOnly;
|
||||
|
||||
extern const Vector2i visibleTiles;
|
||||
extern Vector2i visibleTiles;
|
||||
|
||||
/*returns the graphic ID for a droid rank*/
|
||||
extern UDWORD getDroidRankGraphic(DROID *psDroid);
|
||||
|
|
|
@ -24,6 +24,10 @@
|
|||
#define TILE_HEIGHT 128
|
||||
#define TILE_SIZE (TILE_WIDTH*TILE_HEIGHT)
|
||||
|
||||
// Amount of visible terrain tiles in x/y direction
|
||||
#define VISIBLE_XTILES 64
|
||||
#define VISIBLE_YTILES 64
|
||||
|
||||
#define RADTLX (OBJ_BACKX + OBJ_BACKWIDTH + BASE_GAP + 1 +D_W) // Paul's settings (492+12)
|
||||
#define RADTLY (RET_Y + 1) // Paul's settings (332-17)
|
||||
#define RADWIDTH 128
|
||||
|
|
Loading…
Reference in New Issue