Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
surfaceclass.h
Go to the documentation of this file.
1/*
2** Command & Conquer Generals Zero Hour(tm)
3** Copyright 2025 Electronic Arts Inc.
4**
5** This program is free software: you can redistribute it and/or modify
6** it under the terms of the GNU General Public License as published by
7** the Free Software Foundation, either version 3 of the License, or
8** (at your option) any later version.
9**
10** This program is distributed in the hope that it will be useful,
11** but WITHOUT ANY WARRANTY; without even the implied warranty of
12** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13** GNU General Public License for more details.
14**
15** You should have received a copy of the GNU General Public License
16** along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19/***********************************************************************************************
20 *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
21 ***********************************************************************************************
22 * *
23 * Project Name : WW3D *
24 * *
25 * $Archive:: /VSS_Sync/ww3d2/surfaceclass.h $*
26 * *
27 * Original Author:: Nathaniel Hoffman *
28 * *
29 * $Author:: Vss_sync $*
30 * *
31 * $Modtime:: 8/29/01 9:32p $*
32 * *
33 * $Revision:: 17 $*
34 * *
35 *---------------------------------------------------------------------------------------------*
36 * Functions: *
37 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
38
39#if defined(_MSC_VER)
40#pragma once
41#endif
42
43#ifndef SURFACECLASS_H
44#define SURFACECLASS_H
45
46#include "ww3dformat.h"
47#include "refcount.h"
48
49struct IDirect3DSurface8;
50class Vector2i;
51class Vector3;
52
53/*************************************************************************
54** SurfaceClass
55**
56** This is our surface class, which wraps IDirect3DSurface8.
57**
58** Hector Yee 2/12/01 - added in fills, blits etc for font3d class
59**
60*************************************************************************/
61class SurfaceClass : public W3DMPO, public RefCountClass
62{
64 public:
65
67 WW3DFormat Format; // Surface format
68 unsigned int Width; // Surface width in pixels
69 unsigned int Height; // Surface height in pixels
70 };
71
72 // Create surface with desired height, width and format.
73 SurfaceClass(unsigned width, unsigned height, WW3DFormat format);
74
75 // Create surface from a file.
76 SurfaceClass(const char *filename);
77
78 // Create the surface from a D3D pointer
79 SurfaceClass(IDirect3DSurface8 *d3d_surface);
80
81 ~SurfaceClass(void);
82
83 // Get surface description
84 void Get_Description(SurfaceDescription &surface_desc);
85
86 // Lock / unlock the surface
87 void * Lock(int * pitch);
88 void Unlock(void);
89
90 // HY -- The following functions are support functions for font3d
91 // zaps the surface memory to zero
92 void Clear();
93
94 // copies the contents of one surface to another
95 void Copy(
96 unsigned int dstx, unsigned int dsty,
97 unsigned int srcx, unsigned int srcy,
98 unsigned int width, unsigned int height,
99 const SurfaceClass *other);
100
101 // support for copying from a byte array
102 void Copy(const unsigned char *other);
103
104 // support for copying from a byte array
105 void Copy(Vector2i &min,Vector2i &max, const unsigned char *other);
106
107 // copies the contents of one surface to another, stretches
108 void Stretch_Copy(
109 unsigned int dstx, unsigned int dsty,unsigned int dstwidth, unsigned int dstheight,
110 unsigned int srcx, unsigned int srcy, unsigned int srcwidth, unsigned int srcheight,
111 const SurfaceClass *source);
112
113 // finds the bounding box of non-zero pixels, used in font3d
115
116 // tests a column to see if the alpha is nonzero, used in font3d
117 bool Is_Transparent_Column(unsigned int column);
118
119 // makes a copy of the surface into a byte array
120 unsigned char *CreateCopy(int *width,int *height,int*size,bool flip=false);
121
122 // For use by TextureClass:
123 IDirect3DSurface8 *Peek_D3D_Surface(void) { return D3DSurface; }
124
125 // Attaching and detaching a surface pointer
126 void Attach (IDirect3DSurface8 *surface);
127 void Detach (void);
128
129 // draws a horizontal line
130 void DrawHLine(const unsigned int y,const unsigned int x1, const unsigned int x2, unsigned int color);
131
132 void DrawPixel(const unsigned int x,const unsigned int y, unsigned int color);
133
134 // get pixel function .. to be used infrequently
135 void Get_Pixel(Vector3 &rgb, int x,int y);
136
137 void Hue_Shift(const Vector3 &hsv_shift);
138
139 bool Is_Monochrome(void);
140
141 WW3DFormat Get_Surface_Format() const { return SurfaceFormat; }
142
143 private:
144
145 // Direct3D surface object
146 IDirect3DSurface8 *D3DSurface;
147
148 WW3DFormat SurfaceFormat;
149 friend class TextureClass;
150};
151
152#endif
153
154
#define min(x, y)
Definition BaseType.h:101
#define max(x, y)
Definition BaseType.h:105
#define W3DMPO_GLUE(ARGCLASS)
Definition always.h:120
RefCountClass(void)
Definition refcount.h:108
void DrawHLine(const unsigned int y, const unsigned int x1, const unsigned int x2, unsigned int color)
void Get_Description(SurfaceDescription &surface_desc)
void Copy(unsigned int dstx, unsigned int dsty, unsigned int srcx, unsigned int srcy, unsigned int width, unsigned int height, const SurfaceClass *other)
void Attach(IDirect3DSurface8 *surface)
void Unlock(void)
unsigned char * CreateCopy(int *width, int *height, int *size, bool flip=false)
WW3DFormat Get_Surface_Format() const
bool Is_Transparent_Column(unsigned int column)
bool Is_Monochrome(void)
void Get_Pixel(Vector3 &rgb, int x, int y)
void * Lock(int *pitch)
void Hue_Shift(const Vector3 &hsv_shift)
void Detach(void)
void Stretch_Copy(unsigned int dstx, unsigned int dsty, unsigned int dstwidth, unsigned int dstheight, unsigned int srcx, unsigned int srcy, unsigned int srcwidth, unsigned int srcheight, const SurfaceClass *source)
void FindBB(Vector2i *min, Vector2i *max)
SurfaceClass(unsigned width, unsigned height, WW3DFormat format)
void DrawPixel(const unsigned int x, const unsigned int y, unsigned int color)
IDirect3DSurface8 * Peek_D3D_Surface(void)
friend class TextureClass
WW3DFormat
Definition ww3dformat.h:75