Skip to content

Commit 6fc370d

Browse files
committed
xrRenderGL: Update various OpenGL implementations.
1 parent eca94e6 commit 6fc370d

11 files changed

+38
-50
lines changed

src/Layers/xrRenderGL/glBufferUtils.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ void CreateIndexBuffer(GLuint* pBuffer, const void* pData, UINT DataSize, bool b
2424
return CreateBuffer(pBuffer, pData, DataSize, bImmutable, true);
2525
}
2626

27-
GLenum VertexSizeList[] =
27+
GLsizei VertexSizeList[] =
2828
{
2929
1, // D3DDECLTYPE_FLOAT1
3030
2, // D3DDECLTYPE_FLOAT2
@@ -66,7 +66,7 @@ GLenum VertexTypeList[] =
6666
GL_HALF_FLOAT // D3DDECLTYPE_FLOAT16_4
6767
};
6868

69-
GLenum VertexNormalizedList[] =
69+
GLboolean VertexNormalizedList[] =
7070
{
7171
GL_FALSE, // D3DDECLTYPE_FLOAT1
7272
GL_FALSE, // D3DDECLTYPE_FLOAT2
@@ -87,7 +87,7 @@ GLenum VertexNormalizedList[] =
8787
GL_FALSE // D3DDECLTYPE_FLOAT16_4
8888
};
8989

90-
GLenum VertexTypeSizeList[] =
90+
GLsizei VertexTypeSizeList[] =
9191
{
9292
sizeof(GLfloat), // D3DDECLTYPE_FLOAT1
9393
sizeof(GLfloat), // D3DDECLTYPE_FLOAT2

src/Layers/xrRenderGL/glDetailManager_VS.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
#include "stdafx.h"
2-
#include "../xrRender/DetailManager.h"
3-
4-
#include "../../xrEngine/igame_persistent.h"
5-
#include "../../xrEngine/environment.h"
6-
7-
#include "../xrRenderGL/glBufferUtils.h"
2+
#include "Layers/xrRender/DetailManager.h"
3+
#include "xrEngine/IGame_Persistent.h"
4+
#include "xrEngine/Environment.h"
5+
#include "Layers/xrRenderGL/glBufferUtils.h"
86

97
const int quant = 16384;
108
const int c_hdr = 10;
@@ -101,7 +99,7 @@ void CDetailManager::hw_Render_dump(const Fvector4 &consts, const Fvector4 &wave
10199
static shared_str strArray("array");
102100
static shared_str strXForm("xform");
103101

104-
Device.Statistic->RenderDUMP_DT_Count = 0;
102+
RImplementation.BasicStats.DetailCount = 0;
105103

106104
// Matrices and offsets
107105
u32 vOffset = 0;
@@ -180,7 +178,7 @@ void CDetailManager::hw_Render_dump(const Fvector4 &consts, const Fvector4 &wave
180178
dwBatch ++;
181179
if (dwBatch == hw_BatchSize) {
182180
// flush
183-
Device.Statistic->RenderDUMP_DT_Count += dwBatch;
181+
RImplementation.BasicStats.DetailCount += dwBatch;
184182
u32 dwCNT_verts = dwBatch * Object.number_vertices;
185183
u32 dwCNT_prims = (dwBatch * Object.number_indices)/3;
186184
//RCache.get_ConstantCache_Vertex().b_dirty = TRUE;
@@ -206,7 +204,7 @@ void CDetailManager::hw_Render_dump(const Fvector4 &consts, const Fvector4 &wave
206204
// flush if nessecary
207205
if (dwBatch)
208206
{
209-
Device.Statistic->RenderDUMP_DT_Count += dwBatch;
207+
RImplementation.BasicStats.DetailCount += dwBatch;
210208
u32 dwCNT_verts = dwBatch * Object.number_vertices;
211209
u32 dwCNT_prims = (dwBatch * Object.number_indices)/3;
212210
//RCache.get_ConstantCache_Vertex().b_dirty = TRUE;

src/Layers/xrRenderGL/glSH_Texture.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,13 @@
1010
#include "../../xrEngine/tntQAVI.h"
1111
#include "../../xrEngine/xrTheora_Surface.h"
1212

13-
#include "glRenderDeviceRender.h"
14-
1513
#define PRIORITY_HIGH 12
1614
#define PRIORITY_NORMAL 8
1715
#define PRIORITY_LOW 4
1816

1917
void resptrcode_texture::create(LPCSTR _name)
2018
{
21-
_set(DEV->_CreateTexture(_name));
19+
_set(RImplementation.Resources->_CreateTexture(_name));
2220
}
2321

2422

@@ -45,9 +43,8 @@ CTexture::CTexture ()
4543
CTexture::~CTexture()
4644
{
4745
Unload ();
48-
4946
// release external reference
50-
DEV->_DeleteTexture (this);
47+
RImplementation.Resources->_DeleteTexture(this);
5148
}
5249

5350
void CTexture::surface_set (GLenum target, GLuint surf )
@@ -134,8 +131,8 @@ void CTexture::apply_normal(u32 dwStage) {
134131

135132
void CTexture::Preload ()
136133
{
137-
m_bumpmap = DEV->m_textures_description.GetBumpName(cName);
138-
m_material = DEV->m_textures_description.GetMaterial(cName);
134+
m_bumpmap = RImplementation.Resources->m_textures_description.GetBumpName(cName);
135+
m_material = RImplementation.Resources->m_textures_description.GetMaterial(cName);
139136
}
140137

141138
void CTexture::Load ()

src/Layers/xrRenderGL/glTextureUtils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ struct TextureFormatPairs
1111

1212
TextureFormatPairs TextureFormatList[] =
1313
{
14-
{ D3DFMT_UNKNOWN, NULL },
14+
{ D3DFMT_UNKNOWN, GL_NONE },
1515
//D3DFMT_R8G8B8 Not available
1616
{ D3DFMT_A8R8G8B8, GL_RGBA8 }, // Not available
1717
//D3DFMT_X8R8G8B8 Not available
@@ -107,6 +107,6 @@ GLenum ConvertTextureFormat(D3DFORMAT dx9FMT)
107107
}
108108

109109
VERIFY(!"ConvertTextureFormat didn't find appropriate gl texture format!");
110-
return NULL;
110+
return GL_NONE;
111111
}
112112
}

src/Layers/xrRenderPC_GL/glTexture.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ GLuint CRender::texture_load(LPCSTR fRName, u32& ret_msize, GLenum& ret_desc)
126126

127127
glGenTextures(1, &pTexture);
128128
glBindTexture(GL_TEXTURE_CUBE_MAP, pTexture);
129-
CHK_GL(glTexStorage2D(GL_TEXTURE_CUBE_MAP, mip_cnt, fmt.Internal, dwWidth, dwHeight));
129+
CHK_GL(glTexStorage2D(GL_TEXTURE_CUBE_MAP, mip_cnt, (GLenum)fmt.Internal, dwWidth, dwHeight));
130130

131131
for (size_t face = 0; face < Texture.faces(); face++)
132132
{
@@ -135,11 +135,11 @@ GLuint CRender::texture_load(LPCSTR fRName, u32& ret_msize, GLenum& ret_desc)
135135
if (gli::is_compressed(Texture.format()))
136136
{
137137
CHK_GL(glCompressedTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, i, 0, 0, Texture.dimensions(i).x, Texture.dimensions(i).y,
138-
fmt.Internal, Texture.size(i), Texture.data(0, face, i)));
138+
(GLenum)fmt.Internal, Texture.size(i), Texture.data(0, face, i)));
139139
}
140140
else {
141141
CHK_GL(glTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, i, 0, 0, Texture.dimensions(i).x, Texture.dimensions(i).y,
142-
fmt.External, fmt.Type, Texture.data(0, face, i)));
142+
(GLenum)fmt.External, (GLenum)fmt.Type, Texture.data(0, face, i)));
143143
}
144144
}
145145
}
@@ -165,17 +165,17 @@ GLuint CRender::texture_load(LPCSTR fRName, u32& ret_msize, GLenum& ret_desc)
165165

