Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
bsurface.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 : Command & Conquer *
24 * *
25 * $Archive:: /G/wwlib/bsurface.h $*
26 * *
27 * $Author:: Eric_c $*
28 * *
29 * $Modtime:: 4/02/99 11:59a $*
30 * *
31 * $Revision:: 2 $*
32 * *
33 *---------------------------------------------------------------------------------------------*
34 * Functions: *
35 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
36#if _MSC_VER >= 1000
37#pragma once
38#endif // _MSC_VER >= 1000
39
40#ifndef BSURFACE_H
41#define BSURFACE_H
42
43#include "buff.h"
44#include "xsurface.h"
45
46/*
47** This class handles a simple surface that exists in system RAM.
48*/
49class BSurface : public XSurface
50{
51 public:
52 BSurface(int width, int height, int bbp, void * buffer=NULL) :
53 XSurface(width, height),
54 BBP(bbp),
55 Buff(buffer, width * height * bbp)
56 {
57 }
58
59 /*
60 ** Gets and frees a direct pointer to the buffer.
61 */
62 virtual void * Lock(Point2D point = Point2D(0, 0)) const
63 {
65 return(((char*)Buff.Get_Buffer()) + point.Y * Stride() + point.X * Bytes_Per_Pixel());
66 }
67
68 /*
69 ** Queries information about the surface.
70 */
71 virtual int Bytes_Per_Pixel(void) const {return(BBP);}
72 virtual int Stride(void) const {return(Get_Width() * BBP);}
73
74 protected:
75
76 /*
77 ** Recorded bytes per pixel (used when determining pixel positions).
78 */
79 int BBP;
80
81 /*
82 ** Tracks the buffer that this surface represents.
83 */
85};
86
87#endif
#define NULL
Definition BaseType.h:92
TPoint2D< int > Point2D
Definition Point.h:114
virtual void * Lock(Point2D point=Point2D(0, 0)) const
Definition bsurface.h:62
Buffer Buff
Definition bsurface.h:84
virtual int Stride(void) const
Definition bsurface.h:72
virtual int Bytes_Per_Pixel(void) const
Definition bsurface.h:71
BSurface(int width, int height, int bbp, void *buffer=NULL)
Definition bsurface.h:52
int BBP
Definition bsurface.h:79
Definition BUFF.H:57
virtual int Get_Width(void) const
Definition Surface.h:103
XSurface(int width=0, int height=0)
Definition xsurface.h:54
virtual void * Lock(Point2D=Point2D(0, 0)) const
Definition xsurface.h:92