|
From: <cn...@us...> - 2009-03-20 04:03:56
|
Revision: 188
http://hgengine.svn.sourceforge.net/hgengine/?rev=188&view=rev
Author: cnlohr
Date: 2009-03-20 04:03:50 +0000 (Fri, 20 Mar 2009)
Log Message:
-----------
fix shader (almost working)
Modified Paths:
--------------
Mercury2/src/Shader.cpp
Modified: Mercury2/src/Shader.cpp
===================================================================
--- Mercury2/src/Shader.cpp 2009-03-20 03:37:43 UTC (rev 187)
+++ Mercury2/src/Shader.cpp 2009-03-20 04:03:50 UTC (rev 188)
@@ -54,6 +54,8 @@
{
bool bApply = true;
+ CheckForNewer();
+
//If there's a currnet shader, we may want to abort switching shaders
if( CurrentShader )
{
@@ -87,6 +89,7 @@
bool Shader::LoadShader( )
{
GetTimeCodes( iTimeCode );
+
MString s1 = sShaderName, s2 = sShaderName, s3 = sShaderName;
MercuryFile * f1;
MercuryFile * f2;
@@ -354,6 +357,7 @@
{
unsigned long iCurTimes[3];
GetTimeCodes( iCurTimes );
+
if( iCurTimes[0] != iTimeCode[0] || iCurTimes[1] != iTimeCode[1] || iCurTimes[2] != iTimeCode[2] )
{
DestroyShader( );
@@ -364,16 +368,28 @@
void Shader::GetTimeCodes( unsigned long * iOut )
{
MercuryFile * f = FILEMAN.Open( sShaderName + ".frag" );
- iOut[0] = f->GetModTime();
- f->Close();
+ if( f )
+ {
+ iOut[0] = f->GetModTime();
+ f->Close();
+ } else
+ iOut[0] = 0;
f = FILEMAN.Open( sShaderName + ".vert" );
- iOut[1] = f->GetModTime();
- f->Close();
+ if( f )
+ {
+ iOut[1] = f->GetModTime();
+ f->Close();
+ } else
+ iOut[1] = 0;
f = FILEMAN.Open( sShaderName + ".geom" );
- iOut[2] = f->GetModTime();
- f->Close();
+ if( f )
+ {
+ iOut[2] = f->GetModTime();
+ f->Close();
+ } else
+ iOut[2] = 0;
}
void Shader::ActivateShader()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-03-28 13:22:45
|
Revision: 190
http://hgengine.svn.sourceforge.net/hgengine/?rev=190&view=rev
Author: axlecrusher
Date: 2009-03-28 13:22:39 +0000 (Sat, 28 Mar 2009)
Log Message:
-----------
fix compile
Modified Paths:
--------------
Mercury2/src/Shader.cpp
Modified: Mercury2/src/Shader.cpp
===================================================================
--- Mercury2/src/Shader.cpp 2009-03-21 02:18:27 UTC (rev 189)
+++ Mercury2/src/Shader.cpp 2009-03-28 13:22:39 UTC (rev 190)
@@ -7,6 +7,8 @@
#include <GL/gl.h>
#include <GL/glext.h>
+#include <string.h>
+
using namespace std;
REGISTER_ASSET_TYPE( Shader );
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-06-14 13:05:37
|
Revision: 322
http://hgengine.svn.sourceforge.net/hgengine/?rev=322&view=rev
Author: axlecrusher
Date: 2009-06-14 13:05:36 +0000 (Sun, 14 Jun 2009)
Log Message:
-----------
error checks
Modified Paths:
--------------
Mercury2/src/Shader.cpp
Modified: Mercury2/src/Shader.cpp
===================================================================
--- Mercury2/src/Shader.cpp 2009-06-14 12:12:29 UTC (rev 321)
+++ Mercury2/src/Shader.cpp 2009-06-14 13:05:36 UTC (rev 322)
@@ -403,6 +403,7 @@
void Shader::ActivateShader()
{
glUseProgramObjectARB( iProgramID );
+ GLERRORCHECK;
for( unsigned i = 0; i < m_vShaderTabs.size(); ++i )
{
@@ -412,10 +413,13 @@
case ShaderAttribute::TYPE_INT:
case ShaderAttribute::TYPE_SAMPLER:
glUniform1iARB( i, sa->sau.iInt );
+ GLERRORCHECK;
break;
case ShaderAttribute::TYPE_FLOAT:
case ShaderAttribute::TYPE_FLOATV4:
glUniform4fvARB( i, 4, &sa->sau.fFloatV4[0] );
+ GLERRORCHECK;
+ break;
};
}
}
@@ -423,6 +427,7 @@
void Shader::DeactivateShader()
{
glUseProgramObjectARB( 0 );
+ GLERRORCHECK;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-06-14 15:22:35
|
Revision: 327
http://hgengine.svn.sourceforge.net/hgengine/?rev=327&view=rev
Author: axlecrusher
Date: 2009-06-14 15:21:35 +0000 (Sun, 14 Jun 2009)
Log Message:
-----------
fix crashing if updated shader is broken
Modified Paths:
--------------
Mercury2/src/Shader.cpp
Modified: Mercury2/src/Shader.cpp
===================================================================
--- Mercury2/src/Shader.cpp 2009-06-14 13:55:32 UTC (rev 326)
+++ Mercury2/src/Shader.cpp 2009-06-14 15:21:35 UTC (rev 327)
@@ -34,7 +34,6 @@
iTimeCode[0] = 0;
iTimeCode[1] = 0;
iTimeCode[2] = 0;
-
}
Shader::~Shader()
@@ -358,6 +357,8 @@
}
glDeleteObjectARB(iProgramID);
+
+ iProgramID = 0;
free( objects );
return;
}
@@ -403,6 +404,8 @@
void Shader::ActivateShader()
{
+ if (iProgramID == 0) return;
+
glUseProgramObjectARB( iProgramID );
GLERRORCHECK;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-06-14 23:48:59
|
Revision: 339
http://hgengine.svn.sourceforge.net/hgengine/?rev=339&view=rev
Author: axlecrusher
Date: 2009-06-14 23:47:59 +0000 (Sun, 14 Jun 2009)
Log Message:
-----------
I think we need to destroy the shader on a failed link
Modified Paths:
--------------
Mercury2/src/Shader.cpp
Modified: Mercury2/src/Shader.cpp
===================================================================
--- Mercury2/src/Shader.cpp 2009-06-14 23:39:48 UTC (rev 338)
+++ Mercury2/src/Shader.cpp 2009-06-14 23:47:59 UTC (rev 339)
@@ -310,6 +310,7 @@
puts( "Linking shaders. response follows:" );
puts( tmpstr );
free( tmpstr );
+ DestroyShader();
return bLinked!=0;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-06-16 02:50:20
|
Revision: 342
http://hgengine.svn.sourceforge.net/hgengine/?rev=342&view=rev
Author: axlecrusher
Date: 2009-06-16 00:45:40 +0000 (Tue, 16 Jun 2009)
Log Message:
-----------
set uniforms when activating
Modified Paths:
--------------
Mercury2/src/Shader.cpp
Modified: Mercury2/src/Shader.cpp
===================================================================
--- Mercury2/src/Shader.cpp 2009-06-16 00:27:10 UTC (rev 341)
+++ Mercury2/src/Shader.cpp 2009-06-16 00:45:40 UTC (rev 342)
@@ -328,13 +328,6 @@
glGetActiveUniformARB( iProgramID, i, 1024, &bufflen, &size, &type, buffer );
buffer[bufflen] = 0;
m_uniforms[buffer] = glGetUniformLocationARB( iProgramID, buffer );
-
- //load in global data if it exists
- std::map< MString, ShaderAttribute >::iterator sai = m_globalAttributes.find( buffer );
- if (sai != m_globalAttributes.end())
- {
- SetAttributeInternal(sai->first, sai->second);
- }
}
return true;
}
@@ -417,7 +410,16 @@
glUseProgramObjectARB( iProgramID );
GLERRORCHECK;
- //set global attributes here
+ //set attributes here
+ std::map< MString, int >::iterator ui = m_uniforms.begin();
+ for (;ui != m_uniforms.end(); ++ui)
+ {
+ std::map< MString, ShaderAttribute >::iterator sai = m_globalAttributes.find( ui->first );
+ if (sai != m_globalAttributes.end())
+ {
+ SetAttributeInternal(sai->first, sai->second);
+ }
+ }
}
void Shader::DeactivateShader()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2009-06-27 22:25:16
|
Revision: 383
http://hgengine.svn.sourceforge.net/hgengine/?rev=383&view=rev
Author: cnlohr
Date: 2009-06-27 22:25:13 +0000 (Sat, 27 Jun 2009)
Log Message:
-----------
glUniformMatrix4fv is an ARB, not in the core.
Modified Paths:
--------------
Mercury2/src/Shader.cpp
Modified: Mercury2/src/Shader.cpp
===================================================================
--- Mercury2/src/Shader.cpp 2009-06-27 22:24:47 UTC (rev 382)
+++ Mercury2/src/Shader.cpp 2009-06-27 22:25:13 UTC (rev 383)
@@ -470,7 +470,7 @@
glUniform4fvARB( location, 4, &x.value.fFloatV4[0] );
break;
case ShaderAttribute::TYPE_MATRIX:
- glUniformMatrix4fv(location, 1, 1, x.value.matrix); //transpase too
+ glUniformMatrix4fvARB(location, 1, 1, x.value.matrix); //transpase too
};
GLERRORCHECK;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2010-01-11 21:56:29
|
Revision: 654
http://hgengine.svn.sourceforge.net/hgengine/?rev=654&view=rev
Author: cnlohr
Date: 2010-01-11 21:56:22 +0000 (Mon, 11 Jan 2010)
Log Message:
-----------
update shader to reflect change in way MercuryFile works.
Modified Paths:
--------------
Mercury2/src/Shader.cpp
Modified: Mercury2/src/Shader.cpp
===================================================================
--- Mercury2/src/Shader.cpp 2010-01-11 21:53:23 UTC (rev 653)
+++ Mercury2/src/Shader.cpp 2010-01-11 21:56:22 UTC (rev 654)
@@ -138,16 +138,14 @@
i = f1->Length();
Buffer = (char*)malloc( i+1 );
f1->Read( Buffer, i );
- f1->Close();
+ SAFE_DELETE( f1 );
LOG.Write( "Compiling: " + s1 );
Buffer[i] = '\0';
if( !LoadShaderFrag( Buffer ) )
{
free( Buffer );
- if( f2 )
- f2->Close();
- if( f3 )
- f3->Close();
+ SAFE_DELETE( f2 );
+ SAFE_DELETE( f3 );
LOG.Write("Reporting failed shaderload. Not linking." );
return false;
}
@@ -158,13 +156,13 @@
i = f2->Length();
Buffer = (char*)malloc( i+1 );
f2->Read( Buffer, i );
- f2->Close();
+ SAFE_DELETE( f2 );
Buffer[i] = '\0';
LOG.Write("Compiling: "+s2);
if( !LoadShaderVert( Buffer ) )
{
if( f3 )
- f3->Close();
+ SAFE_DELETE( f3 );
free( Buffer );
LOG.Write("Reporting failed shaderload. Not linking." );
return false;
@@ -176,7 +174,7 @@
i = f3->Length();
Buffer = (char*)malloc( i+1 );
f3->Read( Buffer, i );
- f3->Close();
+ SAFE_DELETE( f3 );
Buffer[i] = '\0';
LOG.Write("Compiling: "+s3);
if( !LoadShaderGeom( Buffer ) )
@@ -404,7 +402,7 @@
if( f )
{
iOut[0] = f->GetModTime();
- f->Close();
+ delete f;
} else
iOut[0] = 0;
@@ -412,7 +410,7 @@
if( f )
{
iOut[1] = f->GetModTime();
- f->Close();
+ delete f;
} else
iOut[1] = 0;
@@ -420,7 +418,7 @@
if( f )
{
iOut[2] = f->GetModTime();
- f->Close();
+ delete f;
} else
iOut[2] = 0;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-01-17 02:36:17
|
Revision: 670
http://hgengine.svn.sourceforge.net/hgengine/?rev=670&view=rev
Author: axlecrusher
Date: 2010-01-17 02:36:11 +0000 (Sun, 17 Jan 2010)
Log Message:
-----------
fix warning
Modified Paths:
--------------
Mercury2/src/Shader.cpp
Modified: Mercury2/src/Shader.cpp
===================================================================
--- Mercury2/src/Shader.cpp 2010-01-17 02:34:24 UTC (rev 669)
+++ Mercury2/src/Shader.cpp 2010-01-17 02:36:11 UTC (rev 670)
@@ -95,7 +95,7 @@
fPriority = StrToFloat( node.Attribute("priority" ) );
ChangeKey( node.Attribute("file") );
- if (iProgramID == NULL)
+ if (iProgramID == 0)
LoadShader();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-04-28 16:27:13
|
Revision: 711
http://hgengine.svn.sourceforge.net/hgengine/?rev=711&view=rev
Author: axlecrusher
Date: 2010-04-28 16:27:07 +0000 (Wed, 28 Apr 2010)
Log Message:
-----------
Remove.
This is handled by the asset PreRender. Checking every during every render call was really slowing thing down in windows.
Modified Paths:
--------------
Mercury2/src/Shader.cpp
Modified: Mercury2/src/Shader.cpp
===================================================================
--- Mercury2/src/Shader.cpp 2010-04-28 09:21:53 UTC (rev 710)
+++ Mercury2/src/Shader.cpp 2010-04-28 16:27:07 UTC (rev 711)
@@ -63,8 +63,6 @@
{
bool bApply = true;
- CheckForNewer();
-
//If there's a currnet shader, we may want to abort switching shaders
if( CurrentShader )
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|