166166
glGenTextures(1, &pTexture);
167167
glBindTexture(GL_TEXTURE_2D, pTexture);
168-
CHK_GL(glTexStorage2D(GL_TEXTURE_2D, mip_cnt, fmt.Internal, dwWidth, dwHeight));
168+
CHK_GL(glTexStorage2D(GL_TEXTURE_2D, mip_cnt, (GLenum)fmt.Internal, dwWidth, dwHeight));
169169
for (size_t i = 0; i < mip_cnt; i++)
170170
{
171171
if (gli::is_compressed(Texture.format()))
172172
{
173173
CHK_GL(glCompressedTexSubImage2D(GL_TEXTURE_2D, i, 0, 0, Texture.dimensions(i).x, Texture.dimensions(i).y,
174-
fmt.Internal, Texture.size(i), Texture.data(0, 0, i)));
174+
(GLenum)fmt.Internal, Texture.size(i), Texture.data(0, 0, i)));
175175
}
176176
else {
177177
CHK_GL(glTexSubImage2D(GL_TEXTURE_2D, i, 0, 0, Texture.dimensions(i).x, Texture.dimensions(i).y,
178-
fmt.External, fmt.Type, Texture.data(0, 0, i)));
178+
(GLenum)fmt.External, (GLenum)fmt.Type, Texture.data(0, 0, i)));
179179
}
180180
}
181181
FS.r_close(S);

