Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Alchemy Viewer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Silent mode is enabled
All outbound communications are blocked.
Learn more
.
Show more breadcrumbs
Alchemy Archive
Alchemy Viewer
Commits
59a0c687
Commit
59a0c687
authored
12 years ago
by
Graham Madarasz (Graham)
Browse files
Options
Downloads
Patches
Plain Diff
Fix windoze line-endings from missing commit hook fiasco
parent
7f66555e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
indra/llrender/llpostprocess.cpp
+595
-595
595 additions, 595 deletions
indra/llrender/llpostprocess.cpp
with
595 additions
and
595 deletions
indra/llrender/llpostprocess.cpp
+
595
−
595
View file @
59a0c687
/**
/**
* @file llpostprocess.cpp
* @file llpostprocess.cpp
* @brief LLPostProcess class implementation
* @brief LLPostProcess class implementation
*
*
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
* Second Life Viewer Source Code
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
* Copyright (C) 2010, Linden Research, Inc.
*
*
* This library is free software; you can redistribute it and/or
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
* version 2.1 of the License only.
*
*
* This library is distributed in the hope that it will be useful,
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
* $/LicenseInfo$
*/
*/
#include
"linden_common.h"
#include
"linden_common.h"
#include
"llpostprocess.h"
#include
"llpostprocess.h"
#include
"llglslshader.h"
#include
"llglslshader.h"
#include
"llsdserialize.h"
#include
"llsdserialize.h"
#include
"llrender.h"
#include
"llrender.h"
static
LLStaticHashedString
sRenderTexture
(
"RenderTexture"
);
static
LLStaticHashedString
sRenderTexture
(
"RenderTexture"
);
static
LLStaticHashedString
sBrightness
(
"brightness"
);
static
LLStaticHashedString
sBrightness
(
"brightness"
);
static
LLStaticHashedString
sContrast
(
"contrast"
);
static
LLStaticHashedString
sContrast
(
"contrast"
);
static
LLStaticHashedString
sContrastBase
(
"contrastBase"
);
static
LLStaticHashedString
sContrastBase
(
"contrastBase"
);
static
LLStaticHashedString
sSaturation
(
"saturation"
);
static
LLStaticHashedString
sSaturation
(
"saturation"
);
static
LLStaticHashedString
sLumWeights
(
"lumWeights"
);
static
LLStaticHashedString
sLumWeights
(
"lumWeights"
);
static
LLStaticHashedString
sNoiseTexture
(
"NoiseTexture"
);
static
LLStaticHashedString
sNoiseTexture
(
"NoiseTexture"
);
static
LLStaticHashedString
sBrightMult
(
"brightMult"
);
static
LLStaticHashedString
sBrightMult
(
"brightMult"
);
static
LLStaticHashedString
sNoiseStrength
(
"noiseStrength"
);
static
LLStaticHashedString
sNoiseStrength
(
"noiseStrength"
);
static
LLStaticHashedString
sExtractLow
(
"extractLow"
);
static
LLStaticHashedString
sExtractLow
(
"extractLow"
);
static
LLStaticHashedString
sExtractHigh
(
"extractHigh"
);
static
LLStaticHashedString
sExtractHigh
(
"extractHigh"
);
static
LLStaticHashedString
sBloomStrength
(
"bloomStrength"
);
static
LLStaticHashedString
sBloomStrength
(
"bloomStrength"
);
static
LLStaticHashedString
sTexelSize
(
"texelSize"
);
static
LLStaticHashedString
sTexelSize
(
"texelSize"
);
static
LLStaticHashedString
sBlurDirection
(
"blurDirection"
);
static
LLStaticHashedString
sBlurDirection
(
"blurDirection"
);
static
LLStaticHashedString
sBlurWidth
(
"blurWidth"
);
static
LLStaticHashedString
sBlurWidth
(
"blurWidth"
);
LLPostProcess
*
gPostProcess
=
NULL
;
LLPostProcess
*
gPostProcess
=
NULL
;
static
const
unsigned
int
NOISE_SIZE
=
512
;
static
const
unsigned
int
NOISE_SIZE
=
512
;
/// CALCULATING LUMINANCE (Using NTSC lum weights)
/// CALCULATING LUMINANCE (Using NTSC lum weights)
/// http://en.wikipedia.org/wiki/Luma_%28video%29
/// http://en.wikipedia.org/wiki/Luma_%28video%29
static
const
float
LUMINANCE_R
=
0.299
f
;
static
const
float
LUMINANCE_R
=
0.299
f
;
static
const
float
LUMINANCE_G
=
0.587
f
;
static
const
float
LUMINANCE_G
=
0.587
f
;
static
const
float
LUMINANCE_B
=
0.114
f
;
static
const
float
LUMINANCE_B
=
0.114
f
;
static
const
char
*
const
XML_FILENAME
=
"postprocesseffects.xml"
;
static
const
char
*
const
XML_FILENAME
=
"postprocesseffects.xml"
;
LLPostProcess
::
LLPostProcess
(
void
)
:
LLPostProcess
::
LLPostProcess
(
void
)
:
initialized
(
false
),
initialized
(
false
),
mAllEffects
(
LLSD
::
emptyMap
()),
mAllEffects
(
LLSD
::
emptyMap
()),
screenW
(
1
),
screenH
(
1
)
screenW
(
1
),
screenH
(
1
)
{
{
mSceneRenderTexture
=
NULL
;
mSceneRenderTexture
=
NULL
;
mNoiseTexture
=
NULL
;
mNoiseTexture
=
NULL
;
mTempBloomTexture
=
NULL
;
mTempBloomTexture
=
NULL
;
noiseTextureScale
=
1.0
f
;
noiseTextureScale
=
1.0
f
;
/* Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender.
/* Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender.
std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", XML_FILENAME));
std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", XML_FILENAME));
LL_DEBUGS2("AppInit", "Shaders") << "Loading PostProcess Effects settings from " << pathName << LL_ENDL;
LL_DEBUGS2("AppInit", "Shaders") << "Loading PostProcess Effects settings from " << pathName << LL_ENDL;
llifstream effectsXML(pathName);
llifstream effectsXML(pathName);
if (effectsXML)
if (effectsXML)
{
{
LLPointer<LLSDParser> parser = new LLSDXMLParser();
LLPointer<LLSDParser> parser = new LLSDXMLParser();
parser->parse(effectsXML, mAllEffects, LLSDSerialize::SIZE_UNLIMITED);
parser->parse(effectsXML, mAllEffects, LLSDSerialize::SIZE_UNLIMITED);
}
}
if (!mAllEffects.has("default"))
if (!mAllEffects.has("default"))
{
{
LLSD & defaultEffect = (mAllEffects["default"] = LLSD::emptyMap());
LLSD & defaultEffect = (mAllEffects["default"] = LLSD::emptyMap());
defaultEffect["enable_night_vision"] = LLSD::Boolean(false);
defaultEffect["enable_night_vision"] = LLSD::Boolean(false);
defaultEffect["enable_bloom"] = LLSD::Boolean(false);
defaultEffect["enable_bloom"] = LLSD::Boolean(false);
defaultEffect["enable_color_filter"] = LLSD::Boolean(false);
defaultEffect["enable_color_filter"] = LLSD::Boolean(false);
/// NVG Defaults
/// NVG Defaults
defaultEffect["brightness_multiplier"] = 3.0;
defaultEffect["brightness_multiplier"] = 3.0;
defaultEffect["noise_size"] = 25.0;
defaultEffect["noise_size"] = 25.0;
defaultEffect["noise_strength"] = 0.4;
defaultEffect["noise_strength"] = 0.4;
// TODO BTest potentially add this to tweaks?
// TODO BTest potentially add this to tweaks?
noiseTextureScale = 1.0f;
noiseTextureScale = 1.0f;
/// Bloom Defaults
/// Bloom Defaults
defaultEffect["extract_low"] = 0.95;
defaultEffect["extract_low"] = 0.95;
defaultEffect["extract_high"] = 1.0;
defaultEffect["extract_high"] = 1.0;
defaultEffect["bloom_width"] = 2.25;
defaultEffect["bloom_width"] = 2.25;
defaultEffect["bloom_strength"] = 1.5;
defaultEffect["bloom_strength"] = 1.5;
/// Color Filter Defaults
/// Color Filter Defaults
defaultEffect["brightness"] = 1.0;
defaultEffect["brightness"] = 1.0;
defaultEffect["contrast"] = 1.0;
defaultEffect["contrast"] = 1.0;
defaultEffect["saturation"] = 1.0;
defaultEffect["saturation"] = 1.0;
LLSD& contrastBase = (defaultEffect["contrast_base"] = LLSD::emptyArray());
LLSD& contrastBase = (defaultEffect["contrast_base"] = LLSD::emptyArray());
contrastBase.append(1.0);
contrastBase.append(1.0);
contrastBase.append(1.0);
contrastBase.append(1.0);
contrastBase.append(1.0);
contrastBase.append(1.0);
contrastBase.append(0.5);
contrastBase.append(0.5);
}
}
setSelectedEffect("default");
setSelectedEffect("default");
*/
*/
}
}
LLPostProcess
::~
LLPostProcess
(
void
)
LLPostProcess
::~
LLPostProcess
(
void
)
{
{
invalidate
()
;
invalidate
()
;
}
}
// static
// static
void
LLPostProcess
::
initClass
(
void
)
void
LLPostProcess
::
initClass
(
void
)
{
{
//this will cause system to crash at second time login
//this will cause system to crash at second time login
//if first time login fails due to network connection --- bao
//if first time login fails due to network connection --- bao
//***llassert_always(gPostProcess == NULL);
//***llassert_always(gPostProcess == NULL);
//replaced by the following line:
//replaced by the following line:
if
(
gPostProcess
)
if
(
gPostProcess
)
return
;
return
;
gPostProcess
=
new
LLPostProcess
();
gPostProcess
=
new
LLPostProcess
();
}
}
// static
// static
void
LLPostProcess
::
cleanupClass
()
void
LLPostProcess
::
cleanupClass
()
{
{
delete
gPostProcess
;
delete
gPostProcess
;
gPostProcess
=
NULL
;
gPostProcess
=
NULL
;
}
}
void
LLPostProcess
::
setSelectedEffect
(
std
::
string
const
&
effectName
)
void
LLPostProcess
::
setSelectedEffect
(
std
::
string
const
&
effectName
)
{
{
mSelectedEffectName
=
effectName
;
mSelectedEffectName
=
effectName
;
static_cast
<
LLSD
&>
(
tweaks
)
=
mAllEffects
[
effectName
];
static_cast
<
LLSD
&>
(
tweaks
)
=
mAllEffects
[
effectName
];
}
}
void
LLPostProcess
::
saveEffect
(
std
::
string
const
&
effectName
)
void
LLPostProcess
::
saveEffect
(
std
::
string
const
&
effectName
)
{
{
/* Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender.
/* Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender.
mAllEffects[effectName] = tweaks;
mAllEffects[effectName] = tweaks;
std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", XML_FILENAME));
std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", XML_FILENAME));
//llinfos << "Saving PostProcess Effects settings to " << pathName << llendl;
//llinfos << "Saving PostProcess Effects settings to " << pathName << llendl;
llofstream effectsXML(pathName);
llofstream effectsXML(pathName);
LLPointer<LLSDFormatter> formatter = new LLSDXMLFormatter();
LLPointer<LLSDFormatter> formatter = new LLSDXMLFormatter();
formatter->format(mAllEffects, effectsXML);
formatter->format(mAllEffects, effectsXML);
*/
*/
}
}
void
LLPostProcess
::
invalidate
()
void
LLPostProcess
::
invalidate
()
{
{
mSceneRenderTexture
=
NULL
;
mSceneRenderTexture
=
NULL
;
mNoiseTexture
=
NULL
;
mNoiseTexture
=
NULL
;
mTempBloomTexture
=
NULL
;
mTempBloomTexture
=
NULL
;
initialized
=
FALSE
;
initialized
=
FALSE
;
}
}
void
LLPostProcess
::
apply
(
unsigned
int
width
,
unsigned
int
height
)
void
LLPostProcess
::
apply
(
unsigned
int
width
,
unsigned
int
height
)
{
{
if
(
!
initialized
||
width
!=
screenW
||
height
!=
screenH
){
if
(
!
initialized
||
width
!=
screenW
||
height
!=
screenH
){
initialize
(
width
,
height
);
initialize
(
width
,
height
);
}
}
if
(
shadersEnabled
()){
if
(
shadersEnabled
()){
doEffects
();
doEffects
();
}
}
}
}
void
LLPostProcess
::
initialize
(
unsigned
int
width
,
unsigned
int
height
)
void
LLPostProcess
::
initialize
(
unsigned
int
width
,
unsigned
int
height
)
{
{
screenW
=
width
;
screenW
=
width
;
screenH
=
height
;
screenH
=
height
;
createTexture
(
mSceneRenderTexture
,
screenW
,
screenH
);
createTexture
(
mSceneRenderTexture
,
screenW
,
screenH
);
initialized
=
true
;
initialized
=
true
;
checkError
();
checkError
();
createNightVisionShader
();
createNightVisionShader
();
createBloomShader
();
createBloomShader
();
createColorFilterShader
();
createColorFilterShader
();
checkError
();
checkError
();
}
}
inline
bool
LLPostProcess
::
shadersEnabled
(
void
)
inline
bool
LLPostProcess
::
shadersEnabled
(
void
)
{
{
return
(
tweaks
.
useColorFilter
().
asBoolean
()
||
return
(
tweaks
.
useColorFilter
().
asBoolean
()
||
tweaks
.
useNightVisionShader
().
asBoolean
()
||
tweaks
.
useNightVisionShader
().
asBoolean
()
||
tweaks
.
useBloomShader
().
asBoolean
()
);
tweaks
.
useBloomShader
().
asBoolean
()
);
}
}
void
LLPostProcess
::
applyShaders
(
void
)
void
LLPostProcess
::
applyShaders
(
void
)
{
{
if
(
tweaks
.
useColorFilter
()){
if
(
tweaks
.
useColorFilter
()){
applyColorFilterShader
();
applyColorFilterShader
();
checkError
();
checkError
();
}
}
if
(
tweaks
.
useNightVisionShader
()){
if
(
tweaks
.
useNightVisionShader
()){
/// If any of the above shaders have been called update the frame buffer;
/// If any of the above shaders have been called update the frame buffer;
if
(
tweaks
.
useColorFilter
())
if
(
tweaks
.
useColorFilter
())
{
{
U32
tex
=
mSceneRenderTexture
->
getTexName
()
;
U32
tex
=
mSceneRenderTexture
->
getTexName
()
;
copyFrameBuffer
(
tex
,
screenW
,
screenH
);
copyFrameBuffer
(
tex
,
screenW
,
screenH
);
}
}
applyNightVisionShader
();
applyNightVisionShader
();
checkError
();
checkError
();
}
}
if
(
tweaks
.
useBloomShader
()){
if
(
tweaks
.
useBloomShader
()){
/// If any of the above shaders have been called update the frame buffer;
/// If any of the above shaders have been called update the frame buffer;
if
(
tweaks
.
useColorFilter
().
asBoolean
()
||
tweaks
.
useNightVisionShader
().
asBoolean
())
if
(
tweaks
.
useColorFilter
().
asBoolean
()
||
tweaks
.
useNightVisionShader
().
asBoolean
())
{
{
U32
tex
=
mSceneRenderTexture
->
getTexName
()
;
U32
tex
=
mSceneRenderTexture
->
getTexName
()
;
copyFrameBuffer
(
tex
,
screenW
,
screenH
);
copyFrameBuffer
(
tex
,
screenW
,
screenH
);
}
}
applyBloomShader
();
applyBloomShader
();
checkError
();
checkError
();
}
}
}
}
void
LLPostProcess
::
applyColorFilterShader
(
void
)
void
LLPostProcess
::
applyColorFilterShader
(
void
)
{
{
/* Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender.
/* Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender.
gPostColorFilterProgram.bind();
gPostColorFilterProgram.bind();
gGL.getTexUnit(0)->activate();
gGL.getTexUnit(0)->activate();
gGL.getTexUnit(0)->enable(LLTexUnit::TT_RECT_TEXTURE);
gGL.getTexUnit(0)->enable(LLTexUnit::TT_RECT_TEXTURE);
gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, sceneRenderTexture);
gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, sceneRenderTexture);
getShaderUniforms(colorFilterUniforms, gPostColorFilterProgram.mProgramObject);
getShaderUniforms(colorFilterUniforms, gPostColorFilterProgram.mProgramObject);
glUniform1iARB(colorFilterUniforms["RenderTexture"], 0);
glUniform1iARB(colorFilterUniforms["RenderTexture"], 0);
glUniform1fARB(colorFilterUniforms["brightness"], tweaks.getBrightness());
glUniform1fARB(colorFilterUniforms["brightness"], tweaks.getBrightness());
glUniform1fARB(colorFilterUniforms["contrast"], tweaks.getContrast());
glUniform1fARB(colorFilterUniforms["contrast"], tweaks.getContrast());
float baseI = (tweaks.getContrastBaseR() + tweaks.getContrastBaseG() + tweaks.getContrastBaseB()) / 3.0f;
float baseI = (tweaks.getContrastBaseR() + tweaks.getContrastBaseG() + tweaks.getContrastBaseB()) / 3.0f;
baseI = tweaks.getContrastBaseIntensity() / ((baseI < 0.001f) ? 0.001f : baseI);
baseI = tweaks.getContrastBaseIntensity() / ((baseI < 0.001f) ? 0.001f : baseI);
float baseR = tweaks.getContrastBaseR() * baseI;
float baseR = tweaks.getContrastBaseR() * baseI;
float baseG = tweaks.getContrastBaseG() * baseI;
float baseG = tweaks.getContrastBaseG() * baseI;
float baseB = tweaks.getContrastBaseB() * baseI;
float baseB = tweaks.getContrastBaseB() * baseI;
glUniform3fARB(colorFilterUniforms["contrastBase"], baseR, baseG, baseB);
glUniform3fARB(colorFilterUniforms["contrastBase"], baseR, baseG, baseB);
glUniform1fARB(colorFilterUniforms["saturation"], tweaks.getSaturation());
glUniform1fARB(colorFilterUniforms["saturation"], tweaks.getSaturation());
glUniform3fARB(colorFilterUniforms["lumWeights"], LUMINANCE_R, LUMINANCE_G, LUMINANCE_B);
glUniform3fARB(colorFilterUniforms["lumWeights"], LUMINANCE_R, LUMINANCE_G, LUMINANCE_B);
LLGLEnable blend(GL_BLEND);
LLGLEnable blend(GL_BLEND);
gGL.setSceneBlendType(LLRender::BT_REPLACE);
gGL.setSceneBlendType(LLRender::BT_REPLACE);
LLGLDepthTest depth(GL_FALSE);
LLGLDepthTest depth(GL_FALSE);
/// Draw a screen space quad
/// Draw a screen space quad
drawOrthoQuad(screenW, screenH, QUAD_NORMAL);
drawOrthoQuad(screenW, screenH, QUAD_NORMAL);
gPostColorFilterProgram.unbind();
gPostColorFilterProgram.unbind();
*/
*/
}
}
void
LLPostProcess
::
createColorFilterShader
(
void
)
void
LLPostProcess
::
createColorFilterShader
(
void
)
{
{
/// Define uniform names
/// Define uniform names
colorFilterUniforms
[
sRenderTexture
]
=
0
;
colorFilterUniforms
[
sRenderTexture
]
=
0
;
colorFilterUniforms
[
sBrightness
]
=
0
;
colorFilterUniforms
[
sBrightness
]
=
0
;
colorFilterUniforms
[
sContrast
]
=
0
;
colorFilterUniforms
[
sContrast
]
=
0
;
colorFilterUniforms
[
sContrastBase
]
=
0
;
colorFilterUniforms
[
sContrastBase
]
=
0
;
colorFilterUniforms
[
sSaturation
]
=
0
;
colorFilterUniforms
[
sSaturation
]
=
0
;
colorFilterUniforms
[
sLumWeights
]
=
0
;
colorFilterUniforms
[
sLumWeights
]
=
0
;
}
}
void
LLPostProcess
::
applyNightVisionShader
(
void
)
void
LLPostProcess
::
applyNightVisionShader
(
void
)
{
{
/* Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender.
/* Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender.
gPostNightVisionProgram.bind();
gPostNightVisionProgram.bind();
gGL.getTexUnit(0)->activate();
gGL.getTexUnit(0)->activate();
gGL.getTexUnit(0)->enable(LLTexUnit::TT_RECT_TEXTURE);
gGL.getTexUnit(0)->enable(LLTexUnit::TT_RECT_TEXTURE);
getShaderUniforms(nightVisionUniforms, gPostNightVisionProgram.mProgramObject);
getShaderUniforms(nightVisionUniforms, gPostNightVisionProgram.mProgramObject);
gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, sceneRenderTexture);
gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, sceneRenderTexture);
glUniform1iARB(nightVisionUniforms["RenderTexture"], 0);
glUniform1iARB(nightVisionUniforms["RenderTexture"], 0);
gGL.getTexUnit(1)->activate();
gGL.getTexUnit(1)->activate();
gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE);
gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE);
gGL.getTexUnit(1)->bindManual(LLTexUnit::TT_TEXTURE, noiseTexture);
gGL.getTexUnit(1)->bindManual(LLTexUnit::TT_TEXTURE, noiseTexture);
glUniform1iARB(nightVisionUniforms["NoiseTexture"], 1);
glUniform1iARB(nightVisionUniforms["NoiseTexture"], 1);
glUniform1fARB(nightVisionUniforms["brightMult"], tweaks.getBrightMult());
glUniform1fARB(nightVisionUniforms["brightMult"], tweaks.getBrightMult());
glUniform1fARB(nightVisionUniforms["noiseStrength"], tweaks.getNoiseStrength());
glUniform1fARB(nightVisionUniforms["noiseStrength"], tweaks.getNoiseStrength());
noiseTextureScale = 0.01f + ((101.f - tweaks.getNoiseSize()) / 100.f);
noiseTextureScale = 0.01f + ((101.f - tweaks.getNoiseSize()) / 100.f);
noiseTextureScale *= (screenH / NOISE_SIZE);
noiseTextureScale *= (screenH / NOISE_SIZE);
glUniform3fARB(nightVisionUniforms["lumWeights"], LUMINANCE_R, LUMINANCE_G, LUMINANCE_B);
glUniform3fARB(nightVisionUniforms["lumWeights"], LUMINANCE_R, LUMINANCE_G, LUMINANCE_B);
LLGLEnable blend(GL_BLEND);
LLGLEnable blend(GL_BLEND);
gGL.setSceneBlendType(LLRender::BT_REPLACE);
gGL.setSceneBlendType(LLRender::BT_REPLACE);
LLGLDepthTest depth(GL_FALSE);
LLGLDepthTest depth(GL_FALSE);
/// Draw a screen space quad
/// Draw a screen space quad
drawOrthoQuad(screenW, screenH, QUAD_NOISE);
drawOrthoQuad(screenW, screenH, QUAD_NOISE);
gPostNightVisionProgram.unbind();
gPostNightVisionProgram.unbind();
gGL.getTexUnit(0)->activate();
gGL.getTexUnit(0)->activate();
*/
*/
}
}
void
LLPostProcess
::
createNightVisionShader
(
void
)
void
LLPostProcess
::
createNightVisionShader
(
void
)
{
{
/// Define uniform names
/// Define uniform names
nightVisionUniforms
[
sRenderTexture
]
=
0
;
nightVisionUniforms
[
sRenderTexture
]
=
0
;
nightVisionUniforms
[
sNoiseTexture
]
=
0
;
nightVisionUniforms
[
sNoiseTexture
]
=
0
;
nightVisionUniforms
[
sBrightMult
]
=
0
;
nightVisionUniforms
[
sBrightMult
]
=
0
;
nightVisionUniforms
[
sNoiseStrength
]
=
0
;
nightVisionUniforms
[
sNoiseStrength
]
=
0
;
nightVisionUniforms
[
sLumWeights
]
=
0
;
nightVisionUniforms
[
sLumWeights
]
=
0
;
createNoiseTexture
(
mNoiseTexture
);
createNoiseTexture
(
mNoiseTexture
);
}
}
void
LLPostProcess
::
applyBloomShader
(
void
)
void
LLPostProcess
::
applyBloomShader
(
void
)
{
{
}
}
void
LLPostProcess
::
createBloomShader
(
void
)
void
LLPostProcess
::
createBloomShader
(
void
)
{
{
createTexture
(
mTempBloomTexture
,
unsigned
(
screenW
*
0.5
),
unsigned
(
screenH
*
0.5
));
createTexture
(
mTempBloomTexture
,
unsigned
(
screenW
*
0.5
),
unsigned
(
screenH
*
0.5
));
/// Create Bloom Extract Shader
/// Create Bloom Extract Shader
bloomExtractUniforms
[
sRenderTexture
]
=
0
;
bloomExtractUniforms
[
sRenderTexture
]
=
0
;
bloomExtractUniforms
[
sExtractLow
]
=
0
;
bloomExtractUniforms
[
sExtractLow
]
=
0
;
bloomExtractUniforms
[
sExtractHigh
]
=
0
;
bloomExtractUniforms
[
sExtractHigh
]
=
0
;
bloomExtractUniforms
[
sLumWeights
]
=
0
;
bloomExtractUniforms
[
sLumWeights
]
=
0
;
/// Create Bloom Blur Shader
/// Create Bloom Blur Shader
bloomBlurUniforms
[
sRenderTexture
]
=
0
;
bloomBlurUniforms
[
sRenderTexture
]
=
0
;
bloomBlurUniforms
[
sBloomStrength
]
=
0
;
bloomBlurUniforms
[
sBloomStrength
]
=
0
;
bloomBlurUniforms
[
sTexelSize
]
=
0
;
bloomBlurUniforms
[
sTexelSize
]
=
0
;
bloomBlurUniforms
[
sBlurDirection
]
=
0
;
bloomBlurUniforms
[
sBlurDirection
]
=
0
;
bloomBlurUniforms
[
sBlurWidth
]
=
0
;
bloomBlurUniforms
[
sBlurWidth
]
=
0
;
}
}
void
LLPostProcess
::
getShaderUniforms
(
glslUniforms
&
uniforms
,
GLhandleARB
&
prog
)
void
LLPostProcess
::
getShaderUniforms
(
glslUniforms
&
uniforms
,
GLhandleARB
&
prog
)
{
{
/// Find uniform locations and insert into map
/// Find uniform locations and insert into map
glslUniforms
::
iterator
i
;
glslUniforms
::
iterator
i
;
for
(
i
=
uniforms
.
begin
();
i
!=
uniforms
.
end
();
++
i
){
for
(
i
=
uniforms
.
begin
();
i
!=
uniforms
.
end
();
++
i
){
i
->
second
=
glGetUniformLocationARB
(
prog
,
i
->
first
.
String
().
c_str
());
i
->
second
=
glGetUniformLocationARB
(
prog
,
i
->
first
.
String
().
c_str
());
}
}
}
}
void
LLPostProcess
::
doEffects
(
void
)
void
LLPostProcess
::
doEffects
(
void
)
{
{
/// Save GL State
/// Save GL State
glPushAttrib
(
GL_ALL_ATTRIB_BITS
);
glPushAttrib
(
GL_ALL_ATTRIB_BITS
);
glPushClientAttrib
(
GL_ALL_ATTRIB_BITS
);
glPushClientAttrib
(
GL_ALL_ATTRIB_BITS
);
/// Copy the screen buffer to the render texture
/// Copy the screen buffer to the render texture
{
{
U32
tex
=
mSceneRenderTexture
->
getTexName
()
;
U32
tex
=
mSceneRenderTexture
->
getTexName
()
;
copyFrameBuffer
(
tex
,
screenW
,
screenH
);
copyFrameBuffer
(
tex
,
screenW
,
screenH
);
}
}
/// Clear the frame buffer.
/// Clear the frame buffer.
glClearColor
(
0.0
f
,
0.0
f
,
0.0
f
,
1.0
f
);
glClearColor
(
0.0
f
,
0.0
f
,
0.0
f
,
1.0
f
);
glClear
(
GL_COLOR_BUFFER_BIT
);
glClear
(
GL_COLOR_BUFFER_BIT
);
/// Change to an orthogonal view
/// Change to an orthogonal view
viewOrthogonal
(
screenW
,
screenH
);
viewOrthogonal
(
screenW
,
screenH
);
checkError
();
checkError
();
applyShaders
();
applyShaders
();
LLGLSLShader
::
bindNoShader
();
LLGLSLShader
::
bindNoShader
();
checkError
();
checkError
();
/// Change to a perspective view
/// Change to a perspective view
viewPerspective
();
viewPerspective
();
/// Reset GL State
/// Reset GL State
glPopClientAttrib
();
glPopClientAttrib
();
glPopAttrib
();
glPopAttrib
();
checkError
();
checkError
();
}
}
void
LLPostProcess
::
copyFrameBuffer
(
U32
&
texture
,
unsigned
int
width
,
unsigned
int
height
)
void
LLPostProcess
::
copyFrameBuffer
(
U32
&
texture
,
unsigned
int
width
,
unsigned
int
height
)
{
{
gGL
.
getTexUnit
(
0
)
->
bindManual
(
LLTexUnit
::
TT_RECT_TEXTURE
,
texture
);
gGL
.
getTexUnit
(
0
)
->
bindManual
(
LLTexUnit
::
TT_RECT_TEXTURE
,
texture
);
glCopyTexImage2D
(
GL_TEXTURE_RECTANGLE_ARB
,
0
,
GL_RGBA
,
0
,
0
,
width
,
height
,
0
);
glCopyTexImage2D
(
GL_TEXTURE_RECTANGLE_ARB
,
0
,
GL_RGBA
,
0
,
0
,
width
,
height
,
0
);
}
}
void
LLPostProcess
::
drawOrthoQuad
(
unsigned
int
width
,
unsigned
int
height
,
QuadType
type
)
void
LLPostProcess
::
drawOrthoQuad
(
unsigned
int
width
,
unsigned
int
height
,
QuadType
type
)
{
{
#if 0
#if 0
float noiseX = 0.f;
float noiseX = 0.f;
float noiseY = 0.f;
float noiseY = 0.f;
float screenRatio = 1.0f;
float screenRatio = 1.0f;
if (type == QUAD_NOISE){
if (type == QUAD_NOISE){
noiseX = ((float) rand() / (float) RAND_MAX);
noiseX = ((float) rand() / (float) RAND_MAX);
noiseY = ((float) rand() / (float) RAND_MAX);
noiseY = ((float) rand() / (float) RAND_MAX);
screenRatio = (float) width / (float) height;
screenRatio = (float) width / (float) height;
}
}
glBegin(GL_QUADS);
glBegin(GL_QUADS);
if (type != QUAD_BLOOM_EXTRACT){
if (type != QUAD_BLOOM_EXTRACT){
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.f, (GLfloat) height);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.f, (GLfloat) height);
} else {
} else {
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.f, (GLfloat) height * 2.0f);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.f, (GLfloat) height * 2.0f);
}
}
if (type == QUAD_NOISE){
if (type == QUAD_NOISE){
glMultiTexCoord2fARB(GL_TEXTURE1_ARB,
glMultiTexCoord2fARB(GL_TEXTURE1_ARB,
noiseX,
noiseX,
noiseTextureScale + noiseY);
noiseTextureScale + noiseY);
} else if (type == QUAD_BLOOM_COMBINE){
} else if (type == QUAD_BLOOM_COMBINE){
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.f, (GLfloat) height * 0.5f);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.f, (GLfloat) height * 0.5f);
}
}
glVertex2f(0.f, (GLfloat) screenH - height);
glVertex2f(0.f, (GLfloat) screenH - height);
if (type != QUAD_BLOOM_EXTRACT){
if (type != QUAD_BLOOM_EXTRACT){
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.f, 0.f);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.f, 0.f);
} else {
} else {
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.f, 0.f);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.f, 0.f);
}
}
if (type == QUAD_NOISE){
if (type == QUAD_NOISE){
glMultiTexCoord2fARB(GL_TEXTURE1_ARB,
glMultiTexCoord2fARB(GL_TEXTURE1_ARB,
noiseX,
noiseX,
noiseY);
noiseY);
} else if (type == QUAD_BLOOM_COMBINE){
} else if (type == QUAD_BLOOM_COMBINE){
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.f, 0.f);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.f, 0.f);
}
}
glVertex2f(0.f, (GLfloat) height + (screenH - height));
glVertex2f(0.f, (GLfloat) height + (screenH - height));
if (type != QUAD_BLOOM_EXTRACT){
if (type != QUAD_BLOOM_EXTRACT){
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, (GLfloat) width, 0.f);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, (GLfloat) width, 0.f);
} else {
} else {
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, (GLfloat) width * 2.0f, 0.f);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, (GLfloat) width * 2.0f, 0.f);
}
}
if (type == QUAD_NOISE){
if (type == QUAD_NOISE){
glMultiTexCoord2fARB(GL_TEXTURE1_ARB,
glMultiTexCoord2fARB(GL_TEXTURE1_ARB,
screenRatio * noiseTextureScale + noiseX,
screenRatio * noiseTextureScale + noiseX,
noiseY);
noiseY);
} else if (type == QUAD_BLOOM_COMBINE){
} else if (type == QUAD_BLOOM_COMBINE){
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, (GLfloat) width * 0.5f, 0.f);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, (GLfloat) width * 0.5f, 0.f);
}
}
glVertex2f((GLfloat) width, (GLfloat) height + (screenH - height));
glVertex2f((GLfloat) width, (GLfloat) height + (screenH - height));
if (type != QUAD_BLOOM_EXTRACT){
if (type != QUAD_BLOOM_EXTRACT){
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, (GLfloat) width, (GLfloat) height);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, (GLfloat) width, (GLfloat) height);
} else {
} else {
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, (GLfloat) width * 2.0f, (GLfloat) height * 2.0f);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, (GLfloat) width * 2.0f, (GLfloat) height * 2.0f);
}
}
if (type == QUAD_NOISE){
if (type == QUAD_NOISE){
glMultiTexCoord2fARB(GL_TEXTURE1_ARB,
glMultiTexCoord2fARB(GL_TEXTURE1_ARB,
screenRatio * noiseTextureScale + noiseX,
screenRatio * noiseTextureScale + noiseX,
noiseTextureScale + noiseY);
noiseTextureScale + noiseY);
} else if (type == QUAD_BLOOM_COMBINE){
} else if (type == QUAD_BLOOM_COMBINE){
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, (GLfloat) width * 0.5f, (GLfloat) height * 0.5f);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, (GLfloat) width * 0.5f, (GLfloat) height * 0.5f);
}
}
glVertex2f((GLfloat) width, (GLfloat) screenH - height);
glVertex2f((GLfloat) width, (GLfloat) screenH - height);
glEnd();
glEnd();
#endif
#endif
}
}
void
LLPostProcess
::
viewOrthogonal
(
unsigned
int
width
,
unsigned
int
height
)
void
LLPostProcess
::
viewOrthogonal
(
unsigned
int
width
,
unsigned
int
height
)
{
{
gGL
.
matrixMode
(
LLRender
::
MM_PROJECTION
);
gGL
.
matrixMode
(
LLRender
::
MM_PROJECTION
);
gGL
.
pushMatrix
();
gGL
.
pushMatrix
();
gGL
.
loadIdentity
();
gGL
.
loadIdentity
();
gGL
.
ortho
(
0.
f
,
(
GLdouble
)
width
,
(
GLdouble
)
height
,
0.
f
,
-
1.
f
,
1.
f
);
gGL
.
ortho
(
0.
f
,
(
GLdouble
)
width
,
(
GLdouble
)
height
,
0.
f
,
-
1.
f
,
1.
f
);
gGL
.
matrixMode
(
LLRender
::
MM_MODELVIEW
);
gGL
.
matrixMode
(
LLRender
::
MM_MODELVIEW
);
gGL
.
pushMatrix
();
gGL
.
pushMatrix
();
gGL
.
loadIdentity
();
gGL
.
loadIdentity
();
}
}
void
LLPostProcess
::
viewPerspective
(
void
)
void
LLPostProcess
::
viewPerspective
(
void
)
{
{
gGL
.
matrixMode
(
LLRender
::
MM_PROJECTION
);
gGL
.
matrixMode
(
LLRender
::
MM_PROJECTION
);
gGL
.
popMatrix
();
gGL
.
popMatrix
();
gGL
.
matrixMode
(
LLRender
::
MM_MODELVIEW
);
gGL
.
matrixMode
(
LLRender
::
MM_MODELVIEW
);
gGL
.
popMatrix
();
gGL
.
popMatrix
();
}
}
void
LLPostProcess
::
changeOrthogonal
(
unsigned
int
width
,
unsigned
int
height
)
void
LLPostProcess
::
changeOrthogonal
(
unsigned
int
width
,
unsigned
int
height
)
{
{
viewPerspective
();
viewPerspective
();
viewOrthogonal
(
width
,
height
);
viewOrthogonal
(
width
,
height
);
}
}
void
LLPostProcess
::
createTexture
(
LLPointer
<
LLImageGL
>&
texture
,
unsigned
int
width
,
unsigned
int
height
)
void
LLPostProcess
::
createTexture
(
LLPointer
<
LLImageGL
>&
texture
,
unsigned
int
width
,
unsigned
int
height
)
{
{
std
::
vector
<
GLubyte
>
data
(
width
*
height
*
4
,
0
)
;
std
::
vector
<
GLubyte
>
data
(
width
*
height
*
4
,
0
)
;
texture
=
new
LLImageGL
(
FALSE
)
;
texture
=
new
LLImageGL
(
FALSE
)
;
if
(
texture
->
createGLTexture
())
if
(
texture
->
createGLTexture
())
{
{
gGL
.
getTexUnit
(
0
)
->
bindManual
(
LLTexUnit
::
TT_RECT_TEXTURE
,
texture
->
getTexName
());
gGL
.
getTexUnit
(
0
)
->
bindManual
(
LLTexUnit
::
TT_RECT_TEXTURE
,
texture
->
getTexName
());
glTexImage2D
(
GL_TEXTURE_RECTANGLE_ARB
,
0
,
4
,
width
,
height
,
0
,
glTexImage2D
(
GL_TEXTURE_RECTANGLE_ARB
,
0
,
4
,
width
,
height
,
0
,
GL_RGBA
,
GL_UNSIGNED_BYTE
,
&
data
[
0
]);
GL_RGBA
,
GL_UNSIGNED_BYTE
,
&
data
[
0
]);
gGL
.
getTexUnit
(
0
)
->
setTextureFilteringOption
(
LLTexUnit
::
TFO_BILINEAR
);
gGL
.
getTexUnit
(
0
)
->
setTextureFilteringOption
(
LLTexUnit
::
TFO_BILINEAR
);
gGL
.
getTexUnit
(
0
)
->
setTextureAddressMode
(
LLTexUnit
::
TAM_CLAMP
);
gGL
.
getTexUnit
(
0
)
->
setTextureAddressMode
(
LLTexUnit
::
TAM_CLAMP
);
}
}
}
}
void
LLPostProcess
::
createNoiseTexture
(
LLPointer
<
LLImageGL
>&
texture
)
void
LLPostProcess
::
createNoiseTexture
(
LLPointer
<
LLImageGL
>&
texture
)
{
{
std
::
vector
<
GLubyte
>
buffer
(
NOISE_SIZE
*
NOISE_SIZE
);
std
::
vector
<
GLubyte
>
buffer
(
NOISE_SIZE
*
NOISE_SIZE
);
for
(
unsigned
int
i
=
0
;
i
<
NOISE_SIZE
;
i
++
){
for
(
unsigned
int
i
=
0
;
i
<
NOISE_SIZE
;
i
++
){
for
(
unsigned
int
k
=
0
;
k
<
NOISE_SIZE
;
k
++
){
for
(
unsigned
int
k
=
0
;
k
<
NOISE_SIZE
;
k
++
){
buffer
[(
i
*
NOISE_SIZE
)
+
k
]
=
(
GLubyte
)((
double
)
rand
()
/
((
double
)
RAND_MAX
+
1.
f
)
*
255.
f
);
buffer
[(
i
*
NOISE_SIZE
)
+
k
]
=
(
GLubyte
)((
double
)
rand
()
/
((
double
)
RAND_MAX
+
1.
f
)
*
255.
f
);
}
}
}
}
texture
=
new
LLImageGL
(
FALSE
)
;
texture
=
new
LLImageGL
(
FALSE
)
;
if
(
texture
->
createGLTexture
())
if
(
texture
->
createGLTexture
())
{
{
gGL
.
getTexUnit
(
0
)
->
bindManual
(
LLTexUnit
::
TT_TEXTURE
,
texture
->
getTexName
());
gGL
.
getTexUnit
(
0
)
->
bindManual
(
LLTexUnit
::
TT_TEXTURE
,
texture
->
getTexName
());
LLImageGL
::
setManualImage
(
GL_TEXTURE_2D
,
0
,
GL_LUMINANCE
,
NOISE_SIZE
,
NOISE_SIZE
,
GL_LUMINANCE
,
GL_UNSIGNED_BYTE
,
&
buffer
[
0
]);
LLImageGL
::
setManualImage
(
GL_TEXTURE_2D
,
0
,
GL_LUMINANCE
,
NOISE_SIZE
,
NOISE_SIZE
,
GL_LUMINANCE
,
GL_UNSIGNED_BYTE
,
&
buffer
[
0
]);
gGL
.
getTexUnit
(
0
)
->
setTextureFilteringOption
(
LLTexUnit
::
TFO_BILINEAR
);
gGL
.
getTexUnit
(
0
)
->
setTextureFilteringOption
(
LLTexUnit
::
TFO_BILINEAR
);
gGL
.
getTexUnit
(
0
)
->
setTextureAddressMode
(
LLTexUnit
::
TAM_WRAP
);
gGL
.
getTexUnit
(
0
)
->
setTextureAddressMode
(
LLTexUnit
::
TAM_WRAP
);
}
}
}
}
bool
LLPostProcess
::
checkError
(
void
)
bool
LLPostProcess
::
checkError
(
void
)
{
{
GLenum
glErr
;
GLenum
glErr
;
bool
retCode
=
false
;
bool
retCode
=
false
;
glErr
=
glGetError
();
glErr
=
glGetError
();
while
(
glErr
!=
GL_NO_ERROR
)
while
(
glErr
!=
GL_NO_ERROR
)
{
{
// shaderErrorLog << (const char *) gluErrorString(glErr) << std::endl;
// shaderErrorLog << (const char *) gluErrorString(glErr) << std::endl;
char
const
*
err_str_raw
=
(
const
char
*
)
gluErrorString
(
glErr
);
char
const
*
err_str_raw
=
(
const
char
*
)
gluErrorString
(
glErr
);
if
(
err_str_raw
==
NULL
)
if
(
err_str_raw
==
NULL
)
{
{
std
::
ostringstream
err_builder
;
std
::
ostringstream
err_builder
;
err_builder
<<
"unknown error number "
<<
glErr
;
err_builder
<<
"unknown error number "
<<
glErr
;
mShaderErrorString
=
err_builder
.
str
();
mShaderErrorString
=
err_builder
.
str
();
}
}
else
else
{
{
mShaderErrorString
=
err_str_raw
;
mShaderErrorString
=
err_str_raw
;
}
}
retCode
=
true
;
retCode
=
true
;
glErr
=
glGetError
();
glErr
=
glGetError
();
}
}
return
retCode
;
return
retCode
;
}
}
void
LLPostProcess
::
checkShaderError
(
GLhandleARB
shader
)
void
LLPostProcess
::
checkShaderError
(
GLhandleARB
shader
)
{
{
GLint
infologLength
=
0
;
GLint
infologLength
=
0
;
GLint
charsWritten
=
0
;
GLint
charsWritten
=
0
;
GLchar
*
infoLog
;
GLchar
*
infoLog
;
checkError
();
// Check for OpenGL errors
checkError
();
// Check for OpenGL errors
glGetObjectParameterivARB
(
shader
,
GL_OBJECT_INFO_LOG_LENGTH_ARB
,
&
infologLength
);
glGetObjectParameterivARB
(
shader
,
GL_OBJECT_INFO_LOG_LENGTH_ARB
,
&
infologLength
);
checkError
();
// Check for OpenGL errors
checkError
();
// Check for OpenGL errors
if
(
infologLength
>
0
)
if
(
infologLength
>
0
)
{
{
infoLog
=
(
GLchar
*
)
malloc
(
infologLength
);
infoLog
=
(
GLchar
*
)
malloc
(
infologLength
);
if
(
infoLog
==
NULL
)
if
(
infoLog
==
NULL
)
{
{
/// Could not allocate infolog buffer
/// Could not allocate infolog buffer
return
;
return
;
}
}
glGetInfoLogARB
(
shader
,
infologLength
,
&
charsWritten
,
infoLog
);
glGetInfoLogARB
(
shader
,
infologLength
,
&
charsWritten
,
infoLog
);
// shaderErrorLog << (char *) infoLog << std::endl;
// shaderErrorLog << (char *) infoLog << std::endl;
mShaderErrorString
=
(
char
*
)
infoLog
;
mShaderErrorString
=
(
char
*
)
infoLog
;
free
(
infoLog
);
free
(
infoLog
);
}
}
checkError
();
// Check for OpenGL errors
checkError
();
// Check for OpenGL errors
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment