Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: Warzone2100/warzone2100
base: 20317c2a6f
...
head fork: Warzone2100/warzone2100
compare: d69f336ec4
Checking mergeability… Don't worry, you can still create the pull request.
  • 3 commits
  • 10 files changed
  • 0 commit comments
  • 1 contributor
View
4 data/mp/multiplay/skirmish/semperfi.js
@@ -747,4 +747,8 @@ function eventChat(from, to, message)
{
donatePower(playerPower(me) / 2, from);
}
+ else if (message == "crazycolours")
+ {
+ setSunIntensity(0.6, 0.4, 0.3, 1.0, 0.8, 0.7, 1.2, 0.9, 0.8);
+ }
}
View
7 lib/ivis_opengl/pieclip.h
@@ -34,13 +34,6 @@
#include "lib/framework/frame.h"
#include "piedef.h"
-struct CLIP_VERTEX
-{
- Vector3i pos;
- unsigned int u, v;
- PIELIGHT light;
-};
-
/***************************************************************************/
/*
* Global ProtoTypes
View
4 lib/ivis_opengl/piedef.h
@@ -82,6 +82,10 @@ extern void pie_GetResetCounts(unsigned int* pPieCount, unsigned int* pPolyCount
/** Setup stencil shadows and OpenGL lighting. */
void pie_BeginLighting(const Vector3f * light, bool drawshadows);
+/** Set light parameters */
+void pie_InitLighting();
+void pie_SetupLighting();
+
/* Stop using stencil shadows and OpenGL lighting (if enabled). */
void pie_EndLighting(void);
View
30 lib/ivis_opengl/piedraw.cpp
@@ -59,12 +59,28 @@ static GLenum ss_op_depth_pass_back = GL_DECR;
static unsigned int pieCount = 0;
static unsigned int polyCount = 0;
static bool shadows = false;
-static GLfloat lighting0[LIGHT_MAX][4] = {{0.0f, 0.0f, 0.0f, 1.0f}, {0.5f, 0.5f, 0.5f, 1.0f}, {0.8f, 0.8f, 0.8f, 1.0f}, {1.0f, 1.0f, 1.0f, 1.0f}};
+static GLfloat lighting0[LIGHT_MAX][4];
/*
* Source
*/
+void pie_InitLighting()
+{
+ const GLfloat defaultLight[LIGHT_MAX][4] = {{0.0f, 0.0f, 0.0f, 1.0f}, {0.5f, 0.5f, 0.5f, 1.0f}, {0.8f, 0.8f, 0.8f, 1.0f}, {1.0f, 1.0f, 1.0f, 1.0f}};
+ memcpy(lighting0, defaultLight, sizeof(lighting0));
+ pie_SetupLighting();
+}
+
+void pie_SetupLighting()
+{
+ glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lighting0[LIGHT_EMISSIVE]);
+ glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_FALSE);
+ glLightfv(GL_LIGHT0, GL_AMBIENT, lighting0[LIGHT_AMBIENT]);
+ glLightfv(GL_LIGHT0, GL_DIFFUSE, lighting0[LIGHT_DIFFUSE]);
+ glLightfv(GL_LIGHT0, GL_SPECULAR, lighting0[LIGHT_SPECULAR]);
+}
+
void pie_Lighting0(LIGHTING_TYPE entry, float value[4])
{
lighting0[entry][0] = value[0];
@@ -75,14 +91,9 @@ void pie_Lighting0(LIGHTING_TYPE entry, float value[4])
void pie_BeginLighting(const Vector3f *light, bool drawshadows)
{
- const float pos[4] = {light->x, light->y, light->z, 0.0f};
+ const float pos[4] = { light->x, light->y, light->z, 0.0f };
- glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lighting0[LIGHT_EMISSIVE]);
- glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_FALSE);
glLightfv(GL_LIGHT0, GL_POSITION, pos);
- glLightfv(GL_LIGHT0, GL_AMBIENT, lighting0[LIGHT_AMBIENT]);
- glLightfv(GL_LIGHT0, GL_DIFFUSE, lighting0[LIGHT_DIFFUSE]);
- glLightfv(GL_LIGHT0, GL_SPECULAR, lighting0[LIGHT_SPECULAR]);
glEnable(GL_LIGHT0);
if (drawshadows)
@@ -91,11 +102,6 @@ void pie_BeginLighting(const Vector3f *light, bool drawshadows)
}
}
-bool pie_GetLightingState(void)
-{
- return true;
-}
-
void pie_EndLighting(void)
{
shadows = false;
View
54 lib/ivis_opengl/piefunc.cpp
@@ -37,42 +37,41 @@
static GFX *skyboxGfx = NULL;
#define VW_VERTICES 5
-void pie_DrawViewingWindow(Vector3i *v, UDWORD x1, UDWORD y1, UDWORD x2, UDWORD y2, PIELIGHT colour)
+static Vector3i pieVrts[VW_VERTICES];
+static PIELIGHT pieColour;
+
+void pie_SetViewingWindow(Vector3i *v, PIELIGHT colour)
{
- CLIP_VERTEX pieVrts[VW_VERTICES];
- SDWORD i;
+ pieColour = colour;
- pie_SetTexturePage(TEXPAGE_NONE);
- pie_SetRendMode(REND_ALPHA);
+ pieVrts[0] = v[1];
+ pieVrts[0].z = INTERFACE_DEPTH; // cull triangles with off screen points
- pieVrts[0].pos.x = v[1].x;
- pieVrts[0].pos.y = v[1].y;
- //cull triangles with off screen points
- pieVrts[0].pos.z = INTERFACE_DEPTH;
+ pieVrts[1] = v[0];
+ pieVrts[1].z = INTERFACE_DEPTH;
- pieVrts[0].u = 0;
- pieVrts[0].v = 0;
- pieVrts[0].light = colour;
+ pieVrts[2] = v[2];
+ pieVrts[2].z = INTERFACE_DEPTH;
- pieVrts[1] = pieVrts[0];
- pieVrts[2] = pieVrts[0];
- pieVrts[3] = pieVrts[0];
- pieVrts[4] = pieVrts[0];
+ pieVrts[3] = v[3];
+ pieVrts[3].z = INTERFACE_DEPTH;
- pieVrts[1].pos.x = v[0].x;
- pieVrts[1].pos.y = v[0].y;
+ pieVrts[4] = pieVrts[0];
+}
- pieVrts[2].pos.x = v[2].x;
- pieVrts[2].pos.y = v[2].y;
+void pie_DrawViewingWindow()
+{
+ SDWORD i;
+ PIELIGHT colour = pieColour;
- pieVrts[3].pos.x = v[3].x;
- pieVrts[3].pos.y = v[3].y;
+ pie_SetTexturePage(TEXPAGE_NONE);
+ pie_SetRendMode(REND_ALPHA);
glColor4ub(colour.byte.r, colour.byte.g, colour.byte.b, colour.byte.a >> 1);
glBegin(GL_TRIANGLE_FAN);
for (i = 0; i < VW_VERTICES; i++)
{
- glVertex2f(pieVrts[i].pos.x, pieVrts[i].pos.y);
+ glVertex2f(pieVrts[i].x, pieVrts[i].y);
}
glEnd();
@@ -80,9 +79,9 @@ void pie_DrawViewingWindow(Vector3i *v, UDWORD x1, UDWORD y1, UDWORD x2, UDWORD
glBegin(GL_LINE_STRIP);
for (i = 0; i < VW_VERTICES; i++)
{
- glVertex2f(pieVrts[i].pos.x, pieVrts[i].pos.y);
+ glVertex2f(pieVrts[i].x, pieVrts[i].y);
}
- glVertex2f(pieVrts[0].pos.x, pieVrts[0].pos.y);
+ glVertex2f(pieVrts[0].x, pieVrts[0].y);
glEnd();
}
@@ -162,8 +161,3 @@ void pie_DrawSkybox(float scale)
glPopAttrib();
}
-
-UBYTE pie_ByteScale(UBYTE a, UBYTE b)
-{
- return ((UDWORD)a * (UDWORD)b) >> 8;
-}
View
7 lib/ivis_opengl/piefunc.h
@@ -33,9 +33,10 @@
#include "lib/ivis_opengl/piedef.h"
#include "lib/ivis_opengl/pieclip.h"
-extern UBYTE pie_ByteScale(UBYTE a, UBYTE b) WZ_DECL_CONST;
-extern void pie_TransColouredTriangle(Vector3f *vrt, PIELIGHT c);
-extern void pie_DrawViewingWindow( Vector3i *v, UDWORD x1, UDWORD y1, UDWORD x2, UDWORD y2, PIELIGHT colour);
+void pie_TransColouredTriangle(Vector3f *vrt, PIELIGHT c);
+
+void pie_SetViewingWindow(Vector3i *v, PIELIGHT colour);
+void pie_DrawViewingWindow();
void pie_DrawSkybox(float scale);
void pie_Skybox_Init();
View
1  src/init.cpp
@@ -1094,6 +1094,7 @@ bool stageThreeInitialise(void)
effectResetUpdates();
initLighting(0, 0, mapWidth, mapHeight);
+ pie_InitLighting();
if(bMultiPlayer)
{
View
1  src/qtscriptfuncs.cpp
@@ -3669,6 +3669,7 @@ static QScriptValue js_setSunIntensity(QScriptContext *context, QScriptEngine *)
pie_Lighting0(LIGHT_AMBIENT, ambient);
pie_Lighting0(LIGHT_DIFFUSE, diffuse);
pie_Lighting0(LIGHT_SPECULAR, specular);
+ pie_SetupLighting();
return QScriptValue();
}
View
69 src/radar.cpp
@@ -57,6 +57,7 @@ bool rotateRadar; ///< Rotate the radar?
static PIELIGHT colRadarAlly, colRadarMe, colRadarEnemy;
static PIELIGHT tileColours[MAX_TILES];
static UDWORD *radarBuffer = NULL;
+static Vector3i playerpos;
PIELIGHT clanColours[]=
{ // see frontend2.png for team color order.
@@ -105,10 +106,11 @@ static float RadarZoomMultiplier = 1.0f;
static UDWORD radarBufferSize = 0;
static int frameSkip = 0;
-static void DrawRadarTiles(void);
-static void DrawRadarObjects(void);
-static void DrawRadarExtras(float radarX, float radarY, float pixSizeH, float pixSizeV);
-static void DrawNorth(void);
+static void DrawRadarTiles();
+static void DrawRadarObjects();
+static void DrawRadarExtras();
+static void DrawNorth();
+static void setViewingWindow();
static void radarSize(int ZoomLevel)
{
@@ -128,16 +130,17 @@ static void radarSize(int ZoomLevel)
debug(LOG_WZ, "radar=(%u,%u) tex=(%u,%u) size=(%u,%u)", radarCenterX, radarCenterY, radarTexWidth, radarTexHeight, radarWidth, radarHeight);
}
-void radarInitVars(void)
+void radarInitVars()
{
radarTexWidth = 0;
radarTexHeight = 0;
RadarZoom = DEFAULT_RADARZOOM;
debug(LOG_WZ, "Resetting radar zoom to %u", RadarZoom);
radarSize(RadarZoom);
+ playerpos = Vector3i(-1, -1, -1);
}
-bool InitRadar(void)
+bool InitRadar()
{
// Ally/enemy/me colors
colRadarAlly = WZCOL_YELLOW;
@@ -152,7 +155,7 @@ bool InitRadar(void)
return true;
}
-bool resizeRadar(void)
+bool resizeRadar()
{
if (radarBuffer)
{
@@ -175,11 +178,12 @@ bool resizeRadar(void)
radarSize(RadarZoom);
pie_SetRadar(-radarWidth/2.0 - 1, -radarHeight/2.0 - 1, radarWidth, radarHeight,
radarTexWidth, radarTexHeight, rotateRadar || (RadarZoom % 16 != 0));
+ setViewingWindow();
return true;
}
-bool ShutdownRadar(void)
+bool ShutdownRadar()
{
pie_ShutdownRadar();
@@ -210,7 +214,7 @@ void SetRadarZoom(uint8_t ZoomLevel)
resizeRadar();
}
-uint8_t GetRadarZoom(void)
+uint8_t GetRadarZoom()
{
return RadarZoom;
}
@@ -257,13 +261,20 @@ void CalcRadarPosition(int mX, int mY, int *PosX, int *PosY)
*PosY = sPosY;
}
-void drawRadar(void)
+void drawRadar()
{
float pixSizeH, pixSizeV;
+ CalcRadarPixelSize(&pixSizeH, &pixSizeV);
+
ASSERT_OR_RETURN(, radarBuffer, "No radar buffer allocated");
- CalcRadarPixelSize(&pixSizeH, &pixSizeV);
+ // Do not recalculate frustum window coordinates if position or zoom does not change
+ if (playerpos.x != player.p.x || playerpos.y != player.p.y || playerpos.z != player.p.z)
+ {
+ setViewingWindow();
+ }
+ playerpos = player.p; // cache position
if (frameSkip <= 0)
{
@@ -283,15 +294,15 @@ void drawRadar(void)
DrawNorth();
}
pie_RenderRadar();
- pie_MatBegin();
- pie_TRANSLATE(-radarWidth/2 - 1, -radarHeight/2 - 1, 0);
- DrawRadarExtras(0, 0, pixSizeH, pixSizeV);
- pie_MatEnd();
+ pie_MatBegin();
+ pie_TRANSLATE(-radarWidth/2 - 1, -radarHeight/2 - 1, 0);
+ DrawRadarExtras();
+ pie_MatEnd();
drawRadarBlips(-radarWidth/2.0 - 1, -radarHeight/2.0 - 1, pixSizeH, pixSizeV);
pie_MatEnd();
}
-static void DrawNorth(void)
+static void DrawNorth()
{
iV_DrawImage(IntImages, RADAR_NORTH, -((radarWidth / 2.0) + iV_GetImageWidth(IntImages, RADAR_NORTH) + 1), -(radarHeight / 2.0));
}
@@ -386,7 +397,7 @@ static PIELIGHT appliedRadarColour(RADAR_DRAW_MODE radarDrawMode, MAPTILE *WTile
}
/** Draw the map tiles on the radar. */
-static void DrawRadarTiles(void)
+static void DrawRadarTiles()
{
SDWORD x, y;
@@ -409,7 +420,7 @@ static void DrawRadarTiles(void)
}
/** Draw the droids and structure positions on the radar. */
-static void DrawRadarObjects(void)
+static void DrawRadarObjects()
{
UBYTE clan;
PIELIGHT playerCol;
@@ -576,13 +587,17 @@ static SDWORD getLengthAdjust( void )
}
/** Draws a Myth/FF7 style viewing window */
-static void drawViewingWindow(float radarX, float radarY, int x, int y, float pixSizeH, float pixSizeV)
+static void setViewingWindow()
{
+ float pixSizeH, pixSizeV;
Vector3i v[4], tv[4], centre;
int shortX, longX, yDrop, yDropVar;
int dif = getDistanceAdjust();
int dif2 = getLengthAdjust();
PIELIGHT colour;
+ CalcRadarPixelSize(&pixSizeH, &pixSizeV);
+ int x = player.p.x * pixSizeH / TILE_UNITS;
+ int y = player.p.z * pixSizeV / TILE_UNITS;
shortX = ((visibleTiles.x / 4) - (dif / 6)) * pixSizeH;
longX = ((visibleTiles.x / 2) - (dif / 4)) * pixSizeH;
@@ -601,8 +616,8 @@ static void drawViewingWindow(float radarX, float radarY, int x, int y, float pi
v[3].x = -shortX;
v[3].y = yDrop;
- centre.x = radarX + x - scrollMinX*pixSizeH;
- centre.y = radarY + y - scrollMinY*pixSizeV;
+ centre.x = x - scrollMinX * pixSizeH;
+ centre.y = y - scrollMinY * pixSizeV;
RotateVector2D(v,tv,&centre,player.r.y,4);
@@ -627,20 +642,16 @@ static void drawViewingWindow(float radarX, float radarY, int x, int y, float pi
colour.rgba = 0;
colour.byte.a = 0x3f;
break;
-
}
/* Send the four points to the draw routine and the clip box params */
- pie_DrawViewingWindow(tv, radarX, radarY, radarX + radarWidth, radarY + radarHeight, colour);
+ pie_SetViewingWindow(tv, colour);
}
-static void DrawRadarExtras(float radarX, float radarY, float pixSizeH, float pixSizeV)
+static void DrawRadarExtras()
{
- int viewX = player.p.x*pixSizeH / TILE_UNITS;
- int viewY = player.p.z*pixSizeV / TILE_UNITS;
-
- drawViewingWindow(radarX, radarY, viewX, viewY, pixSizeH, pixSizeV);
- RenderWindowFrame(FRAME_RADAR, radarX - 1, radarY - 1, radarWidth + 2, radarHeight + 2);
+ pie_DrawViewingWindow();
+ RenderWindowFrame(FRAME_RADAR, -1, -1, radarWidth + 2, radarHeight + 2);
}
/** Does a screen coordinate lie within the radar area? */
View
1  src/scriptfuncs.cpp
@@ -260,6 +260,7 @@ bool scrSetSunIntensity(void)
pie_Lighting0(LIGHT_AMBIENT, ambient);
pie_Lighting0(LIGHT_DIFFUSE, diffuse);
pie_Lighting0(LIGHT_SPECULAR, specular);
+ pie_SetupLighting();
return true;
}

No commit comments for this range

Something went wrong with that request. Please try again.