From 6fc370db8d6a9e168dccd7fa8bf32a6ef461d534 Mon Sep 17 00:00:00 2001 From: Jules Blok Date: Mon, 23 Nov 2015 21:55:13 +0100 Subject: [PATCH] xrRenderGL: Update various OpenGL implementations. --- src/Layers/xrRenderGL/glBufferUtils.cpp | 6 +++--- src/Layers/xrRenderGL/glDetailManager_VS.cpp | 16 +++++++--------- src/Layers/xrRenderGL/glSH_Texture.cpp | 11 ++++------- src/Layers/xrRenderGL/glTextureUtils.cpp | 4 ++-- src/Layers/xrRenderPC_GL/glTexture.cpp | 12 ++++++------ .../gl_rendertarget_accum_omnipart_geom.cpp | 2 +- .../gl_rendertarget_accum_point_geom.cpp | 2 +- .../gl_rendertarget_accum_spot_geom.cpp | 2 +- src/Layers/xrRenderPC_GL/glr_constants.cpp | 14 ++++++++------ src/Layers/xrRenderPC_GL/r2_R_calculate.cpp | 10 +++++----- src/Layers/xrRenderPC_GL/r2_R_sun.cpp | 9 --------- 11 files changed, 38 insertions(+), 50 deletions(-) diff --git a/src/Layers/xrRenderGL/glBufferUtils.cpp b/src/Layers/xrRenderGL/glBufferUtils.cpp index cb06d537efc..66e043810bf 100644 --- a/src/Layers/xrRenderGL/glBufferUtils.cpp +++ b/src/Layers/xrRenderGL/glBufferUtils.cpp @@ -24,7 +24,7 @@ void CreateIndexBuffer(GLuint* pBuffer, const void* pData, UINT DataSize, bool b return CreateBuffer(pBuffer, pData, DataSize, bImmutable, true); } -GLenum VertexSizeList[] = +GLsizei VertexSizeList[] = { 1, // D3DDECLTYPE_FLOAT1 2, // D3DDECLTYPE_FLOAT2 @@ -66,7 +66,7 @@ GLenum VertexTypeList[] = GL_HALF_FLOAT // D3DDECLTYPE_FLOAT16_4 }; -GLenum VertexNormalizedList[] = +GLboolean VertexNormalizedList[] = { GL_FALSE, // D3DDECLTYPE_FLOAT1 GL_FALSE, // D3DDECLTYPE_FLOAT2 @@ -87,7 +87,7 @@ GLenum VertexNormalizedList[] = GL_FALSE // D3DDECLTYPE_FLOAT16_4 }; -GLenum VertexTypeSizeList[] = +GLsizei VertexTypeSizeList[] = { sizeof(GLfloat), // D3DDECLTYPE_FLOAT1 sizeof(GLfloat), // D3DDECLTYPE_FLOAT2 diff --git a/src/Layers/xrRenderGL/glDetailManager_VS.cpp b/src/Layers/xrRenderGL/glDetailManager_VS.cpp index 1becc8daaf6..ffc9b2ac591 100644 --- a/src/Layers/xrRenderGL/glDetailManager_VS.cpp +++ b/src/Layers/xrRenderGL/glDetailManager_VS.cpp @@ -1,10 +1,8 @@ #include "stdafx.h" -#include "../xrRender/DetailManager.h" - -#include "../../xrEngine/igame_persistent.h" -#include "../../xrEngine/environment.h" - -#include "../xrRenderGL/glBufferUtils.h" +#include "Layers/xrRender/DetailManager.h" +#include "xrEngine/IGame_Persistent.h" +#include "xrEngine/Environment.h" +#include "Layers/xrRenderGL/glBufferUtils.h" const int quant = 16384; const int c_hdr = 10; @@ -101,7 +99,7 @@ void CDetailManager::hw_Render_dump(const Fvector4 &consts, const Fvector4 &wave static shared_str strArray("array"); static shared_str strXForm("xform"); - Device.Statistic->RenderDUMP_DT_Count = 0; + RImplementation.BasicStats.DetailCount = 0; // Matrices and offsets u32 vOffset = 0; @@ -180,7 +178,7 @@ void CDetailManager::hw_Render_dump(const Fvector4 &consts, const Fvector4 &wave dwBatch ++; if (dwBatch == hw_BatchSize) { // flush - Device.Statistic->RenderDUMP_DT_Count += dwBatch; + RImplementation.BasicStats.DetailCount += dwBatch; u32 dwCNT_verts = dwBatch * Object.number_vertices; u32 dwCNT_prims = (dwBatch * Object.number_indices)/3; //RCache.get_ConstantCache_Vertex().b_dirty = TRUE; @@ -206,7 +204,7 @@ void CDetailManager::hw_Render_dump(const Fvector4 &consts, const Fvector4 &wave // flush if nessecary if (dwBatch) { - Device.Statistic->RenderDUMP_DT_Count += dwBatch; + RImplementation.BasicStats.DetailCount += dwBatch; u32 dwCNT_verts = dwBatch * Object.number_vertices; u32 dwCNT_prims = (dwBatch * Object.number_indices)/3; //RCache.get_ConstantCache_Vertex().b_dirty = TRUE; diff --git a/src/Layers/xrRenderGL/glSH_Texture.cpp b/src/Layers/xrRenderGL/glSH_Texture.cpp index e1e67a1c82a..5ac4cf4c90a 100644 --- a/src/Layers/xrRenderGL/glSH_Texture.cpp +++ b/src/Layers/xrRenderGL/glSH_Texture.cpp @@ -10,15 +10,13 @@ #include "../../xrEngine/tntQAVI.h" #include "../../xrEngine/xrTheora_Surface.h" -#include "glRenderDeviceRender.h" - #define PRIORITY_HIGH 12 #define PRIORITY_NORMAL 8 #define PRIORITY_LOW 4 void resptrcode_texture::create(LPCSTR _name) { - _set(DEV->_CreateTexture(_name)); + _set(RImplementation.Resources->_CreateTexture(_name)); } @@ -45,9 +43,8 @@ CTexture::CTexture () CTexture::~CTexture() { Unload (); - // release external reference - DEV->_DeleteTexture (this); + RImplementation.Resources->_DeleteTexture(this); } void CTexture::surface_set (GLenum target, GLuint surf ) @@ -134,8 +131,8 @@ void CTexture::apply_normal(u32 dwStage) { void CTexture::Preload () { - m_bumpmap = DEV->m_textures_description.GetBumpName(cName); - m_material = DEV->m_textures_description.GetMaterial(cName); + m_bumpmap = RImplementation.Resources->m_textures_description.GetBumpName(cName); + m_material = RImplementation.Resources->m_textures_description.GetMaterial(cName); } void CTexture::Load () diff --git a/src/Layers/xrRenderGL/glTextureUtils.cpp b/src/Layers/xrRenderGL/glTextureUtils.cpp index 7a62043870f..4d8a96e0017 100644 --- a/src/Layers/xrRenderGL/glTextureUtils.cpp +++ b/src/Layers/xrRenderGL/glTextureUtils.cpp @@ -11,7 +11,7 @@ struct TextureFormatPairs TextureFormatPairs TextureFormatList[] = { - { D3DFMT_UNKNOWN, NULL }, + { D3DFMT_UNKNOWN, GL_NONE }, //D3DFMT_R8G8B8 Not available { D3DFMT_A8R8G8B8, GL_RGBA8 }, // Not available //D3DFMT_X8R8G8B8 Not available @@ -107,6 +107,6 @@ GLenum ConvertTextureFormat(D3DFORMAT dx9FMT) } VERIFY(!"ConvertTextureFormat didn't find appropriate gl texture format!"); - return NULL; + return GL_NONE; } } \ No newline at end of file diff --git a/src/Layers/xrRenderPC_GL/glTexture.cpp b/src/Layers/xrRenderPC_GL/glTexture.cpp index 98ddf4baf43..d71af40c8e0 100644 --- a/src/Layers/xrRenderPC_GL/glTexture.cpp +++ b/src/Layers/xrRenderPC_GL/glTexture.cpp @@ -126,7 +126,7 @@ GLuint CRender::texture_load(LPCSTR fRName, u32& ret_msize, GLenum& ret_desc) glGenTextures(1, &pTexture); glBindTexture(GL_TEXTURE_CUBE_MAP, pTexture); - CHK_GL(glTexStorage2D(GL_TEXTURE_CUBE_MAP, mip_cnt, fmt.Internal, dwWidth, dwHeight)); + CHK_GL(glTexStorage2D(GL_TEXTURE_CUBE_MAP, mip_cnt, (GLenum)fmt.Internal, dwWidth, dwHeight)); for (size_t face = 0; face < Texture.faces(); face++) { @@ -135,11 +135,11 @@ GLuint CRender::texture_load(LPCSTR fRName, u32& ret_msize, GLenum& ret_desc) if (gli::is_compressed(Texture.format())) { CHK_GL(glCompressedTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, i, 0, 0, Texture.dimensions(i).x, Texture.dimensions(i).y, - fmt.Internal, Texture.size(i), Texture.data(0, face, i))); + (GLenum)fmt.Internal, Texture.size(i), Texture.data(0, face, i))); } else { CHK_GL(glTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, i, 0, 0, Texture.dimensions(i).x, Texture.dimensions(i).y, - fmt.External, fmt.Type, Texture.data(0, face, i))); + (GLenum)fmt.External, (GLenum)fmt.Type, Texture.data(0, face, i))); } } } @@ -165,17 +165,17 @@ GLuint CRender::texture_load(LPCSTR fRName, u32& ret_msize, GLenum& ret_desc) glGenTextures(1, &pTexture); glBindTexture(GL_TEXTURE_2D, pTexture); - CHK_GL(glTexStorage2D(GL_TEXTURE_2D, mip_cnt, fmt.Internal, dwWidth, dwHeight)); + CHK_GL(glTexStorage2D(GL_TEXTURE_2D, mip_cnt, (GLenum)fmt.Internal, dwWidth, dwHeight)); for (size_t i = 0; i < mip_cnt; i++) { if (gli::is_compressed(Texture.format())) { CHK_GL(glCompressedTexSubImage2D(GL_TEXTURE_2D, i, 0, 0, Texture.dimensions(i).x, Texture.dimensions(i).y, - fmt.Internal, Texture.size(i), Texture.data(0, 0, i))); + (GLenum)fmt.Internal, Texture.size(i), Texture.data(0, 0, i))); } else { CHK_GL(glTexSubImage2D(GL_TEXTURE_2D, i, 0, 0, Texture.dimensions(i).x, Texture.dimensions(i).y, - fmt.External, fmt.Type, Texture.data(0, 0, i))); + (GLenum)fmt.External, (GLenum)fmt.Type, Texture.data(0, 0, i))); } } FS.r_close(S); diff --git a/src/Layers/xrRenderPC_GL/gl_rendertarget_accum_omnipart_geom.cpp b/src/Layers/xrRenderPC_GL/gl_rendertarget_accum_omnipart_geom.cpp index ec4e2f979d4..1b00bd1ab52 100644 --- a/src/Layers/xrRenderPC_GL/gl_rendertarget_accum_omnipart_geom.cpp +++ b/src/Layers/xrRenderPC_GL/gl_rendertarget_accum_omnipart_geom.cpp @@ -3,7 +3,7 @@ void CRenderTarget::accum_omnip_geom_create () { - u32 dwUsage = GL_STATIC_DRAW; + GLenum dwUsage = GL_STATIC_DRAW; // vertices { diff --git a/src/Layers/xrRenderPC_GL/gl_rendertarget_accum_point_geom.cpp b/src/Layers/xrRenderPC_GL/gl_rendertarget_accum_point_geom.cpp index 17bc928bb73..cfe662fd136 100644 --- a/src/Layers/xrRenderPC_GL/gl_rendertarget_accum_point_geom.cpp +++ b/src/Layers/xrRenderPC_GL/gl_rendertarget_accum_point_geom.cpp @@ -285,7 +285,7 @@ u16 du_sphere_faces[DU_SPHERE_NUMFACES*3]={ void CRenderTarget::accum_point_geom_create() { - u32 dwUsage = GL_STATIC_DRAW; + GLenum dwUsage = GL_STATIC_DRAW; // vertices { diff --git a/src/Layers/xrRenderPC_GL/gl_rendertarget_accum_spot_geom.cpp b/src/Layers/xrRenderPC_GL/gl_rendertarget_accum_spot_geom.cpp index dd75d199766..26e29923d11 100644 --- a/src/Layers/xrRenderPC_GL/gl_rendertarget_accum_spot_geom.cpp +++ b/src/Layers/xrRenderPC_GL/gl_rendertarget_accum_spot_geom.cpp @@ -62,7 +62,7 @@ u16 du_cone_faces[DU_CONE_NUMFACES*3]= void CRenderTarget::accum_spot_geom_create () { - u32 dwUsage = GL_STATIC_DRAW; + GLenum dwUsage = GL_STATIC_DRAW; // vertices { diff --git a/src/Layers/xrRenderPC_GL/glr_constants.cpp b/src/Layers/xrRenderPC_GL/glr_constants.cpp index b2a48dbc803..78fa15d649b 100644 --- a/src/Layers/xrRenderPC_GL/glr_constants.cpp +++ b/src/Layers/xrRenderPC_GL/glr_constants.cpp @@ -2,11 +2,13 @@ #pragma hdrstop #include "../xrRender/r_constants.h" - -void cl_sampler::setup(R_constant* C) +static class cl_sampler : public R_constant_setup { - CHK_GL(glProgramUniform1i(C->samp.program, C->samp.location, C->samp.index)); -} + virtual void setup(R_constant* C) + { + CHK_GL(glProgramUniform1i(C->samp.program, C->samp.location, C->samp.index)); + } +} binder_sampler; IC bool p_sort(ref_constant C1, ref_constant C2) { @@ -109,7 +111,7 @@ BOOL R_constant_table::parse(void* _desc, u16 destination) C->name = name; C->destination = RC_dest_sampler; C->type = RC_sampler; - C->handler = &sampler_binder; + C->handler = &binder_sampler; R_constant_load& L = C->samp; L.index = r_stage++; L.cls = RC_sampler; @@ -120,7 +122,7 @@ BOOL R_constant_table::parse(void* _desc, u16 destination) else { R_ASSERT(C->destination == RC_dest_sampler); R_ASSERT(C->type == RC_sampler); - R_ASSERT(C->handler == &sampler_binder); + R_ASSERT(C->handler == &binder_sampler); R_constant_load& L = C->samp; R_ASSERT(L.index == r_stage); R_ASSERT(L.cls == RC_sampler); diff --git a/src/Layers/xrRenderPC_GL/r2_R_calculate.cpp b/src/Layers/xrRenderPC_GL/r2_R_calculate.cpp index 3f6c8d02ce2..6f91f94168e 100644 --- a/src/Layers/xrRenderPC_GL/r2_R_calculate.cpp +++ b/src/Layers/xrRenderPC_GL/r2_R_calculate.cpp @@ -1,5 +1,5 @@ #include "stdafx.h" -#include "../../xrEngine/customhud.h" +#include "xrEngine/CustomHUD.h" float g_fSCREEN; @@ -45,7 +45,7 @@ void CRender::Calculate() Fvector box_radius; box_radius.set(eps, eps, eps); Sectors_xrc.box_options(CDB::OPT_FULL_TEST); Sectors_xrc.box_query(rmPortals, Device.vCameraPosition, box_radius); - for (int K = 0; Kget_tris()[Sectors_xrc.r_begin()[K].id].dummy]; pPortal->bDualRender = TRUE; } @@ -57,12 +57,12 @@ void CRender::Calculate() // Check if we touch some light even trough portal lstRenderables.clear(); g_SpatialSpace->q_sphere(lstRenderables, 0, STYPE_LIGHTSOURCE, Device.vCameraPosition, EPS_L); - for (u32 _it = 0; _itspatial_updatesector(); - CSector* sector = (CSector*)spatial->spatial.sector; + CSector* sector = (CSector*)spatial->GetSpatialData().sector; if (0 == sector) continue; // disassociated from S/P structure - VERIFY(spatial->spatial.type & STYPE_LIGHTSOURCE); + VERIFY(spatial->GetSpatialData().type & STYPE_LIGHTSOURCE); // lightsource light* L = (light*)(spatial->dcast_Light()); VERIFY(L); diff --git a/src/Layers/xrRenderPC_GL/r2_R_sun.cpp b/src/Layers/xrRenderPC_GL/r2_R_sun.cpp index 1e9248cc501..02974fd88ef 100644 --- a/src/Layers/xrRenderPC_GL/r2_R_sun.cpp +++ b/src/Layers/xrRenderPC_GL/r2_R_sun.cpp @@ -415,15 +415,6 @@ struct DumbClipper } }; -template -inline const _Tp& min(const _Tp& __a, const _Tp& __b) { - return __b < __a ? __b : __a; -} -template -inline const _Tp& max(const _Tp& __a, const _Tp& __b) { - return __a < __b ? __b : __a; -} - xr_vector > s_casters; D3DXVECTOR2 BuildTSMProjectionMatrix_caster_depth_bounds(D3DXMATRIX& lightSpaceBasis)