Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
dx8indexbuffer.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:: /Commando/Code/ww3d2/dx8indexbuffer.h $*
26 * *
27 * Original Author:: Greg Hjelstrom *
28 * *
29 * $Author:: Jani_p $*
30 * *
31 * $Modtime:: 7/10/01 12:27p $*
32 * *
33 * $Revision:: 12 $*
34 * *
35 *---------------------------------------------------------------------------------------------*
36 * Functions: *
37 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
38
39#if defined(_MSC_VER)
40#pragma once
41#endif
42
43#ifndef DX8INDEXBUFFER_H
44#define DX8INDEXBUFFER_H
45
46#include "always.h"
47#include "wwdebug.h"
48#include "refcount.h"
49#include "sphere.h"
50
51class DX8Wrapper;
53struct IDirect3DIndexBuffer8;
56
57// ----------------------------------------------------------------------------
58
60{
61 // nope, it's an ABC
62 //W3DMPO_GLUE(IndexBufferClass)
63protected:
64 virtual ~IndexBufferClass();
65public:
66 IndexBufferClass(unsigned type, unsigned short index_count);
67
68 void Copy(unsigned int* indices,unsigned start_index,unsigned index_count);
69 void Copy(unsigned short* indices,unsigned start_index,unsigned index_count);
70
71 inline unsigned short Get_Index_Count() const { return index_count; }
72
73 inline unsigned Type() const { return type; }
74
75 void Add_Engine_Ref() const;
76 void Release_Engine_Ref() const;
77 inline unsigned Engine_Refs() const { return engine_refs; }
78
80 {
81 IndexBufferClass* index_buffer;
82 unsigned short* indices;
83 public:
84 WriteLockClass(IndexBufferClass* index_buffer, int flags=0);
86
87 unsigned short* Get_Index_Array() { return indices; }
88 };
89
91 {
92 IndexBufferClass* index_buffer;
93 unsigned short* indices;
94 public:
95 AppendLockClass(IndexBufferClass* index_buffer,unsigned start_index, unsigned index_range);
97
98 unsigned short* Get_Index_Array() { return indices; }
99 };
100
101 static unsigned Get_Total_Buffer_Count();
102 static unsigned Get_Total_Allocated_Indices();
103 static unsigned Get_Total_Allocated_Memory();
104
105protected:
106 mutable int engine_refs;
107 unsigned short index_count; // number of indices
108 unsigned type;
109};
110
111
112// HY 2/14/01
113// Created
115{
117
118 friend DX8Wrapper;
119 friend SortingRendererClass;
120
121 unsigned Type;
122 unsigned short IndexCount;
123 unsigned short IndexBufferOffset;
124 IndexBufferClass* IndexBuffer;
125
126 void Allocate_Sorting_Dynamic_Buffer();
127 void Allocate_DX8_Dynamic_Buffer();
128
129public:
130 DynamicIBAccessClass(unsigned short type, unsigned short index_count);
132
133 unsigned Get_Type() const { return Type; }
134 unsigned short Get_Index_Count() const { return IndexCount; }
135
136 // Call at the end of the execution, or at whatever time you wish to release
137 // the recycled dynamic index buffer.
138 static void _Deinit();
139 static void _Reset(bool frame_changed);
140 static unsigned short Get_Default_Index_Count(void);
141
142 // To lock the index buffer, create instance of this write class locally.
143 // The buffer is automatically unlocked when you exit the scope.
145 {
146 DynamicIBAccessClass* DynamicIBAccess;
147 unsigned short* Indices;
148 public:
151 unsigned short* Get_Index_Array() { return Indices; }
152 };
153
155};
156
157
163{
165
168public:
175
178
179 void Copy(unsigned int* indices,unsigned start_index,unsigned index_count);
180 void Copy(unsigned short* indices,unsigned start_index,unsigned index_count);
181
182 inline IDirect3DIndexBuffer8* Get_DX8_Index_Buffer() { return index_buffer; }
183
184private:
185 IDirect3DIndexBuffer8* index_buffer; // actual dx8 index buffer
186};
187
188
189
191{
193
194 friend DX8Wrapper;
195 friend SortingRendererClass;
199public:
200 SortingIndexBufferClass(unsigned short index_count);
202
203protected:
204 unsigned short* index_buffer;
205};
206
207extern int IndexBufferExceptionFunc(void);
208
209#endif //DX8INDEXBUFFER_H
210
#define W3DMPO_GLUE(ARGCLASS)
Definition always.h:120
DX8IndexBufferClass(unsigned short index_count, UsageType usage=USAGE_DEFAULT)
void Copy(unsigned int *indices, unsigned start_index, unsigned index_count)
IDirect3DIndexBuffer8 * Get_DX8_Index_Buffer()
void Copy(unsigned short *indices, unsigned start_index, unsigned index_count)
WriteLockClass(DynamicIBAccessClass *ib_access)
static unsigned short Get_Default_Index_Count(void)
current size of dynamic index buffer
static void _Reset(bool frame_changed)
unsigned Get_Type() const
DynamicIBAccessClass(unsigned short type, unsigned short index_count)
unsigned short Get_Index_Count() const
AppendLockClass(IndexBufferClass *index_buffer, unsigned start_index, unsigned index_range)
WriteLockClass(IndexBufferClass *index_buffer, int flags=0)
void Release_Engine_Ref() const
IndexBufferClass(unsigned type, unsigned short index_count)
static unsigned Get_Total_Allocated_Memory()
unsigned Type() const
virtual ~IndexBufferClass()
static unsigned Get_Total_Buffer_Count()
unsigned short Get_Index_Count() const
unsigned Engine_Refs() const
static unsigned Get_Total_Allocated_Indices()
void Copy(unsigned int *indices, unsigned start_index, unsigned index_count)
void Add_Engine_Ref() const
unsigned short index_count
RefCountClass(void)
Definition refcount.h:108
SortingIndexBufferClass(unsigned short index_count)
unsigned short * index_buffer
int IndexBufferExceptionFunc(void)