src/Layers/xrRenderPC_GL/gl_rendertarget_accum_omnipart_geom.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
void CRenderTarget::accum_omnip_geom_create ()
55
{
6-
u32 dwUsage = GL_STATIC_DRAW;
6+
GLenum dwUsage = GL_STATIC_DRAW;
77

88
// vertices
99
{

src/Layers/xrRenderPC_GL/gl_rendertarget_accum_point_geom.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ u16 du_sphere_faces[DU_SPHERE_NUMFACES*3]={
285285

286286
void CRenderTarget::accum_point_geom_create()
287287
{
288-
u32 dwUsage = GL_STATIC_DRAW;
288+
GLenum dwUsage = GL_STATIC_DRAW;
289289

290290
// vertices
291291
{

src/Layers/xrRenderPC_GL/gl_rendertarget_accum_spot_geom.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ u16 du_cone_faces[DU_CONE_NUMFACES*3]=
6262

6363
void CRenderTarget::accum_spot_geom_create ()
6464
{
65-
u32 dwUsage = GL_STATIC_DRAW;
65+
GLenum dwUsage = GL_STATIC_DRAW;
6666

6767
// vertices
6868
{

src/Layers/xrRenderPC_GL/glr_constants.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
#pragma hdrstop
33

44
#include "../xrRender/r_constants.h"
5-
6-
void cl_sampler::setup(R_constant* C)
5+
static class cl_sampler : public R_constant_setup
76
{
8-
CHK_GL(glProgramUniform1i(C->samp.program, C->samp.location, C->samp.index));
9-
}
7+
virtual void setup(R_constant* C)
8+
{
9+
CHK_GL(glProgramUniform1i(C->samp.program, C->samp.location, C->samp.index));
10+
}
11+
} binder_sampler;
1012

1113
IC bool p_sort(ref_constant C1, ref_constant C2)
1214
{
@@ -109,7 +111,7 @@ BOOL R_constant_table::parse(void* _desc, u16 destination)
109111
C->name = name;
110112
C->destination = RC_dest_sampler;
111113
C->type = RC_sampler;
112-
C->handler = &sampler_binder;
114+
C->handler = &binder_sampler;
113115
R_constant_load& L = C->samp;
114116
L.index = r_stage++;
115117
L.cls = RC_sampler;
@@ -120,7 +122,7 @@ BOOL R_constant_table::parse(void* _desc, u16 destination)
120122
else {
121123
R_ASSERT(C->destination == RC_dest_sampler);
122124
R_ASSERT(C->type == RC_sampler);
123-
R_ASSERT(C->handler == &sampler_binder);
125+
R_ASSERT(C->handler == &binder_sampler);
124126
R_constant_load& L = C->samp;
125127
R_ASSERT(L.index == r_stage);
126128
R_ASSERT(L.cls == RC_sampler);

src/Layers/xrRenderPC_GL/r2_R_calculate.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "stdafx.h"
2-
#include "../../xrEngine/customhud.h"
2+
#include "xrEngine/CustomHUD.h"
33

44
float g_fSCREEN;
55

@@ -45,7 +45,7 @@ void CRender::Calculate()
4545
Fvector box_radius; box_radius.set(eps, eps, eps);
4646
Sectors_xrc.box_options(CDB::OPT_FULL_TEST);
4747
Sectors_xrc.box_query(rmPortals, Device.vCameraPosition, box_radius);
48-
for (int K = 0; K<Sectors_xrc.r_count(); K++) {
48+
for (int K = 0; K<Sectors_xrc.r_count(); K++) {
4949
CPortal* pPortal = (CPortal*)Portals[rmPortals->get_tris()[Sectors_xrc.r_begin()[K].id].dummy];
5050
pPortal->bDualRender = TRUE;
5151
}
@@ -57,12 +57,12 @@ void CRender::Calculate()
5757
// Check if we touch some light even trough portal
5858
lstRenderables.clear();
5959
g_SpatialSpace->q_sphere(lstRenderables, 0, STYPE_LIGHTSOURCE, Device.vCameraPosition, EPS_L);
60-
for (u32 _it = 0; _it<lstRenderables.size(); _it++) {
60+
for (u32 _it = 0; _it<lstRenderables.size(); _it++) {
6161
ISpatial* spatial = lstRenderables[_it]; spatial->spatial_updatesector();
62-
CSector* sector = (CSector*)spatial->spatial.sector;
62+
CSector* sector = (CSector*)spatial->GetSpatialData().sector;
6363
if (0 == sector) continue; // disassociated from S/P structure
6464

65-
VERIFY(spatial->spatial.type & STYPE_LIGHTSOURCE);
65+
VERIFY(spatial->GetSpatialData().type & STYPE_LIGHTSOURCE);
6666
// lightsource
6767
light* L = (light*)(spatial->dcast_Light());
6868
VERIFY(L);

0 commit comments

Comments
 (0)