mirror of
https://github.com/jmarshall23/CnC_Remastered_Collection.git
synced 2026-08-12 08:00:55 +02:00
Merge remote-tracking branch 'upstream/master' into nev6502_branch
This commit is contained in:
+2
-2
@@ -1,4 +1,4 @@
|
||||
# CMakeList.txt : CMake project for Red Alert
|
||||
# CMakeList.txt : CMake project for Red Alert
|
||||
cmake_minimum_required (VERSION 3.8)
|
||||
|
||||
project(RedAlert ASM CXX C)
|
||||
@@ -715,4 +715,4 @@ add_executable(RedAlert ${src_win32lib} ${src_redalert} ${src_external})
|
||||
|
||||
set_target_properties(RedAlert PROPERTIES OUTPUT_NAME "RedAlert" LINK_FLAGS "/PDB:\"RedAlert.pdb\" /SUBSYSTEM:WINDOWS" RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/../" )
|
||||
target_include_directories(RedAlert PRIVATE ./external/devil/;./external/;./redalert/win32lib;./external/lua/;./external/imgui;./external/dxsdk/Include;./external/ffmpeg-win32/include;./external/sdl2/include;./win32lib;./external/openal/include)
|
||||
target_link_libraries(RedAlert "opengl32.lib" "winmm.lib" "Ws2_32.lib" "${CMAKE_SOURCE_DIR}/external/devil/DevIL.lib" "${CMAKE_SOURCE_DIR}/external/sdl2/lib/x86/SDL2.lib" "${CMAKE_SOURCE_DIR}/external/openal/out/build/x86-Release/OpenAL32.lib")
|
||||
target_link_libraries(RedAlert "opengl32.lib" "winmm.lib" "Ws2_32.lib" "${CMAKE_SOURCE_DIR}/external/devil/ilu.lib" "${CMAKE_SOURCE_DIR}/external/devil/DevIL.lib" "${CMAKE_SOURCE_DIR}/external/sdl2/lib/x86/SDL2.lib" "${CMAKE_SOURCE_DIR}/external/openal/out/build/x86-Release/OpenAL32.lib")
|
||||
|
||||
+31
-3
@@ -3140,6 +3140,19 @@ void BuildingTypeClass::One_Time(void)
|
||||
*/
|
||||
_makepath(fullname, NULL, NULL, building.Graphic_Name(), ".SHP");
|
||||
((void const *&)building.ImageData) = MFCD::Retrieve(fullname);
|
||||
{
|
||||
char imageFileName[512];
|
||||
sprintf(imageFileName, "DATA/ART/TEXTURES/SRGB/RED_ALERT/STRUCTURES/%s/%s-0000.TGA", building.Graphic_Name(), building.Graphic_Name());
|
||||
((void const*&)building.HDImageData) = Image_LoadImage(imageFileName, true, true);
|
||||
|
||||
if (building.ImageData != NULL && building.HDImageData != NULL) {
|
||||
int width = Get_Build_Frame_Width(building.ImageData);
|
||||
int height = Get_Build_Frame_Height(building.ImageData);
|
||||
|
||||
building.HDImageData->renderwidth = width;
|
||||
building.HDImageData->renderheight = height;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Try to load weap2.shp and tesla coil's lightning shapes
|
||||
@@ -3218,7 +3231,7 @@ void BuildingTypeClass::Display(int x, int y, WindowNumberType window, HousesTyp
|
||||
//CC_Draw_Shape((Image_t *)Get_HDImage_Data(), 0, x, y, window, SHAPE_CENTER | SHAPE_WIN_REL, NULL, NULL, DIR_N);
|
||||
x += WindowList[window][WINDOWX];
|
||||
y += WindowList[window][WINDOWY];
|
||||
GL_RenderImage(hdimage, x, y, hdimage->width, hdimage->height);
|
||||
GL_RenderImage(hdimage, x, y, hdimage->renderwidth, hdimage->renderheight);
|
||||
}
|
||||
else {
|
||||
void const* ptr = Get_Cameo_Data();
|
||||
@@ -3376,8 +3389,23 @@ void BuildingTypeClass::Init(TheaterType theater)
|
||||
// jmarshall
|
||||
{
|
||||
char imageFileName[512];
|
||||
sprintf(imageFileName, "textures/%s.png", fullname);
|
||||
((BuildingTypeClass *)classptr)->HDImageData = Image_LoadImage(imageFileName);
|
||||
|
||||
// Try load the theatre specific asset first
|
||||
sprintf(imageFileName, "DATA/ART/TEXTURES/SRGB/RED_ALERT/TERRAIN/%s/%s.%s/%s.%s-0000.DDS", Theaters[theater].Name, classptr->Graphic_Name(), Theaters[theater].Suffix, classptr->Graphic_Name(), Theaters[theater].Suffix);
|
||||
((BuildingTypeClass*)classptr)->HDImageData = Image_LoadImage(imageFileName);
|
||||
|
||||
if (!((BuildingTypeClass*)classptr)->HDImageData) {
|
||||
sprintf(imageFileName, "DATA/ART/TEXTURES/SRGB/RED_ALERT/STRUCTURES/%s/%s-0000.TGA", classptr->Graphic_Name(), classptr->Graphic_Name());
|
||||
((BuildingTypeClass*)classptr)->HDImageData = Image_LoadImage(imageFileName);
|
||||
}
|
||||
|
||||
if (classptr->ImageData != NULL && classptr->HDImageData != NULL) {
|
||||
int width = Get_Build_Frame_Width(classptr->ImageData);
|
||||
int height = Get_Build_Frame_Height(classptr->ImageData);
|
||||
|
||||
classptr->HDImageData->renderwidth = width;
|
||||
classptr->HDImageData->renderheight = height;
|
||||
}
|
||||
}
|
||||
// jmarshall end
|
||||
/*
|
||||
|
||||
@@ -3486,9 +3486,9 @@ void CC_Draw_Shape(Image_t* image, int shapenum, int x, int y, WindowNumberType
|
||||
if ((flags & SHAPE_GHOST) && (!ghostdata)) {
|
||||
ghostdata = DisplayClass::SpecialGhost;
|
||||
}
|
||||
if ((flags & SHAPE_FADING) && (!fadingdata)) {
|
||||
fadingdata = DisplayClass::FadingShade;
|
||||
}
|
||||
//if ((flags & SHAPE_FADING) && (!fadingdata)) {
|
||||
// fadingdata = DisplayClass::FadingShade;
|
||||
//}
|
||||
|
||||
static unsigned char* _xbuffer = 0;
|
||||
|
||||
@@ -3498,8 +3498,8 @@ void CC_Draw_Shape(Image_t* image, int shapenum, int x, int y, WindowNumberType
|
||||
|
||||
if (image != NULL && shapenum != -1) {
|
||||
|
||||
int width = image->width;
|
||||
int height = image->height;
|
||||
int width = image->renderwidth;
|
||||
int height = image->renderheight;
|
||||
|
||||
#ifdef NEVER
|
||||
/*
|
||||
@@ -3758,7 +3758,7 @@ void CC_Draw_Shape(void const * shapefile, int shapenum, int x, int y, WindowNum
|
||||
|
||||
{
|
||||
char tmp[512];
|
||||
sprintf(tmp, "s%d%d%d%d%d", shapefile, shapenum, rotation, fadingdata, flags);
|
||||
sprintf(tmp, "s_%d_%d_%d_%d_%d", shapefile, shapenum, rotation, fadingdata, flags);
|
||||
|
||||
if (flags & SHAPE_FADING) {
|
||||
shape_image = Image_CreateImageFrom8Bit(tmp, width, height, (unsigned char*)buffer, (unsigned char*)fadingdata);
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
// HOUSECOLOR.H
|
||||
//
|
||||
|
||||
#include "vectormath.h"
|
||||
|
||||
struct HouseColorHD {
|
||||
HouseColorHD(float3 lowerbounds,
|
||||
float3 upperbounds,
|
||||
float fudge,
|
||||
float3 hsvshift,
|
||||
float3 inputlevels,
|
||||
float2 outputlevels,
|
||||
float3 overallinputlevels,
|
||||
float2 overalloutputlevels,
|
||||
float3 radarmapcolor)
|
||||
{
|
||||
this->LowerBounds = lowerbounds;
|
||||
this->UpperBounds = upperbounds;
|
||||
this->Fudge = fudge;
|
||||
this->HSVShift = hsvshift;
|
||||
this->InputLevels = inputlevels;
|
||||
this->OutputLevels = outputlevels;
|
||||
this->OverallInputLevels = overallinputlevels;
|
||||
this->OverallOutputLevels = overalloutputlevels;
|
||||
this->RadarMapColor = radarmapcolor;
|
||||
}
|
||||
|
||||
float3 LowerBounds;
|
||||
float3 UpperBounds;
|
||||
float Fudge;
|
||||
float3 HSVShift;
|
||||
float3 InputLevels;
|
||||
float2 OutputLevels;
|
||||
float3 OverallInputLevels;
|
||||
float2 OverallOutputLevels;
|
||||
float3 RadarMapColor;
|
||||
};
|
||||
|
||||
// This data has been sourced from the TD Original Skirmish Color mod by Pokey
|
||||
//
|
||||
static HouseColorHD *houseColors[8] = {
|
||||
// Spain
|
||||
new HouseColorHD(float3(0.26, 1.0f, 0.0f), float3(0.0f, 1.0f, 0.22f), 0, float3(0.713,-0.621, 0.000000), float3(0.0f, 1.0f, 1.0f), float2(0.0f, 1.0f), float3(0.0f, 1.0f, 1.0f), float2(0.0f, 1.0f), float3(0.6421568, 0.4784698, 0.4784698)),
|
||||
// Greece
|
||||
new HouseColorHD(float3(0.264706f, 1.0f, 0.0f), float3(0.0f, 1.0f, 0.22f), 0, float3(0.310000f,-0.211000, 0.005000), float3(0.0f, 1.0f, 1.0f), float2(0.0f, 1.0f), float3(0.0f, 1.0f, 1.0f), float2(0.0f, 1.0f), float3(0.0980f, 0.3922, 0.9216)),
|
||||
// USSR
|
||||
new HouseColorHD(float3(0.264706f, 1.0f, 0.0f), float3(0.0f, 1.0f, 0.22f), 0, float3(0.689000f,0.382000, 0.000000), float3(0.0f, 1.0f, 1.0f), float2(0.0f, 1.0f), float3(0.0f, 1.0f, 1.0f), float2(0.0f, 1.0f), float3(0.756863f, 0.0, 0.015686)),
|
||||
// England
|
||||
new HouseColorHD(float3(0.26f, 1.0f, 1.0f), float3(0.0f, 1.0f, 0.22f), 0, float3(0.777f,-0.196, -0.0f), float3(0.0f, 1.0f, 1.0f), float2(0.0f, 1.0f), float3(0.0f, 1.0f, 1.0f), float2(0.0f, 1.0f), float3(0.737255, 0.627451, 0.239216)),
|
||||
// Ukraine
|
||||
new HouseColorHD(float3(0.26, 1.0f, 0.0f), float3(0.0f, 1.0f, 0.22f), 0, float3(0.726,0.119, 0.000000), float3(0.0f, 1.0f, 1.0f), float2(0.0f, 1.0f), float3(0.0f, 1.0f, 1.0f), float2(0.0f, 1.0f), float3(0.772549, 0.380392, 0.07451)),
|
||||
// Germany
|
||||
new HouseColorHD(float3(0.26, 1.0f, 0.0f), float3(0.0f, 1.0f, 0.22f), 0, float3(0.911f,-0.381, 0.000000), float3(0.0f, 1.0f, 1.0f), float2(0.0f, 1.0f), float3(0.0f, 1.0f, 1.0f), float2(0.0f, 1.0f), float3(0.184314, 0.67451, 0.141176)),
|
||||
// France
|
||||
new HouseColorHD(float3(0.26, 1.0f, 0.0f), float3(0.0f, 1.0f, 0.22f), 0, float3(0.119,-0.233, 0.000000), float3(0.0f, 1.0f, 1.0f), float2(0.0f, 1.0f), float3(0.0f, 1.0f, 1.0f), float2(0.0f, 1.0f), float3(0.1151961, 0.6911765, 0.4031861)),
|
||||
// Turkey
|
||||
new HouseColorHD(float3(0.26, 1.0f, 0.0f), float3(0.0f, 1.0f, 0.22f), 0, float3(0.685,-0.151, 0.000000), float3(0.0f, 1.0f, 1.0f), float2(0.0f, 1.0f), float3(0.0f, 1.0f, 1.0f), float2(0.0f, 1.0f), float3(0.5784314, 0.1155861, 0.05387352)),
|
||||
};
|
||||
@@ -0,0 +1,206 @@
|
||||
// IMGUTIL.H
|
||||
//
|
||||
|
||||
#ifdef _DEBUG
|
||||
#pragma optimize( "", on )
|
||||
#endif
|
||||
|
||||
// SRGB -> Linear color space conversion.
|
||||
inline float ByteToLinear(byte p) {
|
||||
float v;
|
||||
v = ((float)p) / 255.0f;
|
||||
v = (double)v >= 0.0404499992728233 ? (float)pow((200.0 * (double)v + 11.0) / 211.0, 2.40000009536743) : (float)((double)v * 25.0 / 323.0);
|
||||
return v;
|
||||
}
|
||||
|
||||
inline float ToSRGB(float v)
|
||||
{
|
||||
return (double)v >= 0.0031308 ? (float)((pow((double)v, 0.416666656732559) * 211.0 - 11.0) / 200.0) : (float)((double)v * 323.0 / 25.0);
|
||||
}
|
||||
|
||||
inline float PixelToHue(float R, float G, float B) {
|
||||
if (R == G && G == B)
|
||||
return 0; // 0 makes as good an UNDEFINED value as any
|
||||
|
||||
float r = (float)R / 255.0f;
|
||||
float g = (float)G / 255.0f;
|
||||
float b = (float)B / 255.0f;
|
||||
|
||||
float max, min;
|
||||
float delta;
|
||||
float hue = 0.0f;
|
||||
|
||||
max = r; min = r;
|
||||
|
||||
if (g > max) max = g;
|
||||
if (b > max) max = b;
|
||||
|
||||
if (g < min) min = g;
|
||||
if (b < min) min = b;
|
||||
|
||||
delta = max - min;
|
||||
|
||||
if (r == max) {
|
||||
hue = (g - b) / delta;
|
||||
}
|
||||
else if (g == max) {
|
||||
hue = 2 + (b - r) / delta;
|
||||
}
|
||||
else if (b == max) {
|
||||
hue = 4 + (r - g) / delta;
|
||||
}
|
||||
hue *= 60;
|
||||
|
||||
if (hue < 0.0f) {
|
||||
hue += 360.0f;
|
||||
}
|
||||
return hue;
|
||||
}
|
||||
|
||||
struct Turple {
|
||||
Turple() {
|
||||
memset(this, 0, sizeof(Turple));
|
||||
}
|
||||
Turple(float Item1, float Item2, float Item3) {
|
||||
this->Item1 = Item1;
|
||||
this->Item2 = Item2;
|
||||
this->Item3 = Item3;
|
||||
this->Item4 = -1;
|
||||
}
|
||||
Turple(float Item1, float Item2, float Item3, float Item4) {
|
||||
this->Item1 = Item1;
|
||||
this->Item2 = Item2;
|
||||
this->Item3 = Item3;
|
||||
this->Item4 = Item4;
|
||||
}
|
||||
float Item1;
|
||||
float Item2;
|
||||
float Item3;
|
||||
float Item4;
|
||||
};
|
||||
|
||||
|
||||
float step(float a, float x)
|
||||
{
|
||||
return x >= a;
|
||||
}
|
||||
|
||||
inline float4 lerp(float4 a, float4 b, float w)
|
||||
{
|
||||
float4 l;
|
||||
l.x = a.x + w * (b.x - a.x);
|
||||
l.y = a.y + w * (b.y - a.y);
|
||||
l.z = a.z + w * (b.z - a.z);
|
||||
l.w = a.w + w * (b.w - a.w);
|
||||
return l;
|
||||
}
|
||||
|
||||
inline float3 lerp(float3 a, float3 b, float w)
|
||||
{
|
||||
float3 l;
|
||||
l.x = a.x + w * (b.x - a.x);
|
||||
l.y = a.y + w * (b.y - a.y);
|
||||
l.z = a.z + w * (b.z - a.z);
|
||||
return l;
|
||||
}
|
||||
|
||||
inline float3 frac(float3 v)
|
||||
{
|
||||
float3 f;
|
||||
f.x = v.x - floor(v.x);
|
||||
f.y = v.y - floor(v.y);
|
||||
f.z = v.z - floor(v.z);
|
||||
return f;
|
||||
}
|
||||
|
||||
inline float frac(float v)
|
||||
{
|
||||
return v - floor(v);
|
||||
}
|
||||
|
||||
inline float lerp(float a, float b, float w)
|
||||
{
|
||||
return a + w * (b - a);
|
||||
}
|
||||
|
||||
|
||||
inline float3 clamp(float3 x, float a, float b)
|
||||
{
|
||||
float3 r;
|
||||
r.x = max(a, min(b, x.x));
|
||||
r.y = max(a, min(b, x.y));
|
||||
r.z = max(a, min(b, x.z));
|
||||
return r;
|
||||
}
|
||||
|
||||
inline float saturate(float x)
|
||||
{
|
||||
return max(0, min(1, x));
|
||||
}
|
||||
|
||||
inline void RenderTeamPalette(byte* pixel, HouseColorHD &teamColor) {
|
||||
float linear1 = ByteToLinear(pixel[2]);
|
||||
float linear2 = ByteToLinear(pixel[1]);
|
||||
float linear3 = ByteToLinear(pixel[0]);
|
||||
float num1 = linear1;
|
||||
float num2 = linear2;
|
||||
float num3 = (float)linear3;
|
||||
Turple valueTuple1 = Turple(0.0f, -0.3333333, 0.6666667, -1 );
|
||||
Turple valueTuple2;
|
||||
|
||||
if ((double)num2 >= (double)num3)
|
||||
valueTuple2 = Turple( num2, num3, valueTuple1.Item1, valueTuple1.Item2 );
|
||||
else
|
||||
valueTuple2 = Turple( num3, num2, valueTuple1.Item4, valueTuple1.Item3 );
|
||||
|
||||
Turple valueTuple3;
|
||||
if ((double)num1 >= (double)valueTuple2.Item1)
|
||||
valueTuple3 = Turple(num1, valueTuple2.Item2, valueTuple2.Item3, valueTuple2.Item1);
|
||||
else
|
||||
valueTuple3 = Turple(valueTuple2.Item1, valueTuple2.Item2, valueTuple2.Item4, num1);
|
||||
double num4 = (double)valueTuple3.Item1 - (double)min(valueTuple3.Item4, valueTuple3.Item2);
|
||||
float num5 = 1E-10f;
|
||||
float num6 = (float)num4;
|
||||
float num7 = num5;
|
||||
float num8 = abs(valueTuple3.Item3 + (float)(((double)valueTuple3.Item4 - (double)valueTuple3.Item2) / (6.0 * (double)num6 + (double)num7)));
|
||||
float num9 = num6 / (valueTuple3.Item1 + num7);
|
||||
double num10 = (double)valueTuple3.Item1;
|
||||
float num11 = num8;
|
||||
float num12 = num9;
|
||||
float num13 = (float)num10;
|
||||
float num14 = PixelToHue(teamColor.LowerBounds.x, teamColor.LowerBounds.y, teamColor.LowerBounds.z) / 360;
|
||||
float num15 = PixelToHue(teamColor.UpperBounds.x, teamColor.UpperBounds.y, teamColor.UpperBounds.z) / 360;
|
||||
|
||||
if ((double)num11 >= (double)num14 && (double)num15 >= (double)num11)
|
||||
{
|
||||
float num16 = (float)((double)num11 / ((double)num15 - (double)num14) * ((double)num15 + (double)teamColor.Fudge - ((double)num14 - (double)teamColor.Fudge))) + teamColor.HSVShift.x;
|
||||
float t = num12 + teamColor.HSVShift.y;
|
||||
float num17 = num13 + teamColor.HSVShift.z;
|
||||
Turple valueTuple4 = Turple(1.0f, 0.6666667, 0.3333333, 3);
|
||||
Turple valueTuple5 = Turple(abs(frac(num16 + valueTuple4.Item1) * 6 - valueTuple4.Item4), abs(frac(num16 + valueTuple4.Item2) * 6 - valueTuple4.Item4), abs(frac(num16 + valueTuple4.Item3) * 6 - valueTuple4.Item4));
|
||||
float num18 = num17 * lerp(valueTuple4.Item1, saturate(valueTuple5.Item1 - valueTuple4.Item1), t);
|
||||
float num19 = num17 * lerp(valueTuple4.Item1, saturate(valueTuple5.Item2 - valueTuple4.Item1), t);
|
||||
float num20 = num17 * lerp(valueTuple4.Item1, saturate(valueTuple5.Item3 - valueTuple4.Item1), t);
|
||||
Turple valueTuple6 = Turple(min(1, max(0.0f, num18 - teamColor.InputLevels.x) / (teamColor.InputLevels.z - teamColor.InputLevels.x)), min(1, max(0.0f, num19 - teamColor.InputLevels.x) / (teamColor.InputLevels.z - teamColor.InputLevels.x)), min(1, max(0.0f, num20 - teamColor.InputLevels.x) / (teamColor.InputLevels.z - teamColor.InputLevels.x)));
|
||||
valueTuple6.Item1 = (float)pow((double)valueTuple6.Item1, (double)teamColor.InputLevels.y);
|
||||
valueTuple6.Item2 = (float)pow((double)valueTuple6.Item2, (double)teamColor.InputLevels.y);
|
||||
valueTuple6.Item3 = (float)pow((double)valueTuple6.Item3, (double)teamColor.InputLevels.y);
|
||||
num1 = lerp(teamColor.OutputLevels.x, teamColor.OutputLevels.y, valueTuple6.Item1);
|
||||
num2 = lerp(teamColor.OutputLevels.x, teamColor.OutputLevels.y, valueTuple6.Item2);
|
||||
num3 = lerp(teamColor.OutputLevels.x, teamColor.OutputLevels.y, valueTuple6.Item3);
|
||||
}
|
||||
|
||||
Turple valueTuple7 = Turple(min(1, max(0.0f, num1 - teamColor.OverallInputLevels.x) / (teamColor.OverallInputLevels.z - teamColor.OverallInputLevels.x)), min(1, max(0.0f, num2 - teamColor.OverallInputLevels.x) / (teamColor.OverallInputLevels.z - teamColor.OverallInputLevels.x)), min(1, max(0.0f, num3 - teamColor.OverallInputLevels.x) / (teamColor.OverallInputLevels.z - teamColor.OverallInputLevels.x)));
|
||||
valueTuple7.Item1 = (float)pow((double)valueTuple7.Item1, (double)teamColor.OverallInputLevels.y);
|
||||
valueTuple7.Item2 = (float)pow((double)valueTuple7.Item2, (double)teamColor.OverallInputLevels.y);
|
||||
valueTuple7.Item3 = (float)pow((double)valueTuple7.Item3, (double)teamColor.OverallInputLevels.y);
|
||||
float v1 = lerp(teamColor.OverallOutputLevels.x, teamColor.OverallOutputLevels.y, valueTuple7.Item1);
|
||||
float v2 = lerp(teamColor.OverallOutputLevels.x, teamColor.OverallOutputLevels.y, valueTuple7.Item2);
|
||||
float v3 = lerp(teamColor.OverallOutputLevels.x, teamColor.OverallOutputLevels.y, valueTuple7.Item3);
|
||||
pixel[2] = (byte)((double)ToSRGB(v1) * (double)255.0f);
|
||||
pixel[1] = (byte)((double)ToSRGB(v2) * (double)255.0f);
|
||||
pixel[0] = (byte)((double)ToSRGB(v3) * (double)255.0f);
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
#pragma optimize( "", off )
|
||||
#endif
|
||||
+15
-8
@@ -1,27 +1,34 @@
|
||||
// Image.h
|
||||
//
|
||||
|
||||
#define MAX_IMAGE_FRAMES 256
|
||||
#define MAX_HOUSE_COLORS 8
|
||||
struct Image_t {
|
||||
Image_t();
|
||||
~Image_t();
|
||||
|
||||
char name[512];
|
||||
unsigned int image;
|
||||
int64_t namehash;
|
||||
unsigned int image[MAX_HOUSE_COLORS][MAX_IMAGE_FRAMES];
|
||||
unsigned int numAnimFrames;
|
||||
int width;
|
||||
int height;
|
||||
unsigned char* buffer;
|
||||
int renderwidth;
|
||||
int renderheight;
|
||||
//unsigned char* buffer[MAX_HOUSE_COLORS][MAX_IMAGE_FRAMES];
|
||||
};
|
||||
|
||||
__forceinline Image_t::Image_t() {
|
||||
buffer = NULL;
|
||||
// buffer = NULL;
|
||||
numAnimFrames = 0;
|
||||
}
|
||||
|
||||
__forceinline Image_t::~Image_t() {
|
||||
if (buffer) {
|
||||
delete buffer;
|
||||
buffer = NULL;
|
||||
}
|
||||
//if (buffer) {
|
||||
// delete buffer;
|
||||
// buffer = NULL;
|
||||
//}
|
||||
}
|
||||
|
||||
Image_t* Image_LoadImage(const char* name);
|
||||
Image_t* Image_LoadImage(const char* name, bool loadAnims = false, bool loadHouseColor = false);
|
||||
Image_t* Image_CreateImageFrom8Bit(const char* name, int Width, int Height, unsigned char* data, unsigned char *remap = NULL);
|
||||
@@ -18,10 +18,10 @@ void GL_ResetClipRect(void) {
|
||||
ImGui::GetForegroundDrawList()->PopClipRect();
|
||||
}
|
||||
|
||||
void GL_RenderImage(Image_t* image, int x, int y, int width, int height) {
|
||||
void GL_RenderImage(Image_t* image, int x, int y, int width, int height, int colorRemap) {
|
||||
ImVec2 mi(x, y);
|
||||
ImVec2 ma(x + width, y + height);
|
||||
ImGui::GetForegroundDrawList()->AddImage((ImTextureID)image->image, mi, ma);
|
||||
ImGui::GetForegroundDrawList()->AddImage((ImTextureID)image->image[colorRemap][0], mi, ma);
|
||||
}
|
||||
|
||||
void GL_FillRect(int color, int x, int y, int width, int height) {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
|
||||
struct Image_t;
|
||||
void GL_RenderImage(Image_t* image, int x, int y, int width, int height);
|
||||
void GL_RenderImage(Image_t* image, int x, int y, int width, int height, int colorRemap = 0);
|
||||
void GL_DrawText(int color, int x, int y, char* text);
|
||||
void GL_FillRect(int color, int x, int y, int width, int height);
|
||||
void GL_DrawLine(int color, int x, int y, int dx, int dy);
|
||||
|
||||
@@ -2182,7 +2182,8 @@ ObjectTypeClass::ObjectTypeClass(
|
||||
Armor(ARMOR_NONE),
|
||||
MaxStrength(0),
|
||||
ImageData(0),
|
||||
RadarIcon(0)
|
||||
RadarIcon(0),
|
||||
HDImageData(0)
|
||||
{
|
||||
/*
|
||||
** Init the DimensionData rect. Not sure how this was ever working before without being allocated. It was just trashing
|
||||
|
||||
+16
-8
@@ -67,7 +67,7 @@
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
#include "function.h"
|
||||
|
||||
#include "Image.h"
|
||||
|
||||
//void const * RadarClass::CoverShape;
|
||||
RadarClass::RTacticalClass RadarClass::RadarButton;
|
||||
@@ -1073,7 +1073,7 @@ void RadarClass::Plot_Radar_Pixel(CELL cell)
|
||||
*/
|
||||
if (color == TBLACK) {
|
||||
if (ZoomFactor > 1) {
|
||||
void const * ptr = NULL;
|
||||
const TemplateTypeClass* ptr = NULL;
|
||||
int icon;
|
||||
|
||||
/*
|
||||
@@ -1081,7 +1081,7 @@ void RadarClass::Plot_Radar_Pixel(CELL cell)
|
||||
** specified cell.
|
||||
*/
|
||||
if (cellptr->TType != TEMPLATE_NONE && cellptr->TType != 255) {
|
||||
ptr = TemplateTypeClass::As_Reference(cellptr->TType).Get_Image_Data();
|
||||
ptr = &TemplateTypeClass::As_Reference(cellptr->TType);
|
||||
icon = cellptr->TIcon;
|
||||
}
|
||||
|
||||
@@ -1090,11 +1090,11 @@ void RadarClass::Plot_Radar_Pixel(CELL cell)
|
||||
** template or an illegal one. Setup for a clear template.
|
||||
*/
|
||||
if (ptr == NULL) {
|
||||
ptr = TemplateTypeClass::As_Reference(TEMPLATE_CLEAR1).Get_Image_Data();
|
||||
ptr = &TemplateTypeClass::As_Reference(TEMPLATE_CLEAR1);
|
||||
icon = cellptr->Clear_Icon();
|
||||
}
|
||||
|
||||
IconsetClass const * iconset = (IconsetClass const *)ptr;
|
||||
IconsetClass const * iconset = (IconsetClass const *)ptr->Get_Image_Data();
|
||||
unsigned char const * icondata = iconset->Icon_Data();
|
||||
|
||||
|
||||
@@ -1103,10 +1103,18 @@ void RadarClass::Plot_Radar_Pixel(CELL cell)
|
||||
*/
|
||||
icon &= 0x00FF;
|
||||
icon = *(iconset->Map_Data() + icon);
|
||||
|
||||
// jmarshall
|
||||
unsigned char * data = (unsigned char *)icondata + icon*(24*24);
|
||||
Buffer_To_Page(0, 0, 24, 24, data, _TileStage);
|
||||
_TileStage.Scale(*LogicPage, 0, 0, x, y, 24, 24, ZoomFactor, ZoomFactor, TRUE);
|
||||
Image_t* image;
|
||||
{
|
||||
char tmp[512];
|
||||
sprintf(tmp, "radar_%d_%d", ptr->Type, icon);
|
||||
image = Image_CreateImageFrom8Bit(tmp, 24, 24, (unsigned char*)data);
|
||||
}
|
||||
GL_RenderImage(image, x, y, ZoomFactor, ZoomFactor);
|
||||
// jmarshall end
|
||||
//Buffer_To_Page(0, 0, 24, 24, data, _TileStage);
|
||||
//_TileStage.Scale(*LogicPage, 0, 0, x, y, 24, 24, ZoomFactor, ZoomFactor, TRUE);
|
||||
} else {
|
||||
// LogicPage->Fill_Rect(x, y, x+ZoomFactor-1, y+ZoomFactor-1, cellptr->Cell_Color(false));
|
||||
/*BG*/ LogicPage->Put_Pixel(x, y, cellptr->Cell_Color(false));
|
||||
|
||||
@@ -1546,8 +1546,10 @@ long Buffer_Frame_To_Page(int x, int y, int width, int height, struct Image_t *
|
||||
xstart = xstart + WindowList[Window][WINDOWX];// + LogicPage->Get_XPos();
|
||||
ystart = ystart + WindowList[Window][WINDOWY];// + LogicPage->Get_YPos();
|
||||
//GL_SetClipRect(WindowList[Window][WINDOWX], WindowList[Window][WINDOWY], WindowList[Window][WINDOWWIDTH], WindowList[Window][WINDOWWIDTH]);
|
||||
GL_RenderImage(shape_image, xstart, ystart, width, height);
|
||||
|
||||
if(renderHDTexture)
|
||||
GL_RenderImage(shape_image, xstart, ystart, width, height, (int)fade_table);
|
||||
else
|
||||
GL_RenderImage(shape_image, xstart, ystart, width, height, 0);
|
||||
|
||||
// Here we just use the function that will blit the entire frame
|
||||
// using the appropriate effects.
|
||||
|
||||
@@ -4451,11 +4451,17 @@ VisualType TechnoClass::Visual_Character(bool raw) const
|
||||
}
|
||||
|
||||
void TechnoClass::Techno_Draw_Object_HD(struct Image_t* image, int shapenum, int x, int y, WindowNumberType window, DirType rotation, int scale) const {
|
||||
void const* remap = Remap_Table();
|
||||
//void const* remap = Remap_Table();
|
||||
void const* shadow = Map.UnitShadow;
|
||||
|
||||
y -= Lepton_To_Pixel(Height);
|
||||
CC_Draw_Shape(image, shapenum, x, y, window, SHAPE_CENTER | SHAPE_WIN_REL | SHAPE_FADING | SHAPE_GHOST, remap, shadow, rotation);
|
||||
PlayerColorType remapColor = PCOLOR_GOLD;
|
||||
if (Techno_Type_Class()->IsRemappable) {
|
||||
remapColor = House->RemapColor;
|
||||
}
|
||||
|
||||
y -= Lepton_To_Pixel(Height);
|
||||
|
||||
CC_Draw_Shape(image, shapenum, x, y, window, SHAPE_CENTER | SHAPE_WIN_REL | SHAPE_FADING | SHAPE_GHOST, (const void *)remapColor, shadow, rotation);
|
||||
}
|
||||
|
||||
/***********************************************************************************************
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
|
||||
|
||||
#include "function.h"
|
||||
|
||||
#include "Image.h"
|
||||
|
||||
// Submarine
|
||||
static VesselTypeClass const VesselSubmarine(
|
||||
@@ -578,7 +578,6 @@ void VesselTypeClass::One_Time(void)
|
||||
*/
|
||||
_makepath(fullname, NULL, NULL, uclass.Graphic_Name(), ".SHP");
|
||||
((void const *&)uclass.ImageData) = MFCD::Retrieve(fullname);
|
||||
|
||||
((int &)uclass.MaxSize) = 26;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,7 +252,7 @@ void WWMouseClass::RenderMouse(void) {
|
||||
|
||||
|
||||
ImGui::SetMouseCursor(ImGuiMouseCursor_None);
|
||||
ImGui::GetForegroundDrawList()->AddImage((ImTextureID)current_cursor->image, mi, ma);
|
||||
ImGui::GetForegroundDrawList()->AddImage((ImTextureID)current_cursor->image[0][0], mi, ma);
|
||||
}
|
||||
|
||||
void WWMouseClass::Low_Show_Mouse(int x, int y)
|
||||
|
||||
+181
-28
@@ -45,6 +45,7 @@
|
||||
#include "examples/imgui_impl_sdl.h"
|
||||
#include "function.h"
|
||||
#include "il/il.h"
|
||||
#include "il/ilu.h"
|
||||
#include "image.h"
|
||||
|
||||
#ifdef WINSOCK_IPX
|
||||
@@ -62,6 +63,8 @@
|
||||
#include <examples/imgui_impl_opengl3.h>
|
||||
|
||||
#include <vector>
|
||||
#include "HOUSECOLOR.H"
|
||||
#include "IMGUTIL.H"
|
||||
|
||||
GLuint backbuffer_texture = -1;
|
||||
//byte* backbuffer_data;
|
||||
@@ -90,11 +93,81 @@ void Show_OldFrameBuffer(bool show) {
|
||||
|
||||
std::vector<Image_t *> loaded_images;
|
||||
|
||||
Image_t* Image_LoadImage(const char* name) {
|
||||
// Check to see if the image is already loaded.
|
||||
for (int i = 0; i < loaded_images.size(); i++) {
|
||||
if (!strcmp(loaded_images[i]->name, name)) {
|
||||
return loaded_images[i];
|
||||
unsigned char* Draw_Dropsample(const unsigned char* in, int inwidth, int inheight, int outwidth, int outheight);
|
||||
|
||||
/*
|
||||
================
|
||||
return a hash value for the filename
|
||||
================
|
||||
*/
|
||||
static int64_t generateHashValue(const char* fname, const int size) {
|
||||
uint32_t hash = 0x811c9dc5;
|
||||
uint32_t prime = 0x1000193;
|
||||
|
||||
for (int i = 0; i < size; ++i) {
|
||||
uint8_t value = fname[i];
|
||||
hash = hash ^ value;
|
||||
hash *= prime;
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
Image_WriteTGA
|
||||
================
|
||||
*/
|
||||
void Image_WriteTGA(const char* filename, const byte* data, int width, int height, bool flipVertical) {
|
||||
byte* buffer;
|
||||
int i;
|
||||
int bufferSize = width * height * 4 + 18;
|
||||
int imgStart = 18;
|
||||
|
||||
buffer = (byte*)malloc(bufferSize);
|
||||
memset(buffer, 0, 18);
|
||||
buffer[2] = 2; // uncompressed type
|
||||
buffer[12] = width & 255;
|
||||
buffer[13] = width >> 8;
|
||||
buffer[14] = height & 255;
|
||||
buffer[15] = height >> 8;
|
||||
buffer[16] = 32; // pixel size
|
||||
|
||||
if (!flipVertical) {
|
||||
buffer[17] = (1 << 5); // flip bit, for normal top to bottom raster order
|
||||
}
|
||||
|
||||
// swap rgba to bgra
|
||||
for (i = imgStart; i < bufferSize; i += 4) {
|
||||
buffer[i] = data[i - imgStart + 2]; // blue
|
||||
buffer[i + 1] = data[i - imgStart + 1]; // green
|
||||
buffer[i + 2] = data[i - imgStart + 0]; // red
|
||||
buffer[i + 3] = data[i - imgStart + 3]; // alpha
|
||||
}
|
||||
char temp[512];
|
||||
strcpy(temp, filename);
|
||||
COM_SetExtension(temp, strlen(temp), ".tga");
|
||||
FILE* f = fopen(temp, "wb");
|
||||
fwrite(buffer, 1, bufferSize, f);
|
||||
fclose(f);
|
||||
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
|
||||
static char* Image_GetGeneratedName(Image_t* image, const char* name, int houseid, int animid, int64_t hash) {
|
||||
static char generatedFileName[1024];
|
||||
sprintf(generatedFileName, "cache/%d.%d.%d.tga", hash, houseid, animid);
|
||||
return &generatedFileName[0];
|
||||
}
|
||||
|
||||
static bool Image_loadHDImage(Image_t *image, const char* name, int houseid, int animid, int64_t hash, bool writeGenerated) {
|
||||
// Check to see if we can load a generated image first.
|
||||
// We only generate images that need a houseid
|
||||
if (!writeGenerated && houseid >= 0) {
|
||||
char* generatedImageName = Image_GetGeneratedName(image, name, houseid, animid, hash);
|
||||
if (Image_loadHDImage(image, generatedImageName, houseid, animid, hash, true)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +176,13 @@ Image_t* Image_LoadImage(const char* name) {
|
||||
ilBindImage(ImageName);
|
||||
if (!ilLoadImage(name)) {
|
||||
ilDeleteImages(1, &ImageName);
|
||||
return NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool swapBGR = false;
|
||||
if (strstr(name, ".TGA")) {
|
||||
iluFlipImage();
|
||||
swapBGR = true;
|
||||
}
|
||||
|
||||
ILuint Width, Height, Bpp;
|
||||
@@ -112,12 +191,28 @@ Image_t* Image_LoadImage(const char* name) {
|
||||
Bpp = ilGetInteger(IL_IMAGE_BPP);
|
||||
ILubyte* Data = ilGetData();
|
||||
|
||||
if (Bpp == 4 && houseid != -1 && !writeGenerated) {
|
||||
//Buffer_Enable_HD_Texture(true);
|
||||
//Data = Draw_Dropsample(Data, Width, Height, Width / 2, Height / 2);
|
||||
//Buffer_Enable_HD_Texture(false);
|
||||
//Width = Width / 2;
|
||||
//Height = Height / 2;
|
||||
for (int i = 0; i < Width * Height; i++) {
|
||||
RenderTeamPalette(&Data[i * 4], *houseColors[houseid]);
|
||||
}
|
||||
}
|
||||
|
||||
GLuint texture;
|
||||
glGenTextures(1, &texture);
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
|
||||
if (Bpp == 4) {
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, Width, Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, Data);
|
||||
if (swapBGR) {
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, Width, Height, 0, GL_BGRA, GL_UNSIGNED_BYTE, Data);
|
||||
}
|
||||
else {
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, Width, Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, Data);
|
||||
}
|
||||
}
|
||||
else if (Bpp == 3) {
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, Width, Height, 0, GL_RGB, GL_UNSIGNED_BYTE, Data);
|
||||
@@ -132,32 +227,87 @@ Image_t* Image_LoadImage(const char* name) {
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
|
||||
Image_t* image = new Image_t();
|
||||
|
||||
strcpy(image->name, name);
|
||||
image->image = texture;
|
||||
image->width = Width;
|
||||
image->height = Height;
|
||||
image->buffer = new unsigned char[Width * Height * Bpp];
|
||||
memcpy(image->buffer, Data, Width * Height * Bpp);
|
||||
loaded_images.push_back(image);
|
||||
|
||||
if(houseid == -1)
|
||||
image->image[0][animid] = texture;
|
||||
else
|
||||
image->image[houseid][animid] = texture;
|
||||
image->namehash = hash;
|
||||
image->renderwidth = image->width = Width;
|
||||
image->renderheight = image->height = Height;
|
||||
//image->buffer[houseid][animid] = new unsigned char[Width * Height * Bpp];
|
||||
//memcpy(image->buffer[houseid][animid], Data, Width * Height * Bpp);
|
||||
|
||||
if (!writeGenerated && Bpp == 4 && houseid >= 0) {
|
||||
char* generatedImageName = Image_GetGeneratedName(image, name, houseid, animid, hash);
|
||||
Image_WriteTGA(generatedImageName, Data, Width, Height, false);
|
||||
}
|
||||
|
||||
ilDeleteImages(1, &ImageName);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Image_t* Image_LoadImage(const char* name, bool loadAnims, bool loadHouseColor) {
|
||||
int64_t hash = generateHashValue(name, strlen(name));
|
||||
|
||||
int image_table_size = loaded_images.size();
|
||||
if (image_table_size > 0)
|
||||
{
|
||||
Image_t** image_table = &loaded_images[0];
|
||||
|
||||
// Check to see if the image is already loaded.
|
||||
for (int i = 0; i < image_table_size; i++) {
|
||||
if (image_table[i]->namehash == hash) {
|
||||
return image_table[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
Image_t* image = new Image_t();
|
||||
|
||||
if (!loadAnims) {
|
||||
unsigned char remap[3] = { 0, 0, 0 };
|
||||
if (!Image_loadHDImage(image, name, -1, 0, hash, false)) {
|
||||
delete image;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
byte* palette = (byte *)CCPalette.Get_Data();
|
||||
for (int i = 0; i < MAX_MPLAYER_COLORS; i++) {
|
||||
if (!Image_loadHDImage(image, name, i, 0, hash, false)) {
|
||||
delete image;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
loaded_images.push_back(image);
|
||||
return image;
|
||||
}
|
||||
|
||||
Image_t* Image_CreateImageFrom8Bit(const char* name, int Width, int Height, unsigned char *data, unsigned char* remap) {
|
||||
// Check to see if the image is already loaded.
|
||||
for (int i = 0; i < loaded_images.size(); i++) {
|
||||
if (!strcmp(loaded_images[i]->name, name)) {
|
||||
return loaded_images[i];
|
||||
int64_t hash = generateHashValue(name, strlen(name));
|
||||
|
||||
int image_table_size = loaded_images.size();
|
||||
if (image_table_size > 0)
|
||||
{
|
||||
Image_t** image_table = &loaded_images[0];
|
||||
|
||||
// Check to see if the image is already loaded.
|
||||
for (int i = 0; i < image_table_size; i++) {
|
||||
if (image_table[i]->namehash == hash) {
|
||||
return image_table[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsigned char* ccpalete = (unsigned char*)CCPalette.Get_Data();
|
||||
|
||||
Image_t* image = new Image_t();
|
||||
image->buffer = new unsigned char[Width * Height * 4];
|
||||
unsigned char *buffer = new unsigned char[Width * Height * 4];
|
||||
|
||||
for (int i = 0; i < Width * Height; i++) {
|
||||
unsigned char c = data[i];
|
||||
@@ -181,10 +331,10 @@ Image_t* Image_CreateImageFrom8Bit(const char* name, int Width, int Height, unsi
|
||||
}
|
||||
|
||||
|
||||
image->buffer[(i * 4) + 0] = r;
|
||||
image->buffer[(i * 4) + 1] = g;
|
||||
image->buffer[(i * 4) + 2] = b;
|
||||
image->buffer[(i * 4) + 3] = a;
|
||||
buffer[(i * 4) + 0] = r;
|
||||
buffer[(i * 4) + 1] = g;
|
||||
buffer[(i * 4) + 2] = b;
|
||||
buffer[(i * 4) + 3] = a;
|
||||
}
|
||||
|
||||
|
||||
@@ -192,16 +342,19 @@ Image_t* Image_CreateImageFrom8Bit(const char* name, int Width, int Height, unsi
|
||||
glGenTextures(1, &texture);
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, Width, Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image->buffer);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, Width, Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
|
||||
|
||||
strcpy(image->name, name);
|
||||
image->image = texture;
|
||||
image->width = Width;
|
||||
image->height = Height;
|
||||
image->image[0][0] = texture;
|
||||
image->numAnimFrames = -1;
|
||||
image->namehash = hash;
|
||||
image->renderwidth = image->width = Width;
|
||||
image->renderheight = image->height = Height;
|
||||
loaded_images.push_back(image);
|
||||
delete buffer;
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -492,6 +492,7 @@ extern bool CanVblankSync;
|
||||
*=============================================================================================*/
|
||||
void GScreenClass::Blit_Display(void)
|
||||
{
|
||||
#if 0 // jmarshall - no longer used and saves on performance to disable it(3.6%).
|
||||
if (SeenBuff.Get_Width()!=320){
|
||||
#if (0)
|
||||
if (HidPage.Get_IsDirectDraw() && (Options.GameSpeed >1 || Options.ScrollRate==6 && CanVblankSync) ){
|
||||
@@ -520,7 +521,7 @@ void GScreenClass::Blit_Display(void)
|
||||
// ST - 1/2/2019 5:26PM
|
||||
//ModeX_Blit (&HiddenPage);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
Vendored
BIN
Binary file not shown.
Reference in New Issue
Block a user