Skip to content

Commit

Permalink
xrRenderGL: Update various OpenGL implementations.
Browse files Browse the repository at this point in the history
  • Loading branch information
CrossVR committed Nov 23, 2015
1 parent eca94e6 commit 6fc370d
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 50 deletions.
6 changes: 3 additions & 3 deletions src/Layers/xrRenderGL/glBufferUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -66,7 +66,7 @@ GLenum VertexTypeList[] =
GL_HALF_FLOAT // D3DDECLTYPE_FLOAT16_4
};

GLenum VertexNormalizedList[] =
GLboolean VertexNormalizedList[] =
{
GL_FALSE, // D3DDECLTYPE_FLOAT1
GL_FALSE, // D3DDECLTYPE_FLOAT2
Expand All @@ -87,7 +87,7 @@ GLenum VertexNormalizedList[] =
GL_FALSE // D3DDECLTYPE_FLOAT16_4
};

GLenum VertexTypeSizeList[] =
GLsizei VertexTypeSizeList[] =
{
sizeof(GLfloat), // D3DDECLTYPE_FLOAT1
sizeof(GLfloat), // D3DDECLTYPE_FLOAT2
Expand Down
16 changes: 7 additions & 9 deletions src/Layers/xrRenderGL/glDetailManager_VS.cpp
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
11 changes: 4 additions & 7 deletions src/Layers/xrRenderGL/glSH_Texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}


Expand All @@ -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 )
Expand Down Expand Up @@ -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 ()
Expand Down
4 changes: 2 additions & 2 deletions src/Layers/xrRenderGL/glTextureUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -107,6 +107,6 @@ GLenum ConvertTextureFormat(D3DFORMAT dx9FMT)
}

VERIFY(!"ConvertTextureFormat didn't find appropriate gl texture format!");
return NULL;
return GL_NONE;
}
}
12 changes: 6 additions & 6 deletions src/Layers/xrRenderPC_GL/glTexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
{
Expand All @@ -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)));
}
}
}
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

void CRenderTarget::accum_omnip_geom_create ()
{
u32 dwUsage = GL_STATIC_DRAW;
GLenum dwUsage = GL_STATIC_DRAW;

// vertices
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
14 changes: 8 additions & 6 deletions src/Layers/xrRenderPC_GL/glr_constants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions src/Layers/xrRenderPC_GL/r2_R_calculate.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "stdafx.h"
#include "../../xrEngine/customhud.h"
#include "xrEngine/CustomHUD.h"

float g_fSCREEN;

Expand Down Expand Up @@ -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; K<Sectors_xrc.r_count(); K++) {
for (int K = 0; K<Sectors_xrc.r_count(); K++) {
CPortal* pPortal = (CPortal*)Portals[rmPortals->get_tris()[Sectors_xrc.r_begin()[K].id].dummy];
pPortal->bDualRender = TRUE;
}
Expand All @@ -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; _it<lstRenderables.size(); _it++) {
for (u32 _it = 0; _it<lstRenderables.size(); _it++) {
ISpatial* spatial = lstRenderables[_it]; spatial->spatial_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);
Expand Down
9 changes: 0 additions & 9 deletions src/Layers/xrRenderPC_GL/r2_R_sun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,15 +415,6 @@ struct DumbClipper
}
};

template <class _Tp>
inline const _Tp& min(const _Tp& __a, const _Tp& __b) {
return __b < __a ? __b : __a;
}
template <class _Tp>
inline const _Tp& max(const _Tp& __a, const _Tp& __b) {
return __a < __b ? __b : __a;
}

xr_vector<Fbox,render_alloc<Fbox> > s_casters;

D3DXVECTOR2 BuildTSMProjectionMatrix_caster_depth_bounds(D3DXMATRIX& lightSpaceBasis)
Expand Down

0 comments on commit 6fc370d

Please sign in to comment.