You can subscribe to this list here.
| 2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(46) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2006 |
Jan
(185) |
Feb
(242) |
Mar
(237) |
Apr
(180) |
May
(102) |
Jun
(278) |
Jul
(114) |
Aug
(92) |
Sep
(246) |
Oct
(212) |
Nov
(279) |
Dec
(99) |
| 2007 |
Jan
(130) |
Feb
(194) |
Mar
(22) |
Apr
(72) |
May
(40) |
Jun
(111) |
Jul
(114) |
Aug
(154) |
Sep
(114) |
Oct
(2) |
Nov
(1) |
Dec
(5) |
| 2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(6) |
Oct
(51) |
Nov
(34) |
Dec
(130) |
| 2009 |
Jan
(22) |
Feb
(20) |
Mar
(41) |
Apr
(45) |
May
(82) |
Jun
(96) |
Jul
(48) |
Aug
(90) |
Sep
(13) |
Oct
(49) |
Nov
(31) |
Dec
(21) |
| 2010 |
Jan
(25) |
Feb
(9) |
Mar
(7) |
Apr
(28) |
May
(27) |
Jun
(7) |
Jul
(1) |
Aug
|
Sep
(1) |
Oct
(1) |
Nov
(13) |
Dec
(2) |
| 2013 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <axl...@us...> - 2009-06-17 01:06:16
|
Revision: 344
http://hgengine.svn.sourceforge.net/hgengine/?rev=344&view=rev
Author: axlecrusher
Date: 2009-06-17 01:06:15 +0000 (Wed, 17 Jun 2009)
Log Message:
-----------
use list
Modified Paths:
--------------
Mercury2/src/Shader.cpp
Mercury2/src/Shader.h
Modified: Mercury2/src/Shader.cpp
===================================================================
--- Mercury2/src/Shader.cpp 2009-06-17 01:05:04 UTC (rev 343)
+++ Mercury2/src/Shader.cpp 2009-06-17 01:06:15 UTC (rev 344)
@@ -327,7 +327,9 @@
GLenum type;
glGetActiveUniformARB( iProgramID, i, 1024, &bufflen, &size, &type, buffer );
buffer[bufflen] = 0;
- m_uniforms[buffer] = glGetUniformLocationARB( iProgramID, buffer );
+// m_uniforms[buffer] = glGetUniformLocationARB( iProgramID, buffer );
+ int location = glGetUniformLocationARB( iProgramID, buffer );
+ m_uniforms.push_back( std::pair<MString,int> (buffer, location) );
}
return true;
}
@@ -411,7 +413,7 @@
GLERRORCHECK;
//set attributes here
- std::map< MString, int >::iterator ui = m_uniforms.begin();
+ std::list< std::pair< MString, int > >::iterator ui = m_uniforms.begin();
for (;ui != m_uniforms.end(); ++ui)
{
std::map< MString, ShaderAttribute >::iterator sai = m_globalAttributes.find( ui->first );
@@ -431,9 +433,11 @@
int32_t Shader::GetUniformLocation(const MString& n)
{
if ( !iProgramID ) return -1;
- std::map< MString, int >::iterator i = m_uniforms.find(n);
- if ( i == m_uniforms.end() ) return -1;
- return i->second;
+
+ std::list< std::pair< MString, int > >::iterator i = m_uniforms.begin();
+ for (;i != m_uniforms.end(); ++i)
+ if (i->first == n) return i->second;
+ return -1;
}
void Shader::SetAttribute(const MString& name, const ShaderAttribute& x)
Modified: Mercury2/src/Shader.h
===================================================================
--- Mercury2/src/Shader.h 2009-06-17 01:05:04 UTC (rev 343)
+++ Mercury2/src/Shader.h 2009-06-17 01:06:15 UTC (rev 344)
@@ -149,8 +149,10 @@
unsigned int fragmentShader;
///Shader attributes
- /** These are the attributes linked into the shader */
- std::map< MString, int > m_uniforms;
+ /** These are the attributes linked into the shader.
+ There are so few uniforms in a shader that a list with
+ a linear search should be faster than a tree*/
+ std::list< std::pair< MString, int > > m_uniforms;
///Name of the shader
MString sShaderName;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-06-17 01:05:05
|
Revision: 343
http://hgengine.svn.sourceforge.net/hgengine/?rev=343&view=rev
Author: axlecrusher
Date: 2009-06-17 01:05:04 +0000 (Wed, 17 Jun 2009)
Log Message:
-----------
simplify fallback
Modified Paths:
--------------
Mercury2/scenegraph.xml
Modified: Mercury2/scenegraph.xml
===================================================================
--- Mercury2/scenegraph.xml 2009-06-16 00:45:40 UTC (rev 342)
+++ Mercury2/scenegraph.xml 2009-06-17 01:05:04 UTC (rev 343)
@@ -28,12 +28,12 @@
</node>
</node>
</node>
- <node type="transformnode" movx="1" fallback="lampForest.lamprow.lamp" />
- <node type="transformnode" movx="2" fallback="lampForest.lamprow.lamp" />
- <node type="transformnode" movx="3" fallback="lampForest.lamprow.lamp" />
- <node type="transformnode" movx="-1" fallback="lampForest.lamprow.lamp" />
- <node type="transformnode" movx="-2" fallback="lampForest.lamprow.lamp" />
- <node type="transformnode" movx="-3" fallback="lampForest.lamprow.lamp" />
+ <node type="transformnode" movx="1" fallback="lamprow.lamp" />
+ <node type="transformnode" movx="2" fallback="lamprow.lamp" />
+ <node type="transformnode" movx="3" fallback="lamprow.lamp" />
+ <node type="transformnode" movx="-1" fallback="lamprow.lamp" />
+ <node type="transformnode" movx="-2" fallback="lamprow.lamp" />
+ <node type="transformnode" movx="-3" fallback="lamprow.lamp" />
</node>
<node type="transformnode" movz="-6" fallback="lampForest.lamprow"/>
<node type="transformnode" movz="-7" fallback="lampForest.lamprow"/>
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:28
|
Revision: 341
http://hgengine.svn.sourceforge.net/hgengine/?rev=341&view=rev
Author: axlecrusher
Date: 2009-06-16 00:27:10 +0000 (Tue, 16 Jun 2009)
Log Message:
-----------
use a global uniform register
Modified Paths:
--------------
Mercury2/src/RenderGraph.cpp
Mercury2/src/Shader.cpp
Mercury2/src/Shader.h
Mercury2/src/Texture.cpp
Modified: Mercury2/src/RenderGraph.cpp
===================================================================
--- Mercury2/src/RenderGraph.cpp 2009-06-15 00:08:01 UTC (rev 340)
+++ Mercury2/src/RenderGraph.cpp 2009-06-16 00:27:10 UTC (rev 341)
@@ -8,6 +8,7 @@
void RenderGraphEntry::Render()
{
MercuryMatrix modelView;
+ ShaderAttribute sa;
if (m_node)
{
@@ -17,18 +18,11 @@
modelView.Transpose();
glLoadMatrixf( modelView.Ptr() );
-
- Shader* currentShader = Shader::GetCurrentShader();
- if ( currentShader )
- {
- int location = currentShader->GetUniformLocation("HG_ModelMatrix");
- if ( location != -1 )
- {
- glUniformMatrix4fv(location, 1, 1,m_matrix->Ptr());
- GLERRORCHECK;
- }
- }
+ sa.type = ShaderAttribute::TYPE_MATRIX;
+ sa.value.matrix = m_matrix->Ptr();
+ Shader::SetAttribute("HG_ModelMatrix", sa);
+
m_node->Render( modelView ); //calls on children assets
}
@@ -40,6 +34,7 @@
if (m_node)
{
glLoadMatrixf( modelView.Ptr() );
+ Shader::SetAttribute("HG_ModelMatrix", sa);
m_node->PostRender( modelView ); //calls on children assets
}
}
Modified: Mercury2/src/Shader.cpp
===================================================================
--- Mercury2/src/Shader.cpp 2009-06-15 00:08:01 UTC (rev 340)
+++ Mercury2/src/Shader.cpp 2009-06-16 00:27:10 UTC (rev 341)
@@ -173,6 +173,7 @@
}
free( Buffer );
}
+
return LinkShaders();
}
@@ -327,6 +328,13 @@
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;
}
@@ -408,29 +416,8 @@
glUseProgramObjectARB( iProgramID );
GLERRORCHECK;
-/*
- for( unsigned i = 0; i < m_vShaderTabs.size(); ++i )
- {
- int location = glGetUniformLocationARB( iProgramID, m_vShaderTabs[i]->name.c_str() );
-
- ShaderAttribute * sa = m_vShaderTabs[i];
- if ( sa->ShaderControlled )
- {
- switch( sa->type )
- {
- case ShaderAttribute::TYPE_INT:
- case ShaderAttribute::TYPE_SAMPLER:
- glUniform1iARB( location, sa->value.iInt );
- GLERRORCHECK;
- break;
- case ShaderAttribute::TYPE_FLOAT:
- case ShaderAttribute::TYPE_FLOATV4:
- glUniform4fvARB( location, 4, &sa->value.fFloatV4[0] );
- GLERRORCHECK;
- break;
- };
- }
- }*/
+
+ //set global attributes here
}
void Shader::DeactivateShader()
@@ -447,6 +434,46 @@
return i->second;
}
+void Shader::SetAttribute(const MString& name, const ShaderAttribute& x)
+{
+ m_globalAttributes[name] = x;
+
+ Shader *current = GetCurrentShader();
+ if (current) current->SetAttributeInternal( name, x );
+}
+
+void Shader::RemoveAttribute(const MString& name)
+{
+ std::map< MString, ShaderAttribute>::iterator i = m_globalAttributes.find( name );
+ if ( i != m_globalAttributes.end() ) m_globalAttributes.erase( i );
+ //no sense in unsetting it in the current shader, what would we set it to?
+}
+
+void Shader::SetAttributeInternal(const MString& name, const ShaderAttribute& x)
+{
+ int location = GetUniformLocation( name );
+
+ if ( location != -1 )
+ {
+ switch( x.type )
+ {
+ case ShaderAttribute::TYPE_INT:
+ case ShaderAttribute::TYPE_SAMPLER:
+ glUniform1iARB( location, x.value.iInt );
+ break;
+ case ShaderAttribute::TYPE_FLOAT:
+ case ShaderAttribute::TYPE_FLOATV4:
+ glUniform4fvARB( location, 4, &x.value.fFloatV4[0] );
+ break;
+ case ShaderAttribute::TYPE_MATRIX:
+ glUniformMatrix4fv(location, 1, 1, x.value.matrix); //transpase too
+ };
+ GLERRORCHECK;
+ }
+}
+
+std::map< MString, ShaderAttribute> Shader::m_globalAttributes;
+
/*
* Copyright (c) 2009 Charles Lohr
* All rights reserved.
Modified: Mercury2/src/Shader.h
===================================================================
--- Mercury2/src/Shader.h 2009-06-15 00:08:01 UTC (rev 340)
+++ Mercury2/src/Shader.h 2009-06-16 00:27:10 UTC (rev 341)
@@ -5,11 +5,13 @@
#include <map>
#include <vector>
+#include <MercuryMatrix.h>
+
///Basic Attribute for all shaders
class ShaderAttribute
{
public:
- ShaderAttribute() : type( TYPE_INT ) { value.iInt = 0; ShaderControlled=0;}
+ ShaderAttribute() : type( TYPE_INT ) { value.iInt = 0; }
///Type of ShaderAttribute for shader
enum ShaderAttributeTyp
@@ -17,7 +19,8 @@
TYPE_INT, ///Synonomous to 'int' when passing into a shader
TYPE_SAMPLER, ///Synonomous to 'sampler2D' when passing into a shader
TYPE_FLOAT, ///Synonomous to 'float' when passing into a shader
- TYPE_FLOATV4 ///Synonomous to 'vec4' when passing into a shader
+ TYPE_FLOATV4, ///Synonomous to 'vec4' when passing into a shader
+ TYPE_MATRIX ///Synonomous to 'mat4' when passing into a shader
} type;
///Actual data for value.
@@ -27,10 +30,8 @@
unsigned int iSampler; ///Synonomous to 'sampler2D'
float fFloat; ///Synonomous to 'float'
float fFloatV4[4]; ///Synonomous to 'vec4'
+ const float* matrix; ///Synonomous to 'mat4'
} value;
-
- MString name;
- bool ShaderControlled;
};
///Shader Attribute Retainer
@@ -71,7 +72,9 @@
virtual void PostRender(const MercuryNode* node);
static Shader* Generate() { return new Shader; }
virtual void LoadFromXML(const XMLNode& node);
- int32_t GetUniformLocation(const MString& n);
+
+ static void SetAttribute(const MString& name, const ShaderAttribute& x);
+ static void RemoveAttribute(const MString& name);
///Explicitly get the OpenGL ProgramID in the event you need it for advanced techniques
unsigned int GetProgramID() { return iProgramID; }
@@ -79,6 +82,10 @@
private:
void LoadShader( const MString& path, float priority );
+ int32_t GetUniformLocation(const MString& n);
+
+ void SetAttributeInternal(const MString& name, const ShaderAttribute& x);
+
///Suggested function for loading shaders.
/** This function looks for {sShaderName}.vert and {sShaderName}.frag. It will
attempt to load, compile and link the files. If any errors are found, they will
@@ -142,11 +149,7 @@
unsigned int fragmentShader;
///Shader attributes
- /** This is the system that helps make it possible to blast
- through all attributes currently set up by dereferencing
- the pointers in the attributes repository.
- */
-// std::vector< ShaderAttribute * > m_vShaderTabs;
+ /** These are the attributes linked into the shader */
std::map< MString, int > m_uniforms;
///Name of the shader
@@ -160,6 +163,9 @@
///Original Shader (to re-enable when leaving)
Shader * OriginalShader;
+
+ //global uniform that should be applied to all shaders
+ static std::map< MString, ShaderAttribute > m_globalAttributes;
};
#endif
Modified: Mercury2/src/Texture.cpp
===================================================================
--- Mercury2/src/Texture.cpp 2009-06-15 00:08:01 UTC (rev 340)
+++ Mercury2/src/Texture.cpp 2009-06-16 00:27:10 UTC (rev 341)
@@ -132,17 +132,10 @@
GLERRORCHECK;
- Shader* currentShader = Shader::GetCurrentShader();
- if ( currentShader )
- {
- MString uname = ssprintf("HG_Texture%d", m_activeTextures);
- int location = currentShader->GetUniformLocation( uname );
- if ( location != -1 )
- {
- glUniform1i(location,m_activeTextures);
- GLERRORCHECK;
- }
- }
+ ShaderAttribute sa;
+ sa.type = ShaderAttribute::TYPE_SAMPLER;
+ sa.value.iSampler = m_textureResource;
+ Shader::SetAttribute( ssprintf("HG_Texture%d", m_activeTextures), sa);
++m_activeTextures;
++m_textureBinds;
@@ -155,6 +148,9 @@
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisable( GL_TEXTURE_2D );
GLERRORCHECK;
+
+ Shader::RemoveAttribute( ssprintf("HG_Texture%d", m_activeTextures) );
+
--m_activeTextures;
}
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: <axl...@us...> - 2009-06-15 00:08:47
|
Revision: 340
http://hgengine.svn.sourceforge.net/hgengine/?rev=340&view=rev
Author: axlecrusher
Date: 2009-06-15 00:08:01 +0000 (Mon, 15 Jun 2009)
Log Message:
-----------
correct texture binding
Modified Paths:
--------------
Mercury2/testShader.frag
Modified: Mercury2/testShader.frag
===================================================================
--- Mercury2/testShader.frag 2009-06-14 23:47:59 UTC (rev 339)
+++ Mercury2/testShader.frag 2009-06-15 00:08:01 UTC (rev 340)
@@ -1,8 +1,8 @@
-uniform sampler2D tex1;
+uniform sampler2D HG_Texture0;
varying vec3 normal;
void main()
{
-// gl_FragData[0] = texture2D(tex1, gl_TexCoord[0].st);
+// gl_FragData[0] = texture2D(HG_Texture0, gl_TexCoord[0].st);
gl_FragData[0].rgb = (normalize(normal)+1.0)/2.0;
}
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-14 23:41:09
|
Revision: 338
http://hgengine.svn.sourceforge.net/hgengine/?rev=338&view=rev
Author: axlecrusher
Date: 2009-06-14 23:39:48 +0000 (Sun, 14 Jun 2009)
Log Message:
-----------
bind textures for shaders
Modified Paths:
--------------
Mercury2/src/Texture.cpp
Modified: Mercury2/src/Texture.cpp
===================================================================
--- Mercury2/src/Texture.cpp 2009-06-14 21:53:47 UTC (rev 337)
+++ Mercury2/src/Texture.cpp 2009-06-14 23:39:48 UTC (rev 338)
@@ -3,6 +3,8 @@
#include <ImageLoader.h>
#include <GLHeaders.h>
+#include <Shader.h>
+
using namespace std;
REGISTER_ASSET_TYPE(Texture);
@@ -127,6 +129,21 @@
glEnable( GL_TEXTURE_2D );
glBindTexture(GL_TEXTURE_2D, m_textureID);
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
+
+ GLERRORCHECK;
+
+ Shader* currentShader = Shader::GetCurrentShader();
+ if ( currentShader )
+ {
+ MString uname = ssprintf("HG_Texture%d", m_activeTextures);
+ int location = currentShader->GetUniformLocation( uname );
+ if ( location != -1 )
+ {
+ glUniform1i(location,m_activeTextures);
+ GLERRORCHECK;
+ }
+ }
+
++m_activeTextures;
++m_textureBinds;
}
@@ -137,6 +154,7 @@
glClientActiveTextureARB(m_textureResource);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisable( GL_TEXTURE_2D );
+ GLERRORCHECK;
--m_activeTextures;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-06-14 21:53:51
|
Revision: 337
http://hgengine.svn.sourceforge.net/hgengine/?rev=337&view=rev
Author: axlecrusher
Date: 2009-06-14 21:53:47 +0000 (Sun, 14 Jun 2009)
Log Message:
-----------
fix UV mapping so FBO works straight out of the buffer
Modified Paths:
--------------
Mercury2/src/FullscreenQuad.cpp
Mercury2/src/Quad.cpp
Modified: Mercury2/src/FullscreenQuad.cpp
===================================================================
--- Mercury2/src/FullscreenQuad.cpp 2009-06-14 20:32:37 UTC (rev 336)
+++ Mercury2/src/FullscreenQuad.cpp 2009-06-14 21:53:47 UTC (rev 337)
@@ -12,12 +12,6 @@
void FullscreenQuad::Render(const MercuryNode* node)
{
- //reverse texture mapping for
- glMatrixMode(GL_TEXTURE);
- glPushMatrix();
- glLoadIdentity();
- glRotatef(180,1,0,0);
-
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadMatrixf( m_matrix.Ptr() );
@@ -29,7 +23,6 @@
Quad::Render( node );
glPopMatrix();
- glMatrixMode(GL_TEXTURE); glPopMatrix();
glMatrixMode(GL_MODELVIEW); glPopMatrix();
}
Modified: Mercury2/src/Quad.cpp
===================================================================
--- Mercury2/src/Quad.cpp 2009-06-14 20:32:37 UTC (rev 336)
+++ Mercury2/src/Quad.cpp 2009-06-14 21:53:47 UTC (rev 337)
@@ -14,19 +14,21 @@
// float* buffer = m_vertexData.m_vertexData();
int i = 0;
- m_vertexData[i++] = 0; m_vertexData[i++] = 1;
+ //UV oriented so 0,0 is lower left and 1,0 upper right.
+ //this makes it so FBO images render correctly right out of the buffer, no flip needed
+ m_vertexData[i++] = 0; m_vertexData[i++] = 0;
m_vertexData[i++] = 0; m_vertexData[i++] = 0; m_vertexData[i++] = -1.0;
m_vertexData[i++] = -0.5; m_vertexData[i++] = -0.5; m_vertexData[i++] = 0.0;
- m_vertexData[i++] = 1; m_vertexData[i++] = 1;
+ m_vertexData[i++] = 1; m_vertexData[i++] = 0;
m_vertexData[i++] = 0; m_vertexData[i++] = 0; m_vertexData[i++] = -1.0;
m_vertexData[i++] = 0.5; m_vertexData[i++] = -0.5; m_vertexData[i++] = 0.0;
- m_vertexData[i++] = 1; m_vertexData[i++] = 0;
+ m_vertexData[i++] = 1; m_vertexData[i++] = 1;
m_vertexData[i++] = 0; m_vertexData[i++] = 0; m_vertexData[i++] = -1.0;
m_vertexData[i++] = 0.5; m_vertexData[i++] = 0.5; m_vertexData[i++] = 0.0;
- m_vertexData[i++] = 0; m_vertexData[i++] = 0;
+ m_vertexData[i++] = 0; m_vertexData[i++] = 1;
m_vertexData[i++] = 0; m_vertexData[i++] = 0; m_vertexData[i++] = -1.0;
m_vertexData[i++] = -0.5; m_vertexData[i++] = 0.5; m_vertexData[i++] = 0.0;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-06-14 20:34:22
|
Revision: 336
http://hgengine.svn.sourceforge.net/hgengine/?rev=336&view=rev
Author: axlecrusher
Date: 2009-06-14 20:32:37 +0000 (Sun, 14 Jun 2009)
Log Message:
-----------
don't lose negative information
Modified Paths:
--------------
Mercury2/testShader.frag
Modified: Mercury2/testShader.frag
===================================================================
--- Mercury2/testShader.frag 2009-06-14 20:16:34 UTC (rev 335)
+++ Mercury2/testShader.frag 2009-06-14 20:32:37 UTC (rev 336)
@@ -4,5 +4,5 @@
void main()
{
// gl_FragData[0] = texture2D(tex1, gl_TexCoord[0].st);
- gl_FragData[0].rgb = normalize(normal);
+ gl_FragData[0].rgb = (normalize(normal)+1.0)/2.0;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-06-14 20:16:56
|
Revision: 335
http://hgengine.svn.sourceforge.net/hgengine/?rev=335&view=rev
Author: axlecrusher
Date: 2009-06-14 20:16:34 +0000 (Sun, 14 Jun 2009)
Log Message:
-----------
faster get uniform
Modified Paths:
--------------
Mercury2/src/Shader.cpp
Mercury2/src/Shader.h
Modified: Mercury2/src/Shader.cpp
===================================================================
--- Mercury2/src/Shader.cpp 2009-06-14 19:46:39 UTC (rev 334)
+++ Mercury2/src/Shader.cpp 2009-06-14 20:16:34 UTC (rev 335)
@@ -314,9 +314,9 @@
}
//Build the list of uniform tabs.
-/* int iNumUniforms;
+ int iNumUniforms;
glGetObjectParameterivARB( iProgramID, GL_OBJECT_ACTIVE_UNIFORMS_ARB, &iNumUniforms );
- m_vShaderTabs.resize( iNumUniforms );
+ m_uniforms.clear();
for( int i = 0; i < iNumUniforms; ++i )
{
char buffer[1024];
@@ -325,10 +325,9 @@
GLenum type;
glGetActiveUniformARB( iProgramID, i, 1024, &bufflen, &size, &type, buffer );
buffer[bufflen] = 0;
- m_vShaderTabs[i] = SHADERATTRIBUTES.GetHandle( buffer );
- m_vShaderTabs[i]->name = buffer;
+ m_uniforms[buffer] = glGetUniformLocationARB( iProgramID, buffer );
}
-*/ return true;
+ return true;
}
void Shader::DestroyShader()
@@ -442,8 +441,9 @@
int32_t Shader::GetUniformLocation(const MString& n)
{
if ( !iProgramID ) return -1;
- return glGetUniformLocationARB( iProgramID, n.c_str() );
-
+ std::map< MString, int >::iterator i = m_uniforms.find(n);
+ if ( i == m_uniforms.end() ) return -1;
+ return i->second;
}
/*
Modified: Mercury2/src/Shader.h
===================================================================
--- Mercury2/src/Shader.h 2009-06-14 19:46:39 UTC (rev 334)
+++ Mercury2/src/Shader.h 2009-06-14 20:16:34 UTC (rev 335)
@@ -147,6 +147,7 @@
the pointers in the attributes repository.
*/
// std::vector< ShaderAttribute * > m_vShaderTabs;
+ std::map< MString, int > m_uniforms;
///Name of the shader
MString sShaderName;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-06-14 19:46:41
|
Revision: 334
http://hgengine.svn.sourceforge.net/hgengine/?rev=334&view=rev
Author: axlecrusher
Date: 2009-06-14 19:46:39 +0000 (Sun, 14 Jun 2009)
Log Message:
-----------
use lamp with normals
Modified Paths:
--------------
Mercury2/scenegraph.xml
Added Paths:
-----------
Mercury2/lampN.hgmdl
Added: Mercury2/lampN.hgmdl
===================================================================
(Binary files differ)
Property changes on: Mercury2/lampN.hgmdl
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: Mercury2/scenegraph.xml
===================================================================
--- Mercury2/scenegraph.xml 2009-06-14 19:38:07 UTC (rev 333)
+++ Mercury2/scenegraph.xml 2009-06-14 19:46:39 UTC (rev 334)
@@ -24,7 +24,7 @@
<node type="transformnode" rotx="-90" name="lamp">
<node type="billboardnode" billboardaxis="0,0,1" spheremode="true" >
<node type="renderablenode">
- <asset type="hgmdlmodel" file="lamp.hgmdl" />
+ <asset type="hgmdlmodel" file="lampN.hgmdl" />
</node>
</node>
</node>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-06-14 19:38:08
|
Revision: 333
http://hgengine.svn.sourceforge.net/hgengine/?rev=333&view=rev
Author: axlecrusher
Date: 2009-06-14 19:38:07 +0000 (Sun, 14 Jun 2009)
Log Message:
-----------
render worldspace normal
Added Paths:
-----------
Mercury2/testShader.frag
Mercury2/testShader.vert
Added: Mercury2/testShader.frag
===================================================================
--- Mercury2/testShader.frag (rev 0)
+++ Mercury2/testShader.frag 2009-06-14 19:38:07 UTC (rev 333)
@@ -0,0 +1,8 @@
+uniform sampler2D tex1;
+varying vec3 normal;
+
+void main()
+{
+// gl_FragData[0] = texture2D(tex1, gl_TexCoord[0].st);
+ gl_FragData[0].rgb = normalize(normal);
+}
Added: Mercury2/testShader.vert
===================================================================
--- Mercury2/testShader.vert (rev 0)
+++ Mercury2/testShader.vert 2009-06-14 19:38:07 UTC (rev 333)
@@ -0,0 +1,13 @@
+varying vec3 normal;
+uniform mat4 HG_ModelMatrix;
+
+void main()
+{
+ gl_TexCoord[0] = gl_MultiTexCoord0;
+ gl_Position = ftransform();
+
+ vec4 n = vec4(gl_Normal, 0);
+
+ //normalize in fragment
+ normal = (HG_ModelMatrix * n).xyz;
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-06-14 19:31:10
|
Revision: 332
http://hgengine.svn.sourceforge.net/hgengine/?rev=332&view=rev
Author: axlecrusher
Date: 2009-06-14 19:31:09 +0000 (Sun, 14 Jun 2009)
Log Message:
-----------
shader work
Modified Paths:
--------------
Mercury2/src/Shader.cpp
Mercury2/src/Shader.h
Modified: Mercury2/src/Shader.cpp
===================================================================
--- Mercury2/src/Shader.cpp 2009-06-14 19:21:19 UTC (rev 331)
+++ Mercury2/src/Shader.cpp 2009-06-14 19:31:09 UTC (rev 332)
@@ -72,8 +72,8 @@
void Shader::PostRender(const MercuryNode* node)
{
CurrentShader = OriginalShader;
- if( OriginalShader )
- OriginalShader->ActivateShader();
+ if( CurrentShader )
+ CurrentShader->ActivateShader();
else
DeactivateShader();
}
@@ -314,7 +314,7 @@
}
//Build the list of uniform tabs.
- int iNumUniforms;
+/* int iNumUniforms;
glGetObjectParameterivARB( iProgramID, GL_OBJECT_ACTIVE_UNIFORMS_ARB, &iNumUniforms );
m_vShaderTabs.resize( iNumUniforms );
for( int i = 0; i < iNumUniforms; ++i )
@@ -328,7 +328,7 @@
m_vShaderTabs[i] = SHADERATTRIBUTES.GetHandle( buffer );
m_vShaderTabs[i]->name = buffer;
}
- return true;
+*/ return true;
}
void Shader::DestroyShader()
@@ -404,30 +404,33 @@
void Shader::ActivateShader()
{
- if (iProgramID == 0) return;
+ if ( !iProgramID ) return;
glUseProgramObjectARB( iProgramID );
GLERRORCHECK;
-
+/*
for( unsigned i = 0; i < m_vShaderTabs.size(); ++i )
{
int location = glGetUniformLocationARB( iProgramID, m_vShaderTabs[i]->name.c_str() );
-
+
ShaderAttribute * sa = m_vShaderTabs[i];
- switch( sa->type )
+ if ( sa->ShaderControlled )
{
- case ShaderAttribute::TYPE_INT:
- case ShaderAttribute::TYPE_SAMPLER:
- glUniform1iARB( location, sa->value.iInt );
- GLERRORCHECK;
- break;
- case ShaderAttribute::TYPE_FLOAT:
- case ShaderAttribute::TYPE_FLOATV4:
- glUniform4fvARB( location, 4, &sa->value.fFloatV4[0] );
- GLERRORCHECK;
- break;
- };
- }
+ switch( sa->type )
+ {
+ case ShaderAttribute::TYPE_INT:
+ case ShaderAttribute::TYPE_SAMPLER:
+ glUniform1iARB( location, sa->value.iInt );
+ GLERRORCHECK;
+ break;
+ case ShaderAttribute::TYPE_FLOAT:
+ case ShaderAttribute::TYPE_FLOATV4:
+ glUniform4fvARB( location, 4, &sa->value.fFloatV4[0] );
+ GLERRORCHECK;
+ break;
+ };
+ }
+ }*/
}
void Shader::DeactivateShader()
@@ -436,7 +439,13 @@
GLERRORCHECK;
}
+int32_t Shader::GetUniformLocation(const MString& n)
+{
+ if ( !iProgramID ) return -1;
+ return glGetUniformLocationARB( iProgramID, n.c_str() );
+}
+
/*
* Copyright (c) 2009 Charles Lohr
* All rights reserved.
Modified: Mercury2/src/Shader.h
===================================================================
--- Mercury2/src/Shader.h 2009-06-14 19:21:19 UTC (rev 331)
+++ Mercury2/src/Shader.h 2009-06-14 19:31:09 UTC (rev 332)
@@ -9,7 +9,7 @@
class ShaderAttribute
{
public:
- ShaderAttribute() : type( TYPE_INT ) { value.iInt = 0; }
+ ShaderAttribute() : type( TYPE_INT ) { value.iInt = 0; ShaderControlled=0;}
///Type of ShaderAttribute for shader
enum ShaderAttributeTyp
@@ -30,6 +30,7 @@
} value;
MString name;
+ bool ShaderControlled;
};
///Shader Attribute Retainer
@@ -70,9 +71,11 @@
virtual void PostRender(const MercuryNode* node);
static Shader* Generate() { return new Shader; }
virtual void LoadFromXML(const XMLNode& node);
+ int32_t GetUniformLocation(const MString& n);
///Explicitly get the OpenGL ProgramID in the event you need it for advanced techniques
unsigned int GetProgramID() { return iProgramID; }
+ inline static Shader* GetCurrentShader() { return CurrentShader; }
private:
void LoadShader( const MString& path, float priority );
@@ -143,7 +146,7 @@
through all attributes currently set up by dereferencing
the pointers in the attributes repository.
*/
- std::vector< ShaderAttribute * > m_vShaderTabs;
+// std::vector< ShaderAttribute * > m_vShaderTabs;
///Name of the shader
MString sShaderName;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-06-14 19:21:20
|
Revision: 331
http://hgengine.svn.sourceforge.net/hgengine/?rev=331&view=rev
Author: axlecrusher
Date: 2009-06-14 19:21:19 +0000 (Sun, 14 Jun 2009)
Log Message:
-----------
upload model matrix
Modified Paths:
--------------
Mercury2/src/RenderGraph.cpp
Modified: Mercury2/src/RenderGraph.cpp
===================================================================
--- Mercury2/src/RenderGraph.cpp 2009-06-14 16:25:45 UTC (rev 330)
+++ Mercury2/src/RenderGraph.cpp 2009-06-14 19:21:19 UTC (rev 331)
@@ -3,18 +3,33 @@
#include <GLHeaders.h>
+#include <Shader.h>
+
void RenderGraphEntry::Render()
{
- MercuryMatrix m;
+ MercuryMatrix modelView;
if (m_node)
{
m_node->PreRender( *m_matrix ); //calls on children assets
- m = m_node->ManipulateMatrix( *m_matrix );
- if ( m_node->IsHidden() || m_node->IsCulled(m) ) return;
- m.Transpose();
- glLoadMatrixf( m.Ptr() );
- m_node->Render( m ); //calls on children assets
+ modelView = m_node->ManipulateMatrix( *m_matrix );
+ if ( m_node->IsHidden() || m_node->IsCulled(modelView) ) return;
+ modelView.Transpose();
+
+ glLoadMatrixf( modelView.Ptr() );
+
+ Shader* currentShader = Shader::GetCurrentShader();
+ if ( currentShader )
+ {
+ int location = currentShader->GetUniformLocation("HG_ModelMatrix");
+ if ( location != -1 )
+ {
+ glUniformMatrix4fv(location, 1, 1,m_matrix->Ptr());
+ GLERRORCHECK;
+ }
+ }
+
+ m_node->Render( modelView ); //calls on children assets
}
//call render on other render graph entries under me
@@ -24,8 +39,8 @@
if (m_node)
{
- glLoadMatrixf( m.Ptr() );
- m_node->PostRender( m ); //calls on children assets
+ glLoadMatrixf( modelView.Ptr() );
+ m_node->PostRender( modelView ); //calls on children assets
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-06-14 17:35:22
|
Revision: 329
http://hgengine.svn.sourceforge.net/hgengine/?rev=329&view=rev
Author: axlecrusher
Date: 2009-06-14 16:20:38 +0000 (Sun, 14 Jun 2009)
Log Message:
-----------
normals
Modified Paths:
--------------
Mercury2/src/MercuryVBO.cpp
Modified: Mercury2/src/MercuryVBO.cpp
===================================================================
--- Mercury2/src/MercuryVBO.cpp 2009-06-14 15:25:23 UTC (rev 328)
+++ Mercury2/src/MercuryVBO.cpp 2009-06-14 16:20:38 UTC (rev 329)
@@ -50,6 +50,8 @@
glClientActiveTextureARB(GL_TEXTURE0+i);
glTexCoordPointer(2, GL_FLOAT, stride, BUFFER_OFFSET(sizeof(float)*0));
}
+
+ glNormalPointer(GL_FLOAT, stride, BUFFER_OFFSET(sizeof(float)*2));
glDrawRangeElements(GL_TRIANGLES, 0, m_indexData.Length()-1, m_indexData.Length(), GL_UNSIGNED_SHORT, NULL);
m_vboBatches++;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-06-14 16:25:51
|
Revision: 330
http://hgengine.svn.sourceforge.net/hgengine/?rev=330&view=rev
Author: axlecrusher
Date: 2009-06-14 16:25:45 +0000 (Sun, 14 Jun 2009)
Log Message:
-----------
normal
Modified Paths:
--------------
Mercury2/src/MercuryVBO.cpp
Modified: Mercury2/src/MercuryVBO.cpp
===================================================================
--- Mercury2/src/MercuryVBO.cpp 2009-06-14 16:20:38 UTC (rev 329)
+++ Mercury2/src/MercuryVBO.cpp 2009-06-14 16:25:45 UTC (rev 330)
@@ -51,6 +51,7 @@
glTexCoordPointer(2, GL_FLOAT, stride, BUFFER_OFFSET(sizeof(float)*0));
}
+ glEnableClientState( GL_NORMAL_ARRAY );
glNormalPointer(GL_FLOAT, stride, BUFFER_OFFSET(sizeof(float)*2));
glDrawRangeElements(GL_TRIANGLES, 0, m_indexData.Length()-1, m_indexData.Length(), GL_UNSIGNED_SHORT, NULL);
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:26:53
|
Revision: 328
http://hgengine.svn.sourceforge.net/hgengine/?rev=328&view=rev
Author: axlecrusher
Date: 2009-06-14 15:25:23 +0000 (Sun, 14 Jun 2009)
Log Message:
-----------
some updates
Modified Paths:
--------------
Mercury2/scenegraph.xml
Mercury2/src/X11Window.cpp
Modified: Mercury2/scenegraph.xml
===================================================================
--- Mercury2/scenegraph.xml 2009-06-14 15:21:35 UTC (rev 327)
+++ Mercury2/scenegraph.xml 2009-06-14 15:25:23 UTC (rev 328)
@@ -10,7 +10,7 @@
<asset type="texture" file="screenFBO_0" dynamic="true"/>
<asset type="fullscreenquad"/>
</node>
- <node type="mercuryfbo" width="640" height="480" depth="true" tnum="1" name="screenFBO" usescreensize="true">
+ <node type="mercuryfbo" width="640" height="480" depth="true" tnum="2" name="screenFBO" usescreensize="true">
<asset type="shader" file="testShader"/>
<node type="transformnode" rotx="-90" movz="-10" movx="0" movy="-5">
<node type="renderablenode">
Modified: Mercury2/src/X11Window.cpp
===================================================================
--- Mercury2/src/X11Window.cpp 2009-06-14 15:21:35 UTC (rev 327)
+++ Mercury2/src/X11Window.cpp 2009-06-14 15:25:23 UTC (rev 328)
@@ -76,6 +76,7 @@
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
+ glEnable(GL_NORMALIZE);
}
X11Window::~X11Window()
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 15:14:36
|
Revision: 326
http://hgengine.svn.sourceforge.net/hgengine/?rev=326&view=rev
Author: axlecrusher
Date: 2009-06-14 13:55:32 +0000 (Sun, 14 Jun 2009)
Log Message:
-----------
fix shader uniforms
Modified Paths:
--------------
Mercury2/src/Shader.cpp
Mercury2/src/Shader.h
Modified: Mercury2/src/Shader.cpp
===================================================================
--- Mercury2/src/Shader.cpp 2009-06-14 13:08:31 UTC (rev 325)
+++ Mercury2/src/Shader.cpp 2009-06-14 13:55:32 UTC (rev 326)
@@ -327,6 +327,7 @@
glGetActiveUniformARB( iProgramID, i, 1024, &bufflen, &size, &type, buffer );
buffer[bufflen] = 0;
m_vShaderTabs[i] = SHADERATTRIBUTES.GetHandle( buffer );
+ m_vShaderTabs[i]->name = buffer;
}
return true;
}
@@ -407,17 +408,19 @@
for( unsigned i = 0; i < m_vShaderTabs.size(); ++i )
{
+ int location = glGetUniformLocationARB( iProgramID, m_vShaderTabs[i]->name.c_str() );
+
ShaderAttribute * sa = m_vShaderTabs[i];
- switch( sa->typ )
+ switch( sa->type )
{
case ShaderAttribute::TYPE_INT:
case ShaderAttribute::TYPE_SAMPLER:
- glUniform1iARB( i, sa->sau.iInt );
+ glUniform1iARB( location, sa->value.iInt );
GLERRORCHECK;
break;
case ShaderAttribute::TYPE_FLOAT:
case ShaderAttribute::TYPE_FLOATV4:
- glUniform4fvARB( i, 4, &sa->sau.fFloatV4[0] );
+ glUniform4fvARB( location, 4, &sa->value.fFloatV4[0] );
GLERRORCHECK;
break;
};
Modified: Mercury2/src/Shader.h
===================================================================
--- Mercury2/src/Shader.h 2009-06-14 13:08:31 UTC (rev 325)
+++ Mercury2/src/Shader.h 2009-06-14 13:55:32 UTC (rev 326)
@@ -9,7 +9,7 @@
class ShaderAttribute
{
public:
- ShaderAttribute() : typ( TYPE_INT ) { sau.iInt = 0; }
+ ShaderAttribute() : type( TYPE_INT ) { value.iInt = 0; }
///Type of ShaderAttribute for shader
enum ShaderAttributeTyp
@@ -18,7 +18,7 @@
TYPE_SAMPLER, ///Synonomous to 'sampler2D' when passing into a shader
TYPE_FLOAT, ///Synonomous to 'float' when passing into a shader
TYPE_FLOATV4 ///Synonomous to 'vec4' when passing into a shader
- } typ;
+ } type;
///Actual data for value.
union ShaderAttributeVal
@@ -27,7 +27,9 @@
unsigned int iSampler; ///Synonomous to 'sampler2D'
float fFloat; ///Synonomous to 'float'
float fFloatV4[4]; ///Synonomous to 'vec4'
- } sau;
+ } value;
+
+ MString name;
};
///Shader Attribute Retainer
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:22:13
|
Revision: 321
http://hgengine.svn.sourceforge.net/hgengine/?rev=321&view=rev
Author: axlecrusher
Date: 2009-06-14 12:12:29 +0000 (Sun, 14 Jun 2009)
Log Message:
-----------
should be auto ptr
Modified Paths:
--------------
Mercury2/src/MercuryFBO.h
Modified: Mercury2/src/MercuryFBO.h
===================================================================
--- Mercury2/src/MercuryFBO.h 2009-06-14 03:34:30 UTC (rev 320)
+++ Mercury2/src/MercuryFBO.h 2009-06-14 12:12:29 UTC (rev 321)
@@ -35,7 +35,7 @@
bool m_initiated, m_useDepth, m_useScreenSize;
uint16_t m_width, m_height;
// uint32_t m_textureID[4];
- Texture *m_textures[4];
+ MAutoPtr< Texture > m_textures[4];
uint8_t m_numTextures;
static uint32_t m_lastRendered;
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:08:32
|
Revision: 325
http://hgengine.svn.sourceforge.net/hgengine/?rev=325&view=rev
Author: axlecrusher
Date: 2009-06-14 13:08:31 +0000 (Sun, 14 Jun 2009)
Log Message:
-----------
use test shader
Modified Paths:
--------------
Mercury2/scenegraph.xml
Modified: Mercury2/scenegraph.xml
===================================================================
--- Mercury2/scenegraph.xml 2009-06-14 13:08:10 UTC (rev 324)
+++ Mercury2/scenegraph.xml 2009-06-14 13:08:31 UTC (rev 325)
@@ -11,6 +11,7 @@
<asset type="fullscreenquad"/>
</node>
<node type="mercuryfbo" width="640" height="480" depth="true" tnum="1" name="screenFBO" usescreensize="true">
+ <asset type="shader" file="testShader"/>
<node type="transformnode" rotx="-90" movz="-10" movx="0" movy="-5">
<node type="renderablenode">
<asset type="texture" file="map.png"/>
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:08:11
|
Revision: 324
http://hgengine.svn.sourceforge.net/hgengine/?rev=324&view=rev
Author: axlecrusher
Date: 2009-06-14 13:08:10 +0000 (Sun, 14 Jun 2009)
Log Message:
-----------
remove debugging
Modified Paths:
--------------
Mercury2/src/Texture.cpp
Modified: Mercury2/src/Texture.cpp
===================================================================
--- Mercury2/src/Texture.cpp 2009-06-14 13:07:39 UTC (rev 323)
+++ Mercury2/src/Texture.cpp 2009-06-14 13:08:10 UTC (rev 324)
@@ -175,7 +175,6 @@
m_path = "DYNATEXT"+name;
ADD_ASSET_INSTANCE(Texture, m_path, this);
- if (m_textureID == 0) printf("booo %d\n", m_textureID);
if (m_textureID == 0) glGenTextures( 1, &m_textureID );
glBindTexture( GL_TEXTURE_2D, m_textureID );
glCopyTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, width, height, 0 );
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:07:40
|
Revision: 323
http://hgengine.svn.sourceforge.net/hgengine/?rev=323&view=rev
Author: axlecrusher
Date: 2009-06-14 13:07:39 +0000 (Sun, 14 Jun 2009)
Log Message:
-----------
udpates
Modified Paths:
--------------
Mercury2/src/MercuryFBO.cpp
Mercury2/src/MercuryFBO.h
Modified: Mercury2/src/MercuryFBO.cpp
===================================================================
--- Mercury2/src/MercuryFBO.cpp 2009-06-14 13:05:36 UTC (rev 322)
+++ Mercury2/src/MercuryFBO.cpp 2009-06-14 13:07:39 UTC (rev 323)
@@ -61,7 +61,6 @@
for (uint8_t i = 0; i < m_numTextures; ++i)
glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT + i, GL_TEXTURE_2D, m_textures[i]->TextureID(), 0 );
-
if( m_useDepth )
glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_depthBufferID );
}
@@ -92,29 +91,27 @@
MString n = ssprintf("%s_%d", m_name.c_str(), i);
m_textures[i]->MakeDynamic(m_width, m_height,n);
}
- Bind();
}
+ Bind();
+ CHECKFBO; //Incomplete FBO
+ GLERRORCHECK;
}
- GLERRORCHECK;
RenderableNode::PreRender(matrix);
}
void MercuryFBO::Render(const MercuryMatrix& matrix)
{
- if (m_lastRendered != m_fboID)
- {
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fboID);
-// CHECKFBO; //Incomplete FBO
- GLERRORCHECK;
- m_lastRendered = m_fboID;
-// m_lastInStask = m_lastRendered;
- }
-
- GLERRORCHECK;
+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fboID);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
GLERRORCHECK;
+ const GLenum buffers[8] = { GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_COLOR_ATTACHMENT2_EXT,
+ GL_COLOR_ATTACHMENT3_EXT, GL_COLOR_ATTACHMENT4_EXT, GL_COLOR_ATTACHMENT5_EXT,
+ GL_COLOR_ATTACHMENT6_EXT, GL_COLOR_ATTACHMENT7_EXT };
+
+ glDrawBuffersARB( m_numTextures, buffers );
+
glPushAttrib(GL_VIEWPORT_BIT);
if ( !m_useScreenSize ) glViewport(0,0,m_width, m_height);
@@ -126,21 +123,23 @@
void MercuryFBO::PostRender(const MercuryMatrix& matrix)
{
- GLERRORCHECK;
glPopAttrib();
-
-// glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_lastInStask);
-// m_lastRendered = m_lastInStask;
RenderableNode::PostRender(matrix);
- GLERRORCHECK;
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); //unbind
+// for( uint8_t i = 0; i < m_numTextures; i++ )
+// {
+// glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT + i, GL_TEXTURE_2D, 0, 0 );
+// glActiveTextureARB( GL_TEXTURE0_ARB + i );
+// glDisable( GL_TEXTURE_2D );
+// }
+ glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 );
+// glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, 0 );
CHECKFBO;
GLERRORCHECK;
- m_lastRendered = 0;
+// m_lastRendered = 0;
}
void MercuryFBO::LoadFromXML(const XMLNode& node)
@@ -163,7 +162,7 @@
RenderableNode::LoadFromXML(node);
}
-uint32_t MercuryFBO::m_lastRendered = NULL;
+//uint32_t MercuryFBO::m_lastRendered = NULL;
/****************************************************************************
* Copyright (C) 2009 by Joshua Allen *
Modified: Mercury2/src/MercuryFBO.h
===================================================================
--- Mercury2/src/MercuryFBO.h 2009-06-14 13:05:36 UTC (rev 322)
+++ Mercury2/src/MercuryFBO.h 2009-06-14 13:07:39 UTC (rev 323)
@@ -38,7 +38,7 @@
MAutoPtr< Texture > m_textures[4];
uint8_t m_numTextures;
- static uint32_t m_lastRendered;
+// static uint32_t m_lastRendered;
// uint32_t m_lastInStask;
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 03:34:32
|
Revision: 320
http://hgengine.svn.sourceforge.net/hgengine/?rev=320&view=rev
Author: axlecrusher
Date: 2009-06-14 03:34:30 +0000 (Sun, 14 Jun 2009)
Log Message:
-----------
handle screen resize a little better
Modified Paths:
--------------
Mercury2/scenegraph.xml
Mercury2/src/MercuryAsset.h
Mercury2/src/MercuryFBO.cpp
Mercury2/src/MercuryFBO.h
Mercury2/src/Texture.cpp
Modified: Mercury2/scenegraph.xml
===================================================================
--- Mercury2/scenegraph.xml 2009-06-14 02:03:25 UTC (rev 319)
+++ Mercury2/scenegraph.xml 2009-06-14 03:34:30 UTC (rev 320)
@@ -7,10 +7,10 @@
<node type="viewport" fov="45" aspect="1.3333" near="0.01" far="100"/>
</node>
<node type="renderablenode">
- <asset type="texture" file="screenFBO" dynamic="true"/>
+ <asset type="texture" file="screenFBO_0" dynamic="true"/>
<asset type="fullscreenquad"/>
</node>
- <node type="mercuryfbo" width="640" height="480" depth="true" tnum="1" name="screenFBO">
+ <node type="mercuryfbo" width="640" height="480" depth="true" tnum="1" name="screenFBO" usescreensize="true">
<node type="transformnode" rotx="-90" movz="-10" movx="0" movy="-5">
<node type="renderablenode">
<asset type="texture" file="map.png"/>
Modified: Mercury2/src/MercuryAsset.h
===================================================================
--- Mercury2/src/MercuryAsset.h 2009-06-14 02:03:25 UTC (rev 319)
+++ Mercury2/src/MercuryAsset.h 2009-06-14 03:34:30 UTC (rev 320)
@@ -40,7 +40,7 @@
inline const BoundingVolume* GetBoundingVolume() const { return m_boundingVolume; }
inline const MString& Path() const { return m_path; }
-
+
void DrawAxes();
protected:
void SetLoadState(LoadState ls); //thread safe
Modified: Mercury2/src/MercuryFBO.cpp
===================================================================
--- Mercury2/src/MercuryFBO.cpp 2009-06-14 02:03:25 UTC (rev 319)
+++ Mercury2/src/MercuryFBO.cpp 2009-06-14 03:34:30 UTC (rev 320)
@@ -1,10 +1,11 @@
#include <MercuryFBO.h>
#include <GLHeaders.h>
+#include <MercuryWindow.h>
REGISTER_NODE_TYPE(MercuryFBO);
MercuryFBO::MercuryFBO()
- :m_fboID(0), m_depthBufferID(0), m_initiated(false), m_useDepth(false), m_numTextures(0)
+ :m_fboID(0), m_depthBufferID(0), m_initiated(false), m_useDepth(false),m_useScreenSize(false), m_width(0),m_height(0), m_numTextures(0)
{
for (uint8_t i = 0; i < 4; ++i) m_textures[i] = NULL;
}
@@ -29,15 +30,27 @@
m_initiated = true;
+ GenerateFBO();
+ Bind();
+
+// CHECKFBO; //Incomplete FBO
+}
+
+void MercuryFBO::GenerateFBO()
+{
if( m_useDepth ) glGenRenderbuffersEXT( 1, &m_depthBufferID );
glGenFramebuffersEXT( 1, &m_fboID );
for (uint8_t i = 0; i < m_numTextures; ++i)
{
- m_textures[i] = Texture::LoadDynamicTexture(m_name);
- m_textures[i]->MakeDynamic(m_width, m_height,m_name);
+ MString n = ssprintf("%s_%d", m_name.c_str(), i);
+ m_textures[i] = Texture::LoadDynamicTexture(n);
+ m_textures[i]->MakeDynamic(m_width, m_height,n);
}
-
+}
+
+void MercuryFBO::Bind()
+{
if( m_useDepth )
{
glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, m_fboID );
@@ -51,9 +64,9 @@
if( m_useDepth )
glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_depthBufferID );
+}
- CHECKFBO; //Incomplete FBO
-}
+
/*
void MercuryFBO::InitFBOBeforeRender()
{
@@ -66,6 +79,24 @@
void MercuryFBO::PreRender(const MercuryMatrix& matrix)
{
if ( !m_initiated ) Setup();
+
+ if ( m_useScreenSize )
+ {
+ int w = MercuryWindow::GetCurrentWindow()->Width();
+ int h = MercuryWindow::GetCurrentWindow()->Height();
+ if ((m_width != w) || (m_height != h))
+ {
+ m_width = w; m_height = h;
+ for (uint8_t i = 0; i < m_numTextures; ++i)
+ {
+ MString n = ssprintf("%s_%d", m_name.c_str(), i);
+ m_textures[i]->MakeDynamic(m_width, m_height,n);
+ }
+ Bind();
+ }
+ }
+ GLERRORCHECK;
+
RenderableNode::PreRender(matrix);
}
@@ -80,16 +111,22 @@
// m_lastInStask = m_lastRendered;
}
+ GLERRORCHECK;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ GLERRORCHECK;
glPushAttrib(GL_VIEWPORT_BIT);
-// glViewport(0,0,m_width, m_width);
+ if ( !m_useScreenSize ) glViewport(0,0,m_width, m_height);
+
+ GLERRORCHECK;
RenderableNode::Render(matrix);
+ GLERRORCHECK;
}
void MercuryFBO::PostRender(const MercuryMatrix& matrix)
{
+ GLERRORCHECK;
glPopAttrib();
// glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_lastInStask);
@@ -99,6 +136,7 @@
GLERRORCHECK;
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); //unbind
+
CHECKFBO;
GLERRORCHECK;
@@ -119,6 +157,9 @@
if ( !node.Attribute("tnum").empty() )
SetNumTextures( StrToInt(node.Attribute("tnum")) );
+ if ( !node.Attribute("usescreensize").empty() )
+ m_useScreenSize = node.Attribute("usescreensize") == "true"?true:false;
+
RenderableNode::LoadFromXML(node);
}
Modified: Mercury2/src/MercuryFBO.h
===================================================================
--- Mercury2/src/MercuryFBO.h 2009-06-14 02:03:25 UTC (rev 319)
+++ Mercury2/src/MercuryFBO.h 2009-06-14 03:34:30 UTC (rev 320)
@@ -27,10 +27,12 @@
private:
void Setup();
void Clean();
+ void GenerateFBO();
+ void Bind();
// void InitFBOBeforeRender();
uint32_t m_fboID, m_depthBufferID;
- bool m_initiated, m_useDepth;
+ bool m_initiated, m_useDepth, m_useScreenSize;
uint16_t m_width, m_height;
// uint32_t m_textureID[4];
Texture *m_textures[4];
Modified: Mercury2/src/Texture.cpp
===================================================================
--- Mercury2/src/Texture.cpp 2009-06-14 02:03:25 UTC (rev 319)
+++ Mercury2/src/Texture.cpp 2009-06-14 03:34:30 UTC (rev 320)
@@ -167,16 +167,16 @@
void Texture::MakeDynamic(uint16_t width, uint16_t height, const MString& name)
{
- Clean();
+// Clean();
SetLoadState(LOADED);
REMOVE_ASSET_INSTANCE(TEXTURE, m_path);
m_path = "DYNATEXT"+name;
ADD_ASSET_INSTANCE(Texture, m_path, this);
-
- glGenTextures( 1, &m_textureID );
- printf("booo %d\n", m_textureID);
+
+ if (m_textureID == 0) printf("booo %d\n", m_textureID);
+ if (m_textureID == 0) glGenTextures( 1, &m_textureID );
glBindTexture( GL_TEXTURE_2D, m_textureID );
glCopyTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, width, height, 0 );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|