40
39
, BitmapFormat PixelFormat
41
40
, NUX_FILE_LINE_DECL)
43
IOpenGLTexture2D *ptr;
44
CreateTexture(Width, Height, Levels, PixelFormat, (IOpenGLTexture2D **) &ptr, NUX_FILE_LINE_PARAM);
45
ObjectPtr<IOpenGLTexture2D> h = ObjectPtr<IOpenGLTexture2D> (ptr);
50
int GpuDevice::CreateTexture(
54
, BitmapFormat PixelFormat
55
, IOpenGLTexture2D **ppTexture
59
if ((Width <= 0) || (Height <= 0))
42
GpuInfo gpu_info = GetGpuInfo();
43
int msz = gpu_info.GetMaxTextureSize();
44
if(Width <= 0 || Height <= 0 || Width > msz || Height > msz)
46
return ObjectPtr<IOpenGLTexture2D>();
65
// From : http://oss.sgi.com/projects/ogl-sample/registry/ARB/texture_non_power_of_two.txt
66
// The "floor" convention has a relatively straightforward way to
67
// evaluate(with integer math) means to determine how many mipmap
68
// levels are required for a complete pyramid:
69
// numLevels = 1 + floor(log2(max(w, h, d)))
70
unsigned int NumTotalMipLevel = 1 + floorf(Log2(Max(Width, Height)));
73
// [in] Number of levels in the texture. If this is zero, generate all texture sublevels
74
// down to 1 by 1 pixels for hardware that supports mip-maps textures. Call GetNumMipLevel to see the
75
// number of levels generated.
49
unsigned int NumTotalMipLevel = 1 + floorf(Log2(Max(Width, Height)));
76
50
unsigned int NumMipLevel = 0;
80
54
NumMipLevel = NumTotalMipLevel;
82
else if (Levels > NumTotalMipLevel)
56
else if (Levels > (int)NumTotalMipLevel)
84
58
NumMipLevel = NumTotalMipLevel;
88
62
NumMipLevel = Levels;
92
// The "floor" convention can be evaluated incrementally with the
93
// following recursion:
95
// nextLODdim = max(1, currentLODdim >> 1)
97
// where currentLODdim is the dimension of a level N and nextLODdim
98
// is the dimension of level N+1. The recursion stops when level
99
// numLevels-1 is reached.
101
*ppTexture = new IOpenGLTexture2D(Width, Height, NumMipLevel, PixelFormat, false, NUX_FILE_LINE_PARAM);
65
ObjectPtr<IOpenGLTexture2D> result;
66
result.Adopt(new IOpenGLTexture2D(Width, Height, NumMipLevel, PixelFormat, false, NUX_FILE_LINE_PARAM));
106
70
ObjectPtr<IOpenGLTexture2D> GpuDevice::CreateTexture2DFromID(int id
110
74
, BitmapFormat pixel_format
111
75
, NUX_FILE_LINE_DECL)
113
IOpenGLTexture2D *ptr;
114
ptr = new IOpenGLTexture2D(width, height, levels, pixel_format, true, NUX_FILE_LINE_PARAM); // ref count = 1;
116
ObjectPtr<IOpenGLTexture2D> h = ObjectPtr<IOpenGLTexture2D> (ptr); // ref count = 2
117
ptr->UnReference(); // ref count = 1
77
GpuInfo gpu_info = GetGpuInfo();
78
int msz = gpu_info.GetMaxTextureSize();
79
if(width <= 0 || height <=0 || width > msz || height > msz)
81
return ObjectPtr<IOpenGLTexture2D>();
84
ObjectPtr<IOpenGLTexture2D> result;
85
result.Adopt(new IOpenGLTexture2D(width, height, levels, pixel_format, true, NUX_FILE_LINE_PARAM));
121
89
ObjectPtr<IOpenGLRectangleTexture> GpuDevice::CreateRectangleTexture(
125
93
, BitmapFormat PixelFormat
126
94
, NUX_FILE_LINE_DECL)
128
IOpenGLRectangleTexture *ptr;
129
CreateRectangleTexture(Width, Height, Levels, PixelFormat, (IOpenGLRectangleTexture **) &ptr, NUX_FILE_LINE_PARAM);
130
ObjectPtr<IOpenGLRectangleTexture> h = ObjectPtr<IOpenGLRectangleTexture> (ptr);
135
int GpuDevice::CreateRectangleTexture(
137
, unsigned int Height
138
, unsigned int Levels
139
, BitmapFormat PixelFormat
140
, IOpenGLRectangleTexture **ppTexture
144
if ((Width <= 0) || (Height <= 0))
96
GpuInfo gpu_info = GetGpuInfo();
97
int msz = gpu_info.GetMaxTextureSize();
98
if(Width <= 0 || Height <= 0 || Width > msz || Height > msz)
100
return ObjectPtr<IOpenGLRectangleTexture>();
150
// From : http://oss.sgi.com/projects/ogl-sample/registry/ARB/texture_non_power_of_two.txt
151
// The "floor" convention has a relatively straightforward way to
152
// evaluate(with integer math) means to determine how many mipmap
153
// levels are required for a complete pyramid:
154
// numLevels = 1 + floor(log2(max(w, h, d)))
155
unsigned int NumTotalMipLevel = 1 + floorf(Log2(Max(Width, Height)));
158
// [in] Number of levels in the texture. If this is zero, generate all texture sublevels
159
// down to 1 by 1 pixels for hardware that supports mip-maps textures. Call GetNumMipLevel to see the
160
// number of levels generated.
103
unsigned int NumTotalMipLevel = 1 + floorf(Log2(Max(Width, Height)));
161
104
unsigned int NumMipLevel = 0;
165
//Rectangle texture texture don't support mipmaps
168
else if (Levels > NumTotalMipLevel)
110
else if (Levels > (int)NumTotalMipLevel)
178
// The "floor" convention can be evaluated incrementally with the
179
// following recursion:
181
// nextLODdim = max(1, currentLODdim >> 1)
183
// where currentLODdim is the dimension of a level N and nextLODdim
184
// is the dimension of level N+1. The recursion stops when level
185
// numLevels-1 is reached.
187
*ppTexture = new IOpenGLRectangleTexture(Width, Height, NumMipLevel, PixelFormat, false, NUX_FILE_LINE_PARAM);
119
ObjectPtr<IOpenGLRectangleTexture> result;
120
result.Adopt(new IOpenGLRectangleTexture(Width, Height, NumMipLevel, PixelFormat, false, NUX_FILE_LINE_PARAM));
193
124
ObjectPtr<IOpenGLCubeTexture> GpuDevice::CreateCubeTexture(
196
127
, BitmapFormat PixelFormat
197
128
, NUX_FILE_LINE_DECL)
199
IOpenGLCubeTexture *ptr;
200
CreateCubeTexture(EdgeLength, Levels, PixelFormat, (IOpenGLCubeTexture **) &ptr);
201
ObjectPtr<IOpenGLCubeTexture> h = ObjectPtr<IOpenGLCubeTexture> (ptr);
206
int GpuDevice::CreateCubeTexture(
207
unsigned int EdgeLength
208
, unsigned int Levels
209
, BitmapFormat PixelFormat
210
, IOpenGLCubeTexture **ppCubeTexture
214
unsigned int NumTotalMipLevel = 1 + floorf(Log2(EdgeLength));
216
// [in] Number of levels in the texture. If this is zero, Direct3D will generate all texture sublevels
217
// down to 1 by 1 pixels for hardware that supports mipmapped textures. Call GetNumMipLevel to see the
218
// number of levels generated.
131
unsigned int NumTotalMipLevel = 1 + floorf(Log2(EdgeLength));
219
132
unsigned int NumMipLevel = 0;
223
136
NumMipLevel = NumTotalMipLevel;
225
else if (Levels > NumTotalMipLevel)
138
else if (Levels > (int)NumTotalMipLevel)
227
140
NumMipLevel = NumTotalMipLevel;
231
144
NumMipLevel = Levels;
234
*ppCubeTexture = new IOpenGLCubeTexture(EdgeLength, NumMipLevel, PixelFormat);
147
ObjectPtr<IOpenGLCubeTexture> result;
148
result.Adopt(new IOpenGLCubeTexture(EdgeLength, NumMipLevel, PixelFormat));
239
152
ObjectPtr<IOpenGLVolumeTexture> GpuDevice::CreateVolumeTexture(
244
157
, BitmapFormat PixelFormat
245
158
, NUX_FILE_LINE_DECL)
247
IOpenGLVolumeTexture *ptr;
248
CreateVolumeTexture(Width, Height, Depth, Levels, PixelFormat, (IOpenGLVolumeTexture **) &ptr, NUX_FILE_LINE_PARAM);
249
ObjectPtr<IOpenGLVolumeTexture> h = ObjectPtr<IOpenGLVolumeTexture> (ptr);
160
GpuInfo gpu_info = GetGpuInfo();
161
int msz = gpu_info.GetMaxTextureSize();
162
if(Width <= 0 || Height <= 0 || Width > msz || Height > msz)
164
return ObjectPtr<IOpenGLVolumeTexture>();
254
int GpuDevice::CreateVolumeTexture(
256
, unsigned int Height
258
, unsigned int Levels
259
, BitmapFormat PixelFormat
260
, IOpenGLVolumeTexture **ppVolumeTexture
264
167
unsigned int NumTotalMipLevel = 1 + floorf(Log2(Max(Max(Width, Height), Depth)));
266
// [in] Number of levels in the texture. If this is zero, Direct3D will generate all texture sublevels
267
// down to 1 by 1 pixels for hardware that supports mipmapped textures. Call GetNumMipLevel to see the
268
// number of levels generated.
269
168
unsigned int NumMipLevel = 0;
273
172
NumMipLevel = NumTotalMipLevel;
275
else if (Levels > NumTotalMipLevel)
174
else if (Levels > (int)NumTotalMipLevel)
277
176
NumMipLevel = NumTotalMipLevel;
281
180
NumMipLevel = Levels;
284
*ppVolumeTexture = new IOpenGLVolumeTexture(Width, Height, Depth, NumMipLevel, PixelFormat);
183
ObjectPtr<IOpenGLVolumeTexture> result;
184
result.Adopt(new IOpenGLVolumeTexture(Width, Height, Depth, NumMipLevel, PixelFormat));
289
188
ObjectPtr<IOpenGLAnimatedTexture> GpuDevice::CreateAnimatedTexture(
293
192
, BitmapFormat PixelFormat)
295
IOpenGLAnimatedTexture *ptr;
296
CreateAnimatedTexture(Width, Height, Depth, PixelFormat, (IOpenGLAnimatedTexture **) &ptr);
297
ObjectPtr<IOpenGLAnimatedTexture> h = ObjectPtr<IOpenGLAnimatedTexture> (ptr);
302
int GpuDevice::CreateAnimatedTexture(unsigned int Width,
305
BitmapFormat PixelFormat,
306
IOpenGLAnimatedTexture **ppAnimatedTexture)
308
*ppAnimatedTexture = new IOpenGLAnimatedTexture(Width, Height, Depth, PixelFormat);
194
GpuInfo gpu_info = GetGpuInfo();
195
int msz = gpu_info.GetMaxTextureSize();
196
if(Width <= 0 || Height <= 0 || Width > msz || Height > msz)
198
return ObjectPtr<IOpenGLAnimatedTexture>();
201
ObjectPtr<IOpenGLAnimatedTexture> result;
202
result.Adopt(new IOpenGLAnimatedTexture(Width, Height, Depth, PixelFormat));
313
206
ObjectPtr<IOpenGLQuery> GpuDevice::CreateQuery(QUERY_TYPE Type)
316
CreateQuery(Type, (IOpenGLQuery **) &ptr);
317
ObjectPtr<IOpenGLQuery> h = ObjectPtr<IOpenGLQuery> (ptr);
322
int GpuDevice::CreateQuery(QUERY_TYPE Type, IOpenGLQuery **ppQuery)
324
*ppQuery = new IOpenGLQuery(Type);
208
ObjectPtr<IOpenGLQuery> result;
209
result.Adopt(new IOpenGLQuery(Type));