1
0
forked from 0ad/0ad

First pass at fixing GLES build - more to come

This was SVN commit r14149.
This commit is contained in:
historic_bruno 2013-11-12 01:17:16 +00:00
parent 0682c23fe3
commit 5771bee032
7 changed files with 106 additions and 11 deletions

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2012 Wildfire Games.
/* Copyright (C) 2013 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -22,6 +22,7 @@
#include "graphics/ShaderManager.h"
#include "graphics/Terrain.h"
#include "lib/bits.h"
#include "lib/config2.h"
#include "ps/CLogger.h"
#include "ps/Game.h"
#include "ps/Profile.h"
@ -147,6 +148,9 @@ void CLOSTexture::InterpolateLOS()
shader->Uniform(str_delta, (float)g_Renderer.GetTimeManager().GetFrameDelta() * 4.0f, 0.0f, 0.0f, 0.0f);
#if CONFIG2_GLES
#warning TODO: fix CLOSTexture::InterpolateLOS for GLES (avoid GL_QUADS/glPushAttrib)
#else
glPushAttrib(GL_VIEWPORT_BIT);
glViewport(0, 0, m_TextureSize, m_TextureSize);
@ -159,6 +163,7 @@ void CLOSTexture::InterpolateLOS()
glEnd();
glPopAttrib();
#endif
shader->Unbind();
m_smoothShader->EndPass();

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2012 Wildfire Games.
/* Copyright (C) 2013 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -20,6 +20,7 @@
#include "ShaderManager.h"
#include "graphics/ShaderTechnique.h"
#include "lib/config2.h"
#include "lib/timer.h"
#include "lib/utf8.h"
#include "ps/CLogger.h"
@ -246,11 +247,19 @@ bool CShaderManager::NewProgram(const char* name, const CShaderDefines& baseDefi
GLenum type = GL_TEXTURE_2D;
CStr t = Attrs.GetNamedItem(at_type);
if (t == "sampler1D")
#if CONFIG2_GLES
debug_warn(L"sampler1D not implemented on GLES");
#else
type = GL_TEXTURE_1D;
#endif
else if (t == "sampler2D")
type = GL_TEXTURE_2D;
else if (t == "sampler3D")
#if CONFIG2_GLES
debug_warn(L"sampler3D not implemented on GLES");
#else
type = GL_TEXTURE_3D;
#endif
else if (t == "samplerCube")
type = GL_TEXTURE_CUBE_MAP;

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2012 Wildfire Games.
/* Copyright (C) 2013 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -660,7 +660,7 @@ CShaderProgram::CShaderProgram(int streamflags)
#if CONFIG2_GLES
/*static*/ CShaderProgram* CShaderProgram::ConstructARB(const VfsPath& vertexFile, const VfsPath& fragmentFile,
const CShaderDefines& UNUSED(defines),
const std::map<CStrIntern, int>& UNUSED(vertexIndexes), const std::map<CStrIntern, int>& UNUSED(fragmentIndexes),
const std::map<CStrIntern, int>& UNUSED(vertexIndexes), const std::map<CStrIntern, frag_index_pair_t>& UNUSED(fragmentIndexes),
int UNUSED(streamflags))
{
LOGERROR(L"CShaderProgram::ConstructARB: '%ls'+'%ls': ARB shaders not supported on this device",

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2011 Wildfire Games
/* Copyright (c) 2013 Wildfire Games
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@ -115,6 +115,7 @@ actually supported).
#define GL_DEPTH_ATTACHMENT_EXT GL_DEPTH_ATTACHMENT
#define GL_COLOR_ATTACHMENT0_EXT GL_COLOR_ATTACHMENT0
#define GL_FRAMEBUFFER_BINDING_EXT GL_FRAMEBUFFER_BINDING
#define GL_FRAMEBUFFER_COMPLETE_EXT GL_FRAMEBUFFER_COMPLETE
#define GL_FRAMEBUFFER_EXT GL_FRAMEBUFFER

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2012 Wildfire Games.
/* Copyright (C) 2013 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -34,6 +34,7 @@
#include "renderer/PostprocManager.h"
#include "renderer/Renderer.h"
#if !CONFIG2_GLES
CPostprocManager::CPostprocManager()
: m_IsInitialised(false), m_PingFbo(0), m_PongFbo(0), m_PostProcEffect(L"default"), m_ColourTex1(0), m_ColourTex2(0),
@ -486,3 +487,66 @@ void CPostprocManager::SetPostEffect(CStrW name)
{
LoadEffect(name);
}
#else
#warning TODO: implement PostprocManager for GLES
void ApplyBlurDownscale2x(GLuint UNUSED(inTex), GLuint UNUSED(outTex), int UNUSED(inWidth), int UNUSED(inHeight))
{
}
void CPostprocManager::ApplyBlurGauss(GLuint UNUSED(inOutTex), GLuint UNUSED(tempTex), int UNUSED(inWidth), int UNUSED(inHeight))
{
}
void CPostprocManager::ApplyEffect(CShaderTechniquePtr &UNUSED(shaderTech1), int UNUSED(pass))
{
}
CPostprocManager::CPostprocManager()
{
}
CPostprocManager::~CPostprocManager()
{
}
void CPostprocManager::Initialize()
{
}
void CPostprocManager::Cleanup()
{
}
void CPostprocManager::RecreateBuffers()
{
}
void CPostprocManager::LoadEffect(CStrW &UNUSED(name))
{
}
std::vector<CStrW> CPostprocManager::GetPostEffects() const
{
return std::vector<CStrW>();
}
void CPostprocManager::SetPostEffect(CStrW UNUSED(name))
{
}
void CPostprocManager::CaptureRenderOutput()
{
}
void CPostprocManager::ApplyPostproc()
{
}
void CPostprocManager::ReleaseRenderOutput()
{
}
#endif

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2012 Wildfire Games.
/* Copyright (C) 2013 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -167,8 +167,11 @@ void SkyManager::LoadSkyTextures()
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
#if CONFIG2_GLES
#warning TODO: fix SkyManager::LoadSkyTextures for GLES
#else
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
#endif
glBindTexture(GL_TEXTURE_2D, 0);
///////////////////////////////////////////////////////////////////////////
}

View File

@ -703,16 +703,25 @@ bool TerrainRenderer::RenderFancyWater(const CShaderDefines& context, ShadowMap*
glGenTextures(1, (GLuint*)&depthTex);
WaterMgr->m_depthTT = depthTex;
glBindTexture(GL_TEXTURE_2D, WaterMgr->m_depthTT);
#if CONFIG2_GLES
GLenum format = GL_DEPTH_COMPONENT;
#else
GLenum format = GL_DEPTH_COMPONENT32;
#endif
// TODO: use POT texture
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32, g_Renderer.GetWidth(), g_Renderer.GetHeight(),
glTexImage2D(GL_TEXTURE_2D, 0, format, g_Renderer.GetWidth(), g_Renderer.GetHeight(),
0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE,NULL);
}
glBindTexture(GL_TEXTURE_2D, WaterMgr->m_depthTT);
#if !CONFIG2_GLES
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_NONE);
#endif
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glCopyTexImage2D(GL_TEXTURE_2D,0,GL_DEPTH_COMPONENT, 0, 0, g_Renderer.GetWidth(), g_Renderer.GetHeight(), 0);
@ -781,7 +790,11 @@ bool TerrainRenderer::RenderFancyWater(const CShaderDefines& context, ShadowMap*
m->wavesShader->TexCoordPointer(GL_TEXTURE0,2,GL_BYTE, stride,&base[WaterMgr->m_VBWaves->m_Index].m_UV);
m->wavesShader->AssertPointersBound();
u8* indexBase = WaterMgr->m_VBWavesIndices->m_Owner->Bind();
#if CONFIG2_GLES
#warning TODO: fix TerrainRenderer::RenderFancyWater for GLES (avoid GL_QUADS)
#else
glDrawElements(GL_QUADS, (GLsizei) WaterMgr->m_VBWavesIndices->m_Count, GL_UNSIGNED_SHORT, indexBase + sizeof(u16)*(WaterMgr->m_VBWavesIndices->m_Index));
#endif
g_Renderer.m_Stats.m_DrawCalls++;
CVertexBuffer::Unbind();
m->wavesShader->Unbind();