Skip to content

Commit 40afe82

Browse files
committed
unify(video): Merge Video code (#1410)
1 parent 3db9373 commit 40afe82

File tree

12 files changed

+52
-34
lines changed

12 files changed

+52
-34
lines changed

Core/GameEngineDevice/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ set(GAMEENGINEDEVICE_SRC
7070
# Include/W3DDevice/GameClient/W3DTerrainTracks.h
7171
# Include/W3DDevice/GameClient/W3DTerrainVisual.h
7272
# Include/W3DDevice/GameClient/W3DTreeBuffer.h
73-
# Include/W3DDevice/GameClient/W3DVideobuffer.h
73+
# Include/W3DDevice/GameClient/W3DVideoBuffer.h
7474
# Include/W3DDevice/GameClient/W3DView.h
7575
# Include/W3DDevice/GameClient/W3DVolumetricShadow.h
7676
# Include/W3DDevice/GameClient/W3DWater.h

Generals/Code/GameEngineDevice/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ set(GAMEENGINEDEVICE_SRC
5959
Include/W3DDevice/GameClient/W3DTerrainTracks.h
6060
Include/W3DDevice/GameClient/W3DTerrainVisual.h
6161
Include/W3DDevice/GameClient/W3DTreeBuffer.h
62-
Include/W3DDevice/GameClient/W3DVideobuffer.h
62+
Include/W3DDevice/GameClient/W3DVideoBuffer.h
6363
Include/W3DDevice/GameClient/W3DView.h
6464
Include/W3DDevice/GameClient/W3DVolumetricShadow.h
6565
Include/W3DDevice/GameClient/W3DWater.h

Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ static void drawFramerateBar(void);
7474
#include "W3DDevice/GameClient/W3DScene.h"
7575
#include "W3DDevice/GameClient/W3DTerrainTracks.h"
7676
#include "W3DDevice/GameClient/W3DWater.h"
77-
#include "W3DDevice/GameClient/W3DVideobuffer.h"
77+
#include "W3DDevice/GameClient/W3DVideoBuffer.h"
7878
#include "W3DDevice/GameClient/W3DShaderManager.h"
7979
#include "W3DDevice/GameClient/W3DDebugDisplay.h"
8080
#include "W3DDevice/GameClient/W3DProjectedShadow.h"

Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DShroud.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,9 @@ void W3DShroud::init(WorldHeightMap *pMap, Real worldCellSizeX, Real worldCellSi
128128
dstTextureWidth=m_numMaxVisibleCellsX=REAL_TO_INT_FLOOR((Real)(pMap->getDrawWidth()-1)*MAP_XY_FACTOR/m_cellWidth)+1;
129129
dstTextureHeight=m_numMaxVisibleCellsY=REAL_TO_INT_FLOOR((Real)(pMap->getDrawHeight()-1)*MAP_XY_FACTOR/m_cellHeight)+1;
130130
dstTextureWidth += 2; //enlarge by 2 pixels so we can have a border color all the way around.
131+
unsigned int depth = 1;
131132
dstTextureHeight += 2; //enlarge by 2 pixels so we can have border color all the way around.
132-
TextureLoader::Validate_Texture_Size((unsigned int &)dstTextureWidth,(unsigned int &)dstTextureHeight);
133+
TextureLoader::Validate_Texture_Size((unsigned int &)dstTextureWidth,(unsigned int &)dstTextureHeight, depth);
133134
}
134135

135136
UnsignedInt srcWidth,srcHeight;

Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DVideoBuffer.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
#include "Common/GameMemory.h"
4949
#include "WW3D2/texture.h"
5050
#include "WW3D2/textureloader.h"
51-
#include "W3DDevice/GameClient/W3DVideobuffer.h"
51+
#include "W3DDevice/GameClient/W3DVideoBuffer.h"
5252

5353
//----------------------------------------------------------------------------
5454
// Externals
@@ -122,7 +122,8 @@ Bool W3DVideoBuffer::allocate( UnsignedInt width, UnsignedInt height )
122122
m_height = height;
123123
m_textureWidth = width;;
124124
m_textureHeight = height;;
125-
TextureLoader::Validate_Texture_Size( m_textureWidth, m_textureHeight);
125+
unsigned int temp_depth=1;
126+
TextureLoader::Validate_Texture_Size( m_textureWidth, m_textureHeight, temp_depth);
126127

127128
WW3DFormat w3dFormat = TypeToW3DFormat( m_format );
128129

Generals/Code/Libraries/Source/WWVegas/WW3D2/textureloader.cpp

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -125,51 +125,66 @@ void TextureLoader::Deinit()
125125
//
126126
// ----------------------------------------------------------------------------
127127

128-
void TextureLoader::Validate_Texture_Size(unsigned& width, unsigned& height)
128+
void TextureLoader::Validate_Texture_Size
129+
(
130+
unsigned& width,
131+
unsigned& height,
132+
unsigned& depth
133+
)
129134
{
130135
const D3DCAPS8& dx8caps=DX8Wrapper::Get_Current_Caps()->Get_DX8_Caps();
131136

132137
unsigned poweroftwowidth = 1;
133-
while (poweroftwowidth < width) {
138+
while (poweroftwowidth < width)
139+
{
134140
poweroftwowidth <<= 1;
135141
}
136142

137143
unsigned poweroftwoheight = 1;
138-
while (poweroftwoheight < height) {
144+
while (poweroftwoheight < height)
145+
{
139146
poweroftwoheight <<= 1;
140147
}
141148

142-
// unsigned size = MAX (width, height);
143-
// unsigned poweroftwosize = 1;
144-
// while (poweroftwosize < size) {
145-
// poweroftwosize <<= 1;
146-
// }
149+
unsigned poweroftwodepth = 1;
150+
while (poweroftwodepth< depth)
151+
{
152+
poweroftwodepth <<= 1;
153+
}
147154

148-
if (poweroftwowidth>dx8caps.MaxTextureWidth) {
155+
if (poweroftwowidth>dx8caps.MaxTextureWidth)
156+
{
149157
poweroftwowidth=dx8caps.MaxTextureWidth;
150158
}
151-
if (poweroftwoheight>dx8caps.MaxTextureHeight) {
159+
if (poweroftwoheight>dx8caps.MaxTextureHeight)
160+
{
152161
poweroftwoheight=dx8caps.MaxTextureHeight;
153162
}
163+
if (poweroftwodepth>dx8caps.MaxVolumeExtent)
164+
{
165+
poweroftwodepth=dx8caps.MaxVolumeExtent;
166+
}
154167

155-
if (poweroftwowidth>poweroftwoheight) {
156-
while (poweroftwowidth/poweroftwoheight>8) {
168+
if (poweroftwowidth>poweroftwoheight)
169+
{
170+
while (poweroftwowidth/poweroftwoheight>8)
171+
{
157172
poweroftwoheight*=2;
158173
}
159174
}
160-
else {
161-
while (poweroftwoheight/poweroftwowidth>8) {
175+
else
176+
{
177+
while (poweroftwoheight/poweroftwowidth>8)
178+
{
162179
poweroftwowidth*=2;
163180
}
164181
}
165182

166-
// width = height = poweroftwosize;
167183
width=poweroftwowidth;
168184
height=poweroftwoheight;
185+
depth=poweroftwodepth;
169186
}
170187

171-
172-
173188
IDirect3DTexture8* TextureLoader::Load_Thumbnail(const StringClass& filename,WW3DFormat texture_format)
174189
{
175190
ThumbnailClass* thumb=ThumbnailClass::Peek_Instance(filename);
@@ -1031,18 +1046,18 @@ void TextureLoadTaskClass::Begin_Texture_Load()
10311046
DDSFileClass dds_file(Texture->Get_Full_Path(),Get_Reduction());
10321047
if (dds_file.Is_Available()) {
10331048
// Destination size will be the next power of two square from the larger width and height...
1034-
unsigned width, height;
1049+
unsigned width, height, depth;
10351050
width=dds_file.Get_Width(0);
10361051
height=dds_file.Get_Height(0);
1037-
TextureLoader::Validate_Texture_Size(width,height);
1052+
TextureLoader::Validate_Texture_Size(width,height,depth);
10381053

10391054
// If the size doesn't match, try and see if texture reduction would help... (mainly for
10401055
// cases where loaded texture is larger than hardware limit)
10411056
if (width!=dds_file.Get_Width(0) || height!=dds_file.Get_Height(0)) {
10421057
for (unsigned i=1;i<dds_file.Get_Mip_Level_Count();++i) {
10431058
unsigned w=dds_file.Get_Width(i);
10441059
unsigned h=dds_file.Get_Height(i);
1045-
TextureLoader::Validate_Texture_Size(width,height);
1060+
TextureLoader::Validate_Texture_Size(width,height,depth);
10461061
if (w==dds_file.Get_Width(i) || h==dds_file.Get_Height(i)) {
10471062
Reduction+=i;
10481063
width=w;
@@ -1105,7 +1120,7 @@ void TextureLoadTaskClass::Begin_Texture_Load()
11051120
}
11061121

11071122
// Destination size will be the next power of two square from the larger width and height...
1108-
unsigned width=targa.Header.Width, height=targa.Header.Height;
1123+
unsigned width=targa.Header.Width, height=targa.Header.Height, depth;
11091124
int ReductionFactor=Get_Reduction();
11101125
int MipLevels=0;
11111126

@@ -1126,7 +1141,7 @@ void TextureLoadTaskClass::Begin_Texture_Load()
11261141
height=targa.Header.Height>>ReductionFactor;
11271142
unsigned ow=width;
11281143
unsigned oh=height;
1129-
TextureLoader::Validate_Texture_Size(width,height);
1144+
TextureLoader::Validate_Texture_Size(width,height,depth);
11301145
if (width!=ow || height!=oh) {
11311146
WWDEBUG_SAY(("Invalid texture size, scaling required. Texture: %s, size: %d x %d -> %d x %d",Texture->Get_Full_Path().str(),ow,oh,width,height));
11321147
}

Generals/Code/Libraries/Source/WWVegas/WW3D2/textureloader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class TextureLoader
4141
static void Deinit();
4242

4343
// Modify given texture size to nearest valid size on current hardware.
44-
static void Validate_Texture_Size(unsigned& width, unsigned& height);
44+
static void Validate_Texture_Size(unsigned& width, unsigned& height, unsigned& depth);
4545

4646
// Adds a loading task to the system. The task if processed in a separate
4747
// thread as soon as possible. The task will appear in finished tasks list

Generals/Code/Libraries/Source/WWVegas/WW3D2/texturethumbnail.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ ThumbnailClass::ThumbnailClass(const StringClass& filename)
9292
// Destination size will be the next power of two square from the larger width and height...
9393
Width=targa.Header.Width>>reduction_factor;
9494
Height=targa.Header.Height>>reduction_factor;
95-
TextureLoader::Validate_Texture_Size(Width,Height);
95+
unsigned depth;
96+
TextureLoader::Validate_Texture_Size(Width,Height,depth);
9697
unsigned src_width=targa.Header.Width;
9798
unsigned src_height=targa.Header.Height;
9899

GeneralsMD/Code/GameEngineDevice/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ set(GAMEENGINEDEVICE_SRC
7070
Include/W3DDevice/GameClient/W3DTerrainTracks.h
7171
Include/W3DDevice/GameClient/W3DTerrainVisual.h
7272
Include/W3DDevice/GameClient/W3DTreeBuffer.h
73-
Include/W3DDevice/GameClient/W3DVideobuffer.h
73+
Include/W3DDevice/GameClient/W3DVideoBuffer.h
7474
Include/W3DDevice/GameClient/W3DView.h
7575
Include/W3DDevice/GameClient/W3DVolumetricShadow.h
7676
Include/W3DDevice/GameClient/W3DWater.h

GeneralsMD/Code/GameEngineDevice/Source/VideoDevice/Bink/BinkVideoPlayer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ VideoStreamInterface* BinkVideoPlayer::open( AsciiString movieTitle )
225225
const Video* pVideo = getVideo(movieTitle);
226226
if (pVideo) {
227227
DEBUG_LOG(("BinkVideoPlayer::createStream() - About to open bink file"));
228-
228+
229229
if (TheGlobalData->m_modDir.isNotEmpty())
230230
{
231231
char filePath[ _MAX_PATH ];

0 commit comments

Comments
 (0)