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: <cn...@us...> - 2009-06-24 02:16:38
|
Revision: 369
http://hgengine.svn.sourceforge.net/hgengine/?rev=369&view=rev
Author: cnlohr
Date: 2009-06-24 02:15:27 +0000 (Wed, 24 Jun 2009)
Log Message:
-----------
fix crash on exit
Modified Paths:
--------------
Mercury2/src/X11Window.cpp
Modified: Mercury2/src/X11Window.cpp
===================================================================
--- Mercury2/src/X11Window.cpp 2009-06-24 00:34:53 UTC (rev 368)
+++ Mercury2/src/X11Window.cpp 2009-06-24 02:15:27 UTC (rev 369)
@@ -115,6 +115,7 @@
if ( unsigned(event.xclient.data.l[0]) == m_wmDeleteMessage )
{
XDestroyWindow(m_display,m_window);
+ return false;
}
break;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-06-24 01:22:15
|
Revision: 368
http://hgengine.svn.sourceforge.net/hgengine/?rev=368&view=rev
Author: axlecrusher
Date: 2009-06-24 00:34:53 +0000 (Wed, 24 Jun 2009)
Log Message:
-----------
don't need to do this
Modified Paths:
--------------
Mercury2/src/MercuryNode.cpp
Mercury2/src/MercuryNode.h
Mercury2/src/RenderGraph.cpp
Modified: Mercury2/src/MercuryNode.cpp
===================================================================
--- Mercury2/src/MercuryNode.cpp 2009-06-23 23:48:43 UTC (rev 367)
+++ Mercury2/src/MercuryNode.cpp 2009-06-24 00:34:53 UTC (rev 368)
@@ -105,7 +105,7 @@
child->RecursiveUpdate(dTime);
}
-void MercuryNode::RecursiveRender(bool doAlpha)
+void MercuryNode::RecursiveRender()
{
MercuryMatrix modelView;
ShaderAttribute sa;
@@ -128,7 +128,7 @@
//call render on other render graph entries under me
for (MercuryNode* child = FirstChild(); child != NULL; child = NextChild(child))
{
- if (child->m_useAlphaPath && !doAlpha)
+ if ( child->m_useAlphaPath )
CURRENTRENDERGRAPH->AddAlphaNode(child);
else
child->RecursiveRender();
Modified: Mercury2/src/MercuryNode.h
===================================================================
--- Mercury2/src/MercuryNode.h 2009-06-23 23:48:43 UTC (rev 367)
+++ Mercury2/src/MercuryNode.h 2009-06-24 00:34:53 UTC (rev 368)
@@ -48,7 +48,7 @@
void ThreadedUpdate(float dTime);
- void RecursiveRender(bool doAlpha = false);
+ void RecursiveRender();
///Run on parent when a child is added
virtual void OnAddChild() {};
@@ -89,7 +89,6 @@
virtual MercuryMatrix ManipulateMatrix(const MercuryMatrix& matrix);
-
protected:
std::list< MercuryNode* > m_children; //These nodes are unique, not instanced
MercuryNode* m_parent;
Modified: Mercury2/src/RenderGraph.cpp
===================================================================
--- Mercury2/src/RenderGraph.cpp 2009-06-23 23:48:43 UTC (rev 367)
+++ Mercury2/src/RenderGraph.cpp 2009-06-24 00:34:53 UTC (rev 368)
@@ -96,7 +96,7 @@
(*i)->Render(srs.Node);
}
- srs.Node->RecursiveRender(true);
+ srs.Node->RecursiveRender();
for (i = srs.Assets.begin();i != srs.Assets.end(); ++i)
(*i)->PostRender(srs.Node);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-06-23 23:48:44
|
Revision: 367
http://hgengine.svn.sourceforge.net/hgengine/?rev=367&view=rev
Author: axlecrusher
Date: 2009-06-23 23:48:43 +0000 (Tue, 23 Jun 2009)
Log Message:
-----------
fix critical bugs.
initialize variables in contructor.
fix order of setting a pointer in the event of a failure
Modified Paths:
--------------
Mercury2/modules/TextNode.cpp
Modified: Mercury2/modules/TextNode.cpp
===================================================================
--- Mercury2/modules/TextNode.cpp 2009-06-23 13:51:18 UTC (rev 366)
+++ Mercury2/modules/TextNode.cpp 2009-06-23 23:48:43 UTC (rev 367)
@@ -9,7 +9,7 @@
REGISTER_NODE_TYPE(TextNode);
TextNode::TextNode()
- :MercuryNode(),m_fSize(1.),m_bDirty(0), m_kVBO(0), m_kTEX(0)
+ :MercuryNode(),m_fSize(1.),m_bDirty(false),m_pThisFont(NULL),m_kVBO(0), m_kTEX(0)
{
}
@@ -168,13 +168,13 @@
{
if( g_AllFonts.get( sFont ) == 0 )
{
- m_pThisFont = &g_AllFonts[sFont];
if( !m_pThisFont->LoadFromFile( sFont ) )
{
fprintf( stderr, "Error: Could not load font: \"%s\".", sFont.c_str() );
g_AllFonts.remove( sFont );
return false;
}
+ m_pThisFont = &g_AllFonts[sFont];
} else
m_pThisFont = &g_AllFonts[sFont];
SetDirtyText();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2009-06-23 14:02:51
|
Revision: 366
http://hgengine.svn.sourceforge.net/hgengine/?rev=366&view=rev
Author: cnlohr
Date: 2009-06-23 13:51:18 +0000 (Tue, 23 Jun 2009)
Log Message:
-----------
whoops forgot to committ his
Added Paths:
-----------
Mercury2/modules/TextNode.h
Added: Mercury2/modules/TextNode.h
===================================================================
--- Mercury2/modules/TextNode.h (rev 0)
+++ Mercury2/modules/TextNode.h 2009-06-23 13:51:18 UTC (rev 366)
@@ -0,0 +1,106 @@
+#ifndef TEXTNODE_H
+#define TEXTNODE_H
+
+#include <MercuryNode.h>
+#include <MercuryHash.h>
+
+class MercuryAsset;
+
+class TextNode : public MercuryNode
+{
+public:
+ TextNode();
+
+ virtual void Update(float dTime);
+ virtual void LoadFromXML(const XMLNode& node);
+ virtual bool LoadFont( const MString & sFont );
+ virtual void SetSize( float fSize );
+ virtual void SetText( const MString & sText );
+
+ inline void SetDirtyText() { m_bDirty = true; }
+
+ virtual void RenderText();
+
+ GENRTTI(TextNode);
+private:
+ class Font;
+
+ float m_fSize;
+ MString m_sText;
+ MString m_sFont;
+ bool m_bDirty;
+ Font * m_pThisFont;
+
+ MAutoPtr< MercuryAsset > m_kVBO;
+ MAutoPtr< MercuryAsset > m_kTEX;
+
+ //Font-class specific stuff
+ class Glyph
+ {
+ public:
+ Glyph() : fsx( 0 ), fsy( 0 ), fex( 0 ), fey( 0 ), ilx( 0 ), ily( 0 ), iox( 0 ), ioy( 0 ) { }
+ float fsx, fsy; //U/V upper left coords
+ float fex, fey; //U/V lower left coords
+ float ilx, ily; //size x/y in px.
+ float iox, ioy; //location x/y in cursor-center of char.
+ };
+
+ class Font
+ {
+ public:
+ bool LoadFromFile( const MString & fName );
+
+ std::map< int, Glyph > m_mGlyphs;
+ MString m_sImage;
+ float m_fHeight;
+ };
+
+ static MHash< Font > g_AllFonts;
+
+ //Datastructure when formatting the text
+ class DChar
+ {
+ public:
+ DChar( Glyph * g, int c, float x, float y ) : glyph(g), character(c), xps(x), yps(y) { }
+
+ Glyph * glyph;
+ int character;
+ float xps; //aka pos on line
+ float yps; //aka line
+ };
+};
+
+#endif
+
+
+/****************************************************************************
+ * Copyright (C) 2009 by Joshua Allen *
+ * *
+ * *
+ * All rights reserved. *
+ * *
+ * Redistribution and use in source and binary forms, with or without *
+ * modification, are permitted provided that the following conditions *
+ * are met: *
+ * * Redistributions of source code must retain the above copyright *
+ * notice, this list of conditions and the following disclaimer. *
+ * * Redistributions in binary form must reproduce the above *
+ * copyright notice, this list of conditions and the following *
+ * disclaimer in the documentation and/or other materials provided *
+ * with the distribution. *
+ * * Neither the name of the Mercury Engine nor the names of its *
+ * contributors may be used to endorse or promote products derived *
+ * from this software without specific prior written permission. *
+ * *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR *
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT *
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
+ ***************************************************************************/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2009-06-23 04:56:11
|
Revision: 365
http://hgengine.svn.sourceforge.net/hgengine/?rev=365&view=rev
Author: cnlohr
Date: 2009-06-23 04:56:11 +0000 (Tue, 23 Jun 2009)
Log Message:
-----------
add text to scene graph
Modified Paths:
--------------
Mercury2/scenegraph.xml
Modified: Mercury2/scenegraph.xml
===================================================================
--- Mercury2/scenegraph.xml 2009-06-23 04:56:04 UTC (rev 364)
+++ Mercury2/scenegraph.xml 2009-06-23 04:56:11 UTC (rev 365)
@@ -6,6 +6,10 @@
<node type="cameranode" movx="0" movz="0" movy="0" rotx="0" roty="0" rotz="0" name="camera">
<node type="viewport" fov="45" aspect="1.3333" near="0.01" far="100" name="vp"/>
</node>
+
+ <node type="transformnode" movz="-5" >
+ <node type="TextNode" text="test font 123" font="testfont.hgfont" size=".01" />
+ </node>
<!-- <asset type="texture" file="screenFBO_0" dynamic="true"/>
<asset type="fullscreenquad"/>
<node type="mercuryfbo" width="640" height="480" depth="true" tnum="2" name="screenFBO" usescreensize="true">
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2009-06-23 04:56:06
|
Revision: 364
http://hgengine.svn.sourceforge.net/hgengine/?rev=364&view=rev
Author: cnlohr
Date: 2009-06-23 04:56:04 +0000 (Tue, 23 Jun 2009)
Log Message:
-----------
update VBO as to enable direct manipulation instead of forcing abstraction
Modified Paths:
--------------
Mercury2/src/MercuryVBO.h
Modified: Mercury2/src/MercuryVBO.h
===================================================================
--- Mercury2/src/MercuryVBO.h 2009-06-23 04:55:17 UTC (rev 363)
+++ Mercury2/src/MercuryVBO.h 2009-06-23 04:56:04 UTC (rev 364)
@@ -21,7 +21,9 @@
static uint32_t BatchCount() { return m_vboBatches; }
static uint32_t ResetBatchCount() { uint32_t t = m_vboBatches; m_vboBatches = 0; return t; }
static uint32_t ResetBindCount() { uint32_t t = m_vboBinds; m_vboBinds = 0; return t; }
-
+
+ float * GetVertexHandle() { return &m_vertexData[0]; }
+ short unsigned int * GetIndexHandle() { return &m_indexData[0]; }
private:
virtual void InitVBO();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2009-06-23 04:55:22
|
Revision: 363
http://hgengine.svn.sourceforge.net/hgengine/?rev=363&view=rev
Author: cnlohr
Date: 2009-06-23 04:55:17 +0000 (Tue, 23 Jun 2009)
Log Message:
-----------
add "GetType()" to get the string name of the class on hand.
Modified Paths:
--------------
Mercury2/src/MercuryNode.h
Modified: Mercury2/src/MercuryNode.h
===================================================================
--- Mercury2/src/MercuryNode.h 2009-06-23 04:54:38 UTC (rev 362)
+++ Mercury2/src/MercuryNode.h 2009-06-23 04:55:17 UTC (rev 363)
@@ -17,7 +17,8 @@
#define GENRTTI(x) static const x* Cast(const MercuryNode* n) \
{ if (n==NULL) return NULL; return dynamic_cast<const x*>(n); } \
static x* Cast(MercuryNode* n) \
-{ if (n==NULL) return NULL; return dynamic_cast<x*>(n); }
+{ if (n==NULL) return NULL; return dynamic_cast<x*>(n); } \
+static const char * GetType() { return #x; }
/*
#define GENRTTI(x) static bool IsMyType(const MercuryNode* n) \
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2009-06-23 04:54:38
|
Revision: 362
http://hgengine.svn.sourceforge.net/hgengine/?rev=362&view=rev
Author: cnlohr
Date: 2009-06-23 04:54:38 +0000 (Tue, 23 Jun 2009)
Log Message:
-----------
be more descriptive, especially when something goes wrong, report the linking error.
Modified Paths:
--------------
Mercury2/src/ModuleManager.cpp
Modified: Mercury2/src/ModuleManager.cpp
===================================================================
--- Mercury2/src/ModuleManager.cpp 2009-06-23 04:54:16 UTC (rev 361)
+++ Mercury2/src/ModuleManager.cpp 2009-06-23 04:54:38 UTC (rev 362)
@@ -38,12 +38,13 @@
{
XMLDocument* doc = XMLDocument::Load("modules.xml");
XMLNode r = doc->GetRootNode();
- for (XMLNode child = r.Child(); child.IsValid(); child = r.NextNode())
+ for (XMLNode child = r.Child(); child.IsValid(); child = child.NextNode())
{
if( child.Name() != "Module" )
{
fprintf( stderr, "Invalid element in modules: %s\n", child.Name().c_str() );
}
+ printf( "Loading: %s\n", child.Attribute( "obj" ).c_str() );
#ifdef WIN32
MString ModuleName = child.Attribute( "obj" ) + ".dll";
#else
@@ -63,11 +64,13 @@
bool ModuleManager::LoadModule( const MString & ModuleName, const MString & LoadFunction )
{
if( m_hAllHandles[ModuleName] ) UnloadModule( ModuleName );
- m_hAllHandles[ModuleName] = dlopen( ModuleName.c_str(), RTLD_NOW | RTLD_GLOBAL );
+ void * v = dlopen( ModuleName.c_str(), RTLD_NOW | RTLD_GLOBAL );
+ m_hAllHandles[ModuleName] = v;
+
if( !m_hAllHandles[ModuleName] )
{
- fprintf( stderr, "Error opening: %s\n", ModuleName.c_str() );
+ fprintf( stderr, "Error opening: %s (%s)\n", ModuleName.c_str(), dlerror() );
return false;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2009-06-23 04:54:19
|
Revision: 361
http://hgengine.svn.sourceforge.net/hgengine/?rev=361&view=rev
Author: cnlohr
Date: 2009-06-23 04:54:16 +0000 (Tue, 23 Jun 2009)
Log Message:
-----------
cleanup font size and names of files
Modified Paths:
--------------
Mercury2/tools/fonter/main.cpp
Modified: Mercury2/tools/fonter/main.cpp
===================================================================
--- Mercury2/tools/fonter/main.cpp 2009-06-23 04:53:59 UTC (rev 360)
+++ Mercury2/tools/fonter/main.cpp 2009-06-23 04:54:16 UTC (rev 361)
@@ -8,6 +8,8 @@
# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf)
#endif
+#define FONTSIZE 64
+
FILE * fontfile;
int my_write_png( const char * fname, unsigned char * imagedata, int x, int y );
@@ -46,7 +48,7 @@
fprintf( stderr, "Could not open font output file: %s\n", fname );
exit( -1 );
}
- fprintf( fontfile, "%s\n", pngname );
+ fprintf( fontfile, "%s\n%d\n", pngname, FONTSIZE );
my_read_font( argv[1], imagedata, 64, 64, 16, 16 );
my_write_png( pngname, imagedata, 1024, 1024 );
@@ -81,7 +83,7 @@
exit( -1 );
}
- error = FT_Set_Pixel_Sizes( face, 0, 64 );
+ error = FT_Set_Pixel_Sizes( face, 0, FONTSIZE );
if( error )
{
fprintf( stderr, "Error with FT_Set_Pixel_Sizes\n" );
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2009-06-23 04:54:00
|
Revision: 360
http://hgengine.svn.sourceforge.net/hgengine/?rev=360&view=rev
Author: cnlohr
Date: 2009-06-23 04:53:59 +0000 (Tue, 23 Jun 2009)
Log Message:
-----------
update modules
Modified Paths:
--------------
Mercury2/modules.xml
Modified: Mercury2/modules.xml
===================================================================
--- Mercury2/modules.xml 2009-06-23 04:53:46 UTC (rev 359)
+++ Mercury2/modules.xml 2009-06-23 04:53:59 UTC (rev 360)
@@ -1,3 +1,4 @@
<Modules>
- <Module src="modules/BillboardNode.c" obj="modules/BillboardNode" func="InstallBillboardNode" />
+ <Module src="modules/TextNode.cpp" obj="modules/TextNode" func="InstallTextNode" />
+ <Module src="modules/BillboardNode.cpp" obj="modules/BillboardNode" func="InstallBillboardNode"/>
</Modules>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2009-06-23 04:53:52
|
Revision: 359
http://hgengine.svn.sourceforge.net/hgengine/?rev=359&view=rev
Author: cnlohr
Date: 2009-06-23 04:53:46 +0000 (Tue, 23 Jun 2009)
Log Message:
-----------
woot text node
Modified Paths:
--------------
Mercury2/modules/Makefile
Added Paths:
-----------
Mercury2/modules/TextNode.cpp
Modified: Mercury2/modules/Makefile
===================================================================
--- Mercury2/modules/Makefile 2009-06-23 00:23:23 UTC (rev 358)
+++ Mercury2/modules/Makefile 2009-06-23 04:53:46 UTC (rev 359)
@@ -2,7 +2,7 @@
CXXFLAGS=${CFLAGS}
LDFLAGS=-shared
-all : BillboardNode.so
+all : BillboardNode.so TextNode.so
clean :
rm -rf *~ *.o *.so
@@ -10,3 +10,5 @@
BillboardNode.so : BillboardNode.o
g++ -o$@ $^ ${LDFLAGS}
+TextNode.so : TextNode.o
+ g++ -o$@ $^ ${LDFLAGS}
Added: Mercury2/modules/TextNode.cpp
===================================================================
--- Mercury2/modules/TextNode.cpp (rev 0)
+++ Mercury2/modules/TextNode.cpp 2009-06-23 04:53:46 UTC (rev 359)
@@ -0,0 +1,285 @@
+#include "TextNode.h"
+#include <MercuryVertex.h>
+#include <Viewport.h>
+#include <MercuryFile.h>
+#include <MercuryVBO.h>
+#include <Texture.h>
+#include <vector>
+
+REGISTER_NODE_TYPE(TextNode);
+
+TextNode::TextNode()
+ :MercuryNode(),m_fSize(1.),m_bDirty(0), m_kVBO(0), m_kTEX(0)
+{
+}
+
+void TextNode::Update(float dTime)
+{
+ if( m_bDirty )
+ {
+ RenderText();
+ }
+
+ MercuryNode::Update( dTime );
+}
+
+void TextNode::LoadFromXML(const XMLNode& node)
+{
+ MercuryNode::LoadFromXML(node);
+
+ if ( !node.Attribute("font").empty() )
+ LoadFont( node.Attribute("font") );
+ if ( !node.Attribute("size").empty() )
+ SetSize( StrToFloat( node.Attribute("size") ) );
+ if ( !node.Attribute("text").empty() )
+ SetText( node.Attribute("text") );
+}
+
+void TextNode::RenderText()
+{
+ std::vector< DChar > chars;
+ float xps = 0;
+ float yps = 0;
+
+ if( !m_pThisFont )
+ return;
+
+// AddAsset( AssetFactory::GetInstance().Generate( "Quad", "MyQuad" ) );
+
+ if( !m_kTEX )
+ {
+ m_kTEX = MAutoPtr< MercuryAsset >( Texture::LoadFromFile( m_pThisFont->m_sImage ) );
+ if( !m_kTEX )
+ {
+ fprintf( stderr, "Could not create Texture for text.\n" );
+ return;
+ }
+ m_kTEX->Init( this );
+ }
+
+ //Setup FBO and Texture
+ if( !m_kVBO )
+ {
+ m_kVBO = new MercuryVBO;
+ if( !m_kVBO )
+ {
+ fprintf( stderr, "Could not create VBO for text.\n" );
+ return;
+ }
+ AddAsset( m_kVBO );
+ }
+
+ //Pass 1: Figure out actual char positions and count
+ for( const char * c = &m_sText[0]; *c != 0; c++ )
+ {
+ if( *c == 9 )
+ xps+=80;
+ else if( *c == 10 )
+ {
+ xps = 0;
+ yps += m_pThisFont->m_fHeight; //??XXXX NEED TO SET TO RIGHT VALUE!
+ }
+ else if( *c == 32 )
+ xps+=20;
+ else
+ {
+ if( m_pThisFont->m_mGlyphs.find( *c ) != m_pThisFont->m_mGlyphs.end() )
+ {
+ Glyph & g = m_pThisFont->m_mGlyphs[*c];
+
+ chars.push_back( DChar( &g, *c, xps, yps ) );
+ //Here is the right place to do line-splitting if need be.
+
+ xps += g.ilx+4; //Why 4?
+ }
+ }
+ }
+
+ //Stage 2: Actually generate the geometry.
+ ((MercuryVBO*)m_kVBO.Ptr())->AllocateIndexSpace(chars.size()*6);
+ ((MercuryVBO*)m_kVBO.Ptr())->AllocateVertexSpace(chars.size()*4);
+
+ for( unsigned i = 0; i < chars.size(); i++ )
+ {
+ DChar & dc = chars[i];
+ Glyph * g = dc.glyph;
+ float * vd = ((MercuryVBO*)m_kVBO.Ptr())->GetVertexHandle();
+ short unsigned int * id = ((MercuryVBO*)m_kVBO.Ptr())->GetIndexHandle();
+
+ float sx = (-g->iox + dc.xps)*m_fSize;
+ float sy = -(-g->ioy + dc.yps)*m_fSize;
+ float ex = (g->ilx-g->iox + dc.xps)*m_fSize;
+ float ey = -(g->ily-g->ioy + dc.yps)*m_fSize;
+
+ //Vertex1: Upper Left
+ vd[(i*4+0)*8+0] = g->fsx;
+ vd[(i*4+0)*8+1] = g->fsy; //U,V
+ vd[(i*4+0)*8+2] = 0;
+ vd[(i*4+0)*8+3] = 0;
+ vd[(i*4+0)*8+4] = -1; //Normal <0,0,-1>
+ vd[(i*4+0)*8+5] = sx;
+ vd[(i*4+0)*8+6] = sy;
+ vd[(i*4+0)*8+7] = 0;
+
+ //Vertex 2: Upper Right
+ vd[(i*4+1)*8+0] = g->fex;
+ vd[(i*4+1)*8+1] = g->fsy;
+ vd[(i*4+1)*8+2] = 0;
+ vd[(i*4+1)*8+3] = 0;
+ vd[(i*4+1)*8+4] = -1; //Normal <0,0,-1>
+ vd[(i*4+1)*8+5] = ex;
+ vd[(i*4+1)*8+6] = sy;
+ vd[(i*4+1)*8+7] = 0;
+
+ //Vertex 3: Lower Right
+ vd[(i*4+2)*8+0] = g->fex;
+ vd[(i*4+2)*8+1] = g->fey;
+ vd[(i*4+2)*8+2] = 0;
+ vd[(i*4+2)*8+3] = 0;
+ vd[(i*4+2)*8+4] = -1; //Normal <0,0,-1>
+ vd[(i*4+2)*8+5] = ex;
+ vd[(i*4+2)*8+6] = ey;
+ vd[(i*4+2)*8+7] = 0;
+
+ //Vertex 4: Lower Left
+ vd[(i*4+3)*8+0] = g->fsx;
+ vd[(i*4+3)*8+1] = g->fey;
+ vd[(i*4+3)*8+2] = 0;
+ vd[(i*4+3)*8+3] = 0;
+ vd[(i*4+3)*8+4] = -1; //Normal <0,0,-1>
+ vd[(i*4+3)*8+5] = sx;
+ vd[(i*4+3)*8+6] = ey;
+ vd[(i*4+3)*8+7] = 0;
+
+ printf( "%f %f %f %f %f %f %f %f\n", vd[(i*4+0)*8+5], vd[(i*4+0)*8+6], vd[(i*4+1)*8+5], vd[(i*4+1)*8+6], vd[(i*4+2)*8+5], vd[(i*4+2)*8+6], vd[(i*4+3)*8+5], vd[(i*4+3)*8+6] );
+ id[i*6+0] = i * 4 + 2;
+ id[i*6+1] = i * 4 + 1;
+ id[i*6+2] = i * 4 + 0;
+ id[i*6+3] = i * 4 + 0;
+ id[i*6+4] = i * 4 + 3;
+ id[i*6+5] = i * 4 + 2;
+ }
+
+ m_bDirty = false;
+ m_kVBO->Init( this );
+}
+
+bool TextNode::LoadFont( const MString & sFont )
+{
+ if( g_AllFonts.get( sFont ) == 0 )
+ {
+ m_pThisFont = &g_AllFonts[sFont];
+ if( !m_pThisFont->LoadFromFile( sFont ) )
+ {
+ fprintf( stderr, "Error: Could not load font: \"%s\".", sFont.c_str() );
+ g_AllFonts.remove( sFont );
+ return false;
+ }
+ } else
+ m_pThisFont = &g_AllFonts[sFont];
+ SetDirtyText();
+
+ return true;
+}
+
+void TextNode::SetSize( float fSize )
+{
+ m_fSize = fSize;
+ SetDirtyText();
+}
+
+void TextNode::SetText( const MString & sText )
+{
+ m_sText = sText;
+ SetDirtyText();
+}
+
+
+bool TextNode::Font::LoadFromFile( const MString & fName )
+{
+ int line = 0;
+ MString sLine;
+
+ MercuryFile * f = FILEMAN.Open( fName );
+ if( !f )
+ return false;
+
+ if( !f->ReadLine( m_sImage ) )
+ {
+ delete f;
+ return false;
+ }
+
+ if( !f->ReadLine( sLine ) )
+ {
+ delete f;
+ return false;
+ }
+
+ if( sscanf( sLine.c_str(), "%f", &m_fHeight ) != 1 )
+ {
+ fprintf( stderr, "Malformatted font size.\n" );
+ delete f;
+ return false;
+ }
+
+ while( !f->Eof() )
+ {
+ int res;
+ line++;
+
+ Glyph g;
+ int ch;
+
+ f->ReadLine( sLine );
+ if( ( res = sscanf( sLine.c_str(), "%d %f %f %f %f %f %f %f %f", &ch,
+ &g.fsx, &g.fsy, &g.fex, &g.fey, &g.ilx, &g.ily, &g.iox, &g.ioy ) ) != 9 )
+ {
+ if( res == 0 || res == -1 ) continue;
+ fprintf( stderr, "Error on line %d of font \"%s\" (invalid number of args) (%d args).\n", line, fName.c_str(), res );
+ delete f;
+ return false;
+ }
+
+ //Insert the glyph into the map.
+ m_mGlyphs[ch] = g;
+ }
+
+ delete f;
+ return true;
+}
+
+MHash< TextNode::Font > TextNode::g_AllFonts;
+
+
+/****************************************************************************
+ * Copyright (C) 2009 by Charles Lohr *
+ * *
+ * *
+ * All rights reserved. *
+ * *
+ * Redistribution and use in source and binary forms, with or without *
+ * modification, are permitted provided that the following conditions *
+ * are met: *
+ * * Redistributions of source code must retain the above copyright *
+ * notice, this list of conditions and the following disclaimer. *
+ * * Redistributions in binary form must reproduce the above *
+ * copyright notice, this list of conditions and the following *
+ * disclaimer in the documentation and/or other materials provided *
+ * with the distribution. *
+ * * Neither the name of the Mercury Engine nor the names of its *
+ * contributors may be used to endorse or promote products derived *
+ * from this software without specific prior written permission. *
+ * *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR *
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT *
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
+ ***************************************************************************/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-06-23 00:59:32
|
Revision: 358
http://hgengine.svn.sourceforge.net/hgengine/?rev=358&view=rev
Author: axlecrusher
Date: 2009-06-23 00:23:23 +0000 (Tue, 23 Jun 2009)
Log Message:
-----------
add transparent pass
Modified Paths:
--------------
Mercury2/scenegraph.xml
Mercury2/src/Mercury2.cpp
Mercury2/src/MercuryNode.cpp
Mercury2/src/MercuryNode.h
Mercury2/src/RenderGraph.cpp
Mercury2/src/RenderGraph.h
Mercury2/src/Texture.cpp
Mercury2/src/Texture.h
Mercury2/src/X11Window.cpp
Added Paths:
-----------
Mercury2/flame.png
Added: Mercury2/flame.png
===================================================================
(Binary files differ)
Property changes on: Mercury2/flame.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: Mercury2/scenegraph.xml
===================================================================
--- Mercury2/scenegraph.xml 2009-06-21 13:49:48 UTC (rev 357)
+++ Mercury2/scenegraph.xml 2009-06-23 00:23:23 UTC (rev 358)
@@ -6,21 +6,27 @@
<node type="cameranode" movx="0" movz="0" movy="0" rotx="0" roty="0" rotz="0" name="camera">
<node type="viewport" fov="45" aspect="1.3333" near="0.01" far="100" name="vp"/>
</node>
- <asset type="texture" file="screenFBO_0" dynamic="true"/>
+<!-- <asset type="texture" file="screenFBO_0" dynamic="true"/>
<asset type="fullscreenquad"/>
<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="transformnode" rotx="-90" movz="-10" movx="0" movy="-5">
<asset type="texture" file="map.png"/>
<asset type="hgmdlmodel" file="map.hgmdl" />
</node>
<node type="mercurynode" name="lampForest" >
- <asset type="texture" file="lamp.png"/>
<node type="transformnode" movz="-5" movx="0" movy="0" name="lamprow" >
- <node type="transformnode" rotx="-90" name="lamp">
- <node type="billboardnode" billboardaxis="0,0,1" spheremode="true" >
+ <node type="mercurynode" name="lamp">
+ <node type="transformnode" rotx="-90" >
+ <asset type="texture" file="lamp.png"/>
<asset type="hgmdlmodel" file="lampN.hgmdl" />
</node>
+ <node type="billboardnode" billboardaxis="0,1,0" spheremode="true" >
+ <node type="transformnode" roty="180" scalex="0.1" scaley="0.1" alphaPath="true">
+ <asset type="texture" file="flame.png"/>
+ <asset type="quad"/>
+ </node>
+ </node>
</node>
<node type="transformnode" movx="1" fallback="lamprow.lamp" />
<node type="transformnode" movx="2" fallback="lamprow.lamp" />
@@ -36,5 +42,5 @@
<node type="transformnode" movz="-4" fallback="lampForest.lamprow"/>
<node type="transformnode" movz="-3" fallback="lampForest.lamprow"/>
</node>
- </node>
+<!-- </node> -->
</SceneGraph>
Modified: Mercury2/src/Mercury2.cpp
===================================================================
--- Mercury2/src/Mercury2.cpp 2009-06-21 13:49:48 UTC (rev 357)
+++ Mercury2/src/Mercury2.cpp 2009-06-23 00:23:23 UTC (rev 358)
@@ -6,7 +6,7 @@
#include <XMLParser.h>
-//#include <RenderableNode.h>
+#include <RenderGraph.h>
#include <MercuryCrash.h>
#include <MercuryBacktrace.h>
@@ -76,6 +76,7 @@
MESSAGEMAN::GetInstance().PumpMessages( timer.MicrosecondsSinceInit() );
root->RecursiveUpdate( timer.Age() ); //comment to use threads
+ CURRENTRENDERGRAPH = &renderGraph;
if ( MercuryNode::NeedsRebuild() )
{
renderGraph.Build(root);
@@ -86,6 +87,7 @@
// RenderableNode::RecursiveRender(root);
// printf("\n");
root->RecursiveRender();
+ renderGraph.RenderAlpha();
w->SwapBuffers();
++m_count;
Modified: Mercury2/src/MercuryNode.cpp
===================================================================
--- Mercury2/src/MercuryNode.cpp 2009-06-21 13:49:48 UTC (rev 357)
+++ Mercury2/src/MercuryNode.cpp 2009-06-23 00:23:23 UTC (rev 358)
@@ -7,13 +7,14 @@
#include <GLHeaders.h>
#include <Shader.h>
+#include <RenderGraph.h>
using namespace std;
REGISTER_NODE_TYPE(MercuryNode);
MercuryNode::MercuryNode()
- :m_parent(NULL), m_prevSibling(NULL), m_nextSibling(NULL), m_hidden(false)
+ :m_parent(NULL), m_prevSibling(NULL), m_nextSibling(NULL), m_hidden(false), m_useAlphaPath(false)
{
}
@@ -104,7 +105,7 @@
child->RecursiveUpdate(dTime);
}
-void MercuryNode::RecursiveRender()
+void MercuryNode::RecursiveRender(bool doAlpha)
{
MercuryMatrix modelView;
ShaderAttribute sa;
@@ -126,7 +127,12 @@
//call render on other render graph entries under me
for (MercuryNode* child = FirstChild(); child != NULL; child = NextChild(child))
- child->RecursiveRender();
+ {
+ if (child->m_useAlphaPath && !doAlpha)
+ CURRENTRENDERGRAPH->AddAlphaNode(child);
+ else
+ child->RecursiveRender();
+ }
glLoadMatrixf( modelView.Ptr() );
Shader::SetAttribute("HG_ModelMatrix", sa);
@@ -150,6 +156,9 @@
if ( !node.Attribute("hidden").empty() )
m_hidden = node.Attribute("hidden")=="true"?true:false;
+ if ( !node.Attribute("alphaPath").empty() )
+ m_useAlphaPath = node.Attribute("alphaPath")=="true"?true:false;
+
//Not much to do here except run through all the children nodes
for (XMLNode child = node.Child(); child.IsValid(); child = child.NextNode())
{
Modified: Mercury2/src/MercuryNode.h
===================================================================
--- Mercury2/src/MercuryNode.h 2009-06-21 13:49:48 UTC (rev 357)
+++ Mercury2/src/MercuryNode.h 2009-06-23 00:23:23 UTC (rev 358)
@@ -47,7 +47,7 @@
void ThreadedUpdate(float dTime);
- void RecursiveRender();
+ void RecursiveRender(bool doAlpha = false);
///Run on parent when a child is added
virtual void OnAddChild() {};
@@ -98,6 +98,7 @@
static bool m_rebuildRenderGraph;
MString m_name;
bool m_hidden;
+ bool m_useAlphaPath;
private:
bool IsInAssetList(MercuryAsset* asset) const;
Modified: Mercury2/src/RenderGraph.cpp
===================================================================
--- Mercury2/src/RenderGraph.cpp 2009-06-21 13:49:48 UTC (rev 357)
+++ Mercury2/src/RenderGraph.cpp 2009-06-23 00:23:23 UTC (rev 358)
@@ -4,7 +4,11 @@
#include <GLHeaders.h>
#include <Shader.h>
+#include <Viewport.h>
+#include <Texture.h>
+RenderGraph* CURRENTRENDERGRAPH = NULL;
+
void RenderGraphEntry::Render()
{
MercuryMatrix modelView;
@@ -65,6 +69,60 @@
// entry = lastEntry;
}
+void RenderGraph::AddAlphaNode( MercuryNode* node )
+{
+ StoreRenderState srs;
+ srs.Save();
+ srs.Matrix = node->FindGlobalMatrix();
+ srs.Node = node;
+
+ MercuryVertex p = srs.Matrix * MercuryVertex(0,0,0,1);
+
+ //order from back to front (ensure furthest has lowest number and is first)
+ float length = (p - EYE).Length() * -1;
+ m_alphaNodesQueue.Insert(length, srs);
+}
+
+void RenderGraph::RenderAlpha()
+{
+ while ( !m_alphaNodesQueue.empty() )
+ {
+ StoreRenderState& srs = m_alphaNodesQueue.GetNext();
+
+ std::list< MercuryAsset* >::iterator i = srs.Assets.begin();
+ for (;i != srs.Assets.end(); ++i)
+ {
+ (*i)->PreRender(srs.Node);
+ (*i)->Render(srs.Node);
+ }
+
+ srs.Node->RecursiveRender(true);
+
+ for (i = srs.Assets.begin();i != srs.Assets.end(); ++i)
+ (*i)->PostRender(srs.Node);
+
+ m_alphaNodesQueue.PopNext();
+ }
+}
+
+StoreRenderState::StoreRenderState()
+ :Node(NULL)
+{
+}
+
+void StoreRenderState::Save()
+{
+ //get assets for current textures
+ const std::list< Texture* >& textures = Texture::GetActiveTextures();
+ std::list< Texture* >::const_iterator i = textures.begin();
+ for (;i != textures.end(); ++i)
+ Assets.push_back( *i );
+
+ //save the active shader
+ Shader* s = Shader::GetCurrentShader();
+ if (s) Assets.push_back(s);
+}
+
/****************************************************************************
* Copyright (C) 2009 by Joshua Allen *
* *
Modified: Mercury2/src/RenderGraph.h
===================================================================
--- Mercury2/src/RenderGraph.h 2009-06-21 13:49:48 UTC (rev 357)
+++ Mercury2/src/RenderGraph.h 2009-06-23 00:23:23 UTC (rev 358)
@@ -3,6 +3,7 @@
#include <MercuryNode.h>
//#include <RenderableNode.h>
+#include <PriorityQueue.h>
class RenderGraphEntry
{
@@ -26,16 +27,38 @@
const MercuryMatrix* m_matrix;
};
+/** Tries to get pointers to all assets needed to rebuild an accurate render state.
+This will only work for restoring the render state within the same render loop.
+**/
+class StoreRenderState
+{
+ public:
+ StoreRenderState();
+ void Save();
+ MercuryNode* Node;
+ MercuryMatrix Matrix;
+// private:
+ std::list< MercuryAsset* > Assets;
+};
+
class RenderGraph
{
public:
void Build( MercuryNode* node );
inline void Render() { m_root.Render(); }
+
+ void AddAlphaNode( MercuryNode* node );
+ void RenderAlpha();
private:
void Build( MercuryNode* node, RenderGraphEntry& entry );
RenderGraphEntry m_root;
+
+ //nodes that use alpha, ordered from farthest to nearest from the camera
+ PriorityQueue<float, StoreRenderState > m_alphaNodesQueue;
};
+extern RenderGraph* CURRENTRENDERGRAPH;
+
#endif
/****************************************************************************
Modified: Mercury2/src/Texture.cpp
===================================================================
--- Mercury2/src/Texture.cpp 2009-06-21 13:49:48 UTC (rev 357)
+++ Mercury2/src/Texture.cpp 2009-06-23 00:23:23 UTC (rev 358)
@@ -15,7 +15,7 @@
if (!m_initTextureSuccess)
{
m_initTextureSuccess = true;
- m_activeTextures = 0;
+ m_numActiveTextures = 0;
}
}
@@ -76,7 +76,7 @@
GL_UNSIGNED_BYTE,
m_raw->m_data);
*/
- gluBuild2DMipmaps( GL_TEXTURE_2D, 3, m_raw->m_width, m_raw->m_height, ByteType, GL_UNSIGNED_BYTE, m_raw->m_data );
+ gluBuild2DMipmaps( GL_TEXTURE_2D, ByteType, m_raw->m_width, m_raw->m_height, ByteType, GL_UNSIGNED_BYTE, m_raw->m_data );
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
@@ -121,7 +121,7 @@
void Texture::BindTexture()
{
- m_textureResource = GL_TEXTURE0+m_activeTextures;
+ m_textureResource = GL_TEXTURE0+m_numActiveTextures;
glActiveTexture( m_textureResource );
glClientActiveTextureARB(m_textureResource);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
@@ -134,9 +134,11 @@
ShaderAttribute sa;
sa.type = ShaderAttribute::TYPE_SAMPLER;
sa.value.iSampler = m_textureResource;
- Shader::SetAttribute( ssprintf("HG_Texture%d", m_activeTextures), sa);
+ Shader::SetAttribute( ssprintf("HG_Texture%d", m_numActiveTextures), sa);
- ++m_activeTextures;
+ m_activeTextures.push_back(this);
+
+ ++m_numActiveTextures;
++m_textureBinds;
}
@@ -148,9 +150,10 @@
glDisable( GL_TEXTURE_2D );
GLERRORCHECK;
- Shader::RemoveAttribute( ssprintf("HG_Texture%d", m_activeTextures) );
+ Shader::RemoveAttribute( ssprintf("HG_Texture%d", m_numActiveTextures) );
+ m_activeTextures.pop_back();
- --m_activeTextures;
+ --m_numActiveTextures;
}
void Texture::LoadImagePath(const MString& path)
@@ -220,8 +223,9 @@
}
bool Texture::m_initTextureSuccess = false;
-uint8_t Texture::m_activeTextures = 0;
+uint8_t Texture::m_numActiveTextures = 0;
uint32_t Texture::m_textureBinds = 0;
+std::list< Texture* > Texture::m_activeTextures;
/***************************************************************************
* Copyright (C) 2008 by Joshua Allen *
Modified: Mercury2/src/Texture.h
===================================================================
--- Mercury2/src/Texture.h 2009-06-21 13:49:48 UTC (rev 357)
+++ Mercury2/src/Texture.h 2009-06-23 00:23:23 UTC (rev 358)
@@ -21,7 +21,7 @@
void LoadFromRaw();
- inline static uint8_t NumberActiveTextures() { return m_activeTextures; }
+ inline static uint8_t NumberActiveTextures() { return m_numActiveTextures; }
inline static uint32_t ReadAndResetBindCount() { uint32_t t = m_textureBinds; m_textureBinds = 0; return t; }
inline uint32_t TextureID() const { return m_textureID; }
@@ -31,6 +31,7 @@
static Texture* Generate();
static MAutoPtr< Texture > LoadFromFile(const MString& path);
static MAutoPtr< Texture > LoadDynamicTexture(const MString& name);
+ static const std::list< Texture* >& GetActiveTextures() { return m_activeTextures; }
void SetRawData(RawImageData* raw);
private:
@@ -44,8 +45,10 @@
uint32_t m_textureResource;
static bool m_initTextureSuccess;
- static uint8_t m_activeTextures;
+ static uint8_t m_numActiveTextures;
static uint32_t m_textureBinds;
+ static std::list< Texture* > m_activeTextures;
+
// MString m_filename;
};
Modified: Mercury2/src/X11Window.cpp
===================================================================
--- Mercury2/src/X11Window.cpp 2009-06-21 13:49:48 UTC (rev 357)
+++ Mercury2/src/X11Window.cpp 2009-06-23 00:23:23 UTC (rev 358)
@@ -77,6 +77,8 @@
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glEnable(GL_NORMALIZE);
+
+ glEnable (GL_BLEND); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
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-21 14:01:13
|
Revision: 357
http://hgengine.svn.sourceforge.net/hgengine/?rev=357&view=rev
Author: axlecrusher
Date: 2009-06-21 13:49:48 +0000 (Sun, 21 Jun 2009)
Log Message:
-----------
don't use pair
Modified Paths:
--------------
Mercury2/src/Shader.cpp
Mercury2/src/Shader.h
Modified: Mercury2/src/Shader.cpp
===================================================================
--- Mercury2/src/Shader.cpp 2009-06-21 13:06:46 UTC (rev 356)
+++ Mercury2/src/Shader.cpp 2009-06-21 13:49:48 UTC (rev 357)
@@ -327,7 +327,7 @@
buffer[bufflen] = 0;
// m_uniforms[buffer] = glGetUniformLocationARB( iProgramID, buffer );
int location = glGetUniformLocationARB( iProgramID, buffer );
- m_uniforms.push_back( std::pair<MString,int> (buffer, location) );
+ m_uniforms.push_back( UniformMap(buffer, location) );
}
return true;
}
@@ -411,10 +411,10 @@
GLERRORCHECK;
//set attributes here
- std::list< std::pair< MString, int > >::iterator ui = m_uniforms.begin();
+ std::list< UniformMap >::iterator ui = m_uniforms.begin();
for (;ui != m_uniforms.end(); ++ui)
{
- std::map< MString, ShaderAttribute >::iterator sai = m_globalAttributes.find( ui->first );
+ std::map< MString, ShaderAttribute >::iterator sai = m_globalAttributes.find( ui->name );
if (sai != m_globalAttributes.end())
{
SetAttributeInternal(sai->first, sai->second);
@@ -432,9 +432,9 @@
{
if ( !iProgramID ) return -1;
- std::list< std::pair< MString, int > >::iterator i = m_uniforms.begin();
+ std::list< UniformMap >::iterator i = m_uniforms.begin();
for (;i != m_uniforms.end(); ++i)
- if (i->first == n) return i->second;
+ if (i->name == n) return i->id;
return -1;
}
Modified: Mercury2/src/Shader.h
===================================================================
--- Mercury2/src/Shader.h 2009-06-21 13:06:46 UTC (rev 356)
+++ Mercury2/src/Shader.h 2009-06-21 13:49:48 UTC (rev 357)
@@ -50,6 +50,16 @@
std::map< MString, ShaderAttribute * > m_AllShaderAttributes;
};
+class UniformMap
+{
+ public:
+ UniformMap(MString n, int i)
+ :name(n), id(i)
+ {}
+ MString name;
+ int id;
+};
+
///Basic element for turning shaders on and off
/** This class helps aide in the loading and use of shaders. It allows loading of files
through the LoadShader() function that actively looks for .frag and .vert files. By use
@@ -150,7 +160,7 @@
/** 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;
+ std::list< UniformMap > 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-21 13:06:47
|
Revision: 356
http://hgengine.svn.sourceforge.net/hgengine/?rev=356&view=rev
Author: axlecrusher
Date: 2009-06-21 13:06:46 +0000 (Sun, 21 Jun 2009)
Log Message:
-----------
unneeded
Modified Paths:
--------------
Mercury2/src/Shader.cpp
Mercury2/src/Shader.h
Modified: Mercury2/src/Shader.cpp
===================================================================
--- Mercury2/src/Shader.cpp 2009-06-21 02:57:59 UTC (rev 355)
+++ Mercury2/src/Shader.cpp 2009-06-21 13:06:46 UTC (rev 356)
@@ -11,8 +11,7 @@
REGISTER_ASSET_TYPE( Shader );
-ShaderAttributesSet SHADERATTRIBUTES;
-Shader * Shader::CurrentShader;
+Shader * Shader::CurrentShader = NULL;
ShaderAttribute * ShaderAttributesSet::GetHandle( const MString & sName )
{
Modified: Mercury2/src/Shader.h
===================================================================
--- Mercury2/src/Shader.h 2009-06-21 02:57:59 UTC (rev 355)
+++ Mercury2/src/Shader.h 2009-06-21 13:06:46 UTC (rev 356)
@@ -50,8 +50,6 @@
std::map< MString, ShaderAttribute * > m_AllShaderAttributes;
};
-extern ShaderAttributesSet SHADERATTRIBUTES;
-
///Basic element for turning shaders on and off
/** This class helps aide in the loading and use of shaders. It allows loading of files
through the LoadShader() function that actively looks for .frag and .vert files. By use
@@ -161,7 +159,7 @@
float fPriority;
///Global static shader (so shaders can recursively activate and deactivate shaders)
- static Shader * CurrentShader;
+ static Shader* CurrentShader;
///Original Shader (to re-enable when leaving)
Shader * OriginalShader;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2009-06-21 02:58:00
|
Revision: 355
http://hgengine.svn.sourceforge.net/hgengine/?rev=355&view=rev
Author: cnlohr
Date: 2009-06-21 02:57:59 +0000 (Sun, 21 Jun 2009)
Log Message:
-----------
tweak cnconfigure to make the debugging output a little more useful.
Modified Paths:
--------------
Mercury2/cnconfigure
Modified: Mercury2/cnconfigure
===================================================================
--- Mercury2/cnconfigure 2009-06-21 02:07:05 UTC (rev 354)
+++ Mercury2/cnconfigure 2009-06-21 02:57:59 UTC (rev 355)
@@ -184,8 +184,8 @@
LDFLAGS="$LDFLAGS $LD_BASE"
-echo "Final compile line: cc \$(CC_BASE) \$(CFLAGS) -c -o \$@ \$<"
-echo "Final link line: g++ -o \$@ \$^ \$(LDFLAGS)"
+echo "Final compile line: cc ${CC_BASE} ${CFLAGS} -c -o \$@ \$<"
+echo "Final link line: g++ -o \$@ \$^ ${LDFLAGS}"
echo "PROJ=$PROJ" >> Makefile
echo "CFLAGS=$CC_BASE $CFLAGS" >> Makefile
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-06-21 02:53:20
|
Revision: 353
http://hgengine.svn.sourceforge.net/hgengine/?rev=353&view=rev
Author: axlecrusher
Date: 2009-06-21 01:54:13 +0000 (Sun, 21 Jun 2009)
Log Message:
-----------
remove
Removed Paths:
-------------
Mercury2/src/RenderableNode.cpp
Mercury2/src/RenderableNode.h
Deleted: Mercury2/src/RenderableNode.cpp
===================================================================
--- Mercury2/src/RenderableNode.cpp 2009-06-21 01:52:15 UTC (rev 352)
+++ Mercury2/src/RenderableNode.cpp 2009-06-21 01:54:13 UTC (rev 353)
@@ -1,188 +0,0 @@
-#include <RenderableNode.h>
-#include <assert.h>
-#include <GLHeaders.h>
-#include <TransformNode.h>
-//#include <unistd.h>
-#include <Viewport.h>
-
-using namespace std;
-
-REGISTER_NODE_TYPE(RenderableNode);
-
-RenderableNode::RenderableNode()
- :m_hidden(false)
-{
-}
-
-RenderableNode::~RenderableNode()
-{
- m_prerender.clear();
- m_render.clear();
- m_postrender.clear();
-}
-
-void RenderableNode::Update(float dTime)
-{
- /*
- MercuryMatrix m = FindGlobalMatrix();
-
- std::list< MAutoPtr< MercuryAsset > >::iterator i;
- for (i = m_assets.begin(); i != m_assets.end(); ++i )
- {
- const BoundingVolume* v = (*i)->GetBoundingVolume();
- if (v)
- {
- BoundingVolume* nv = v->SpawnClone();
- nv->Transform(m);
- SAFE_DELETE(nv);
- //do some stuff to figure out if this node is culled
- }
- }
- */
-}
-
-void RenderableNode::PreRender(const MercuryMatrix& matrix)
-{
- list< MercuryAsset* >::iterator i;
- for (i = m_prerender.begin(); i != m_prerender.end(); ++i )
- (*i)->PreRender(this);
-}
-
-void RenderableNode::Render(const MercuryMatrix& matrix)
-{
- list< MercuryAsset* >::iterator i;
- for (i = m_render.begin(); i != m_render.end(); ++i )
- (*i)->Render(this);
-}
-
-void RenderableNode::PostRender(const MercuryMatrix& matrix)
-{
- list< MercuryAsset* >::iterator i;
- for (i = m_postrender.begin(); i != m_postrender.end(); ++i )
- (*i)->PostRender(this);
-}
-
-const MercuryMatrix& RenderableNode::FindGlobalMatrix() const
-{
- MercuryNode* n = NULL;
- TransformNode* tn;
- for (n = Parent(); n; n = n->Parent())
- {
- tn = TransformNode::Cast(n);
- if ( tn )
- return tn->GetGlobalMatrix();
- }
-
- return MercuryMatrix::Identity();
-}
-
-void RenderableNode::AddPreRender(MercuryAsset* asset)
-{
-#ifdef MCHECKASSETS
- if ( !IsInAssetList(asset) ) //yell and scream
- assert(!"Asset does not exist in list!");
-#endif
-
- m_prerender.push_back(asset);
-}
-
-void RenderableNode::AddRender(MercuryAsset* asset)
-{
-#ifdef MCHECKASSETS
- if ( !IsInAssetList(asset) ) //yell and scream
- assert(!"Asset does not exist in list!");
-#endif
-
- m_render.push_back(asset);
-}
-void RenderableNode::AddPostRender(MercuryAsset* asset)
-{
-#ifdef MCHECKASSETS
- if ( !IsInAssetList(asset) ) //yell and scream
- assert(!"Asset does not exist in list!");
-#endif
-
- m_postrender.push_back(asset);
-}
-
-bool RenderableNode::IsInAssetList( MercuryAsset* asset ) const
-{
- std::list< MAutoPtr< MercuryAsset > >::const_iterator i;
- for (i = m_assets.begin(); i != m_assets.end(); ++i )
- if ( (*i) == asset ) return true;
- return false;
-}
-
-void RenderableNode::LoadFromXML(const XMLNode& node)
-{
- if ( !node.Attribute("hidden").empty() )
- m_hidden = node.Attribute("hidden")=="true"?true:false;
-
- for (XMLNode child = node.Child(); child.IsValid(); child = child.NextNode())
- {
- if ( child.Name() == "asset" )
- {
- MString key = child.Attribute("file");
- MAutoPtr< MercuryAsset > asset( AssetFactory::GetInstance().Generate( child.Attribute("type"), key ) );
- if ( asset.IsValid() )
- {
- asset->LoadFromXML( child );
- this->AddAsset( asset );
- asset->Init( this );
- }
- }
- }
-
- MercuryNode::LoadFromXML( node );
-}
-
-bool RenderableNode::IsCulled(const MercuryMatrix& matrix)
-{
- bool clip = false;
-
- std::list< MAutoPtr< MercuryAsset > >::iterator i;
- for (i = m_assets.begin(); i != m_assets.end(); ++i )
- {
- const BoundingVolume* bv = (*i)->GetBoundingVolume();
- if (bv)
- {
- BoundingVolume* v = bv->SpawnClone();
- v->Transform( matrix );
- clip = v->Clip( *FRUSTUM );
- delete v;
- if ( clip == false ) return false;
- }
- else
- return false;
- }
- return clip;
-}
-
-MercuryMatrix RenderableNode::ManipulateMatrix(const MercuryMatrix& matrix)
-{
- return VIEWMATRIX * matrix;
-}
-
-/***************************************************************************
- * Copyright (C) 2008 by Joshua Allen *
- * *
- * *
- * All rights reserved. *
- * *
- * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: *
- * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. *
- * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. *
- * * Neither the name of the <ORGANIZATION> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. *
- * *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR *
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
- ***************************************************************************/
Deleted: Mercury2/src/RenderableNode.h
===================================================================
--- Mercury2/src/RenderableNode.h 2009-06-21 01:52:15 UTC (rev 352)
+++ Mercury2/src/RenderableNode.h 2009-06-21 01:54:13 UTC (rev 353)
@@ -1,83 +0,0 @@
-#ifndef RENDERABLENODE_H
-#define RENDERABLENODE_H
-
-#include <MercuryNode.h>
-#include <MAutoPtr.h>
-#include <MercuryAsset.h>
-#include <MercuryMatrix.h>
-#include <MSemaphore.h>
-#include <Mint.h>
-
-#define MCHECKASSETS
-
-class RenderableNode : public MercuryNode
-{
- public:
- RenderableNode();
- ~RenderableNode();
-
- virtual void Update(float dTime);
-
- inline void AddAsset(MAutoPtr< MercuryAsset > asset) { m_assets.push_back(asset); }
-
- void AddPreRender(MercuryAsset* asset);
- void AddRender(MercuryAsset* asset);
- void AddPostRender(MercuryAsset* asset);
-
- ///This will get the world space matrix
- virtual void PreRender(const MercuryMatrix& matrix);
-
- virtual void Render(const MercuryMatrix& matrix);
-
- virtual void PostRender(const MercuryMatrix& matrix);
-
- virtual void LoadFromXML(const XMLNode& node);
-
- const MercuryMatrix& FindGlobalMatrix() const;
-
- virtual bool IsCulled(const MercuryMatrix& matrix);
- bool IsHidden() { return m_hidden; }
-
- virtual MercuryMatrix ManipulateMatrix(const MercuryMatrix& matrix);
-
- GENRTTI(RenderableNode);
- protected:
- bool m_hidden;
- private:
- bool IsInAssetList(MercuryAsset* asset) const;
-
- //The asset is actually stored here
- std::list< MAutoPtr< MercuryAsset > > m_assets;
-
- //we will just use normal pointers here because we don't want to waste too much time
- //dereferencing the autopointer. As a precaution when assets are added to these lists,
- //they must exist in m_assets.
- std::list< MercuryAsset* > m_prerender;
- std::list< MercuryAsset* > m_render;
- std::list< MercuryAsset* > m_postrender;
-};
-
-#endif
-/***************************************************************************
- * Copyright (C) 2008 by Joshua Allen *
- * *
- * *
- * All rights reserved. *
- * *
- * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: *
- * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. *
- * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. *
- * * Neither the name of the <ORGANIZATION> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. *
- * *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR *
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
- ***************************************************************************/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-06-21 02:53:19
|
Revision: 351
http://hgengine.svn.sourceforge.net/hgengine/?rev=351&view=rev
Author: axlecrusher
Date: 2009-06-21 01:49:41 +0000 (Sun, 21 Jun 2009)
Log Message:
-----------
no more renderable node
Modified Paths:
--------------
Mercury2/adv_set.c
Mercury2/scenegraph.xml
Modified: Mercury2/adv_set.c
===================================================================
--- Mercury2/adv_set.c 2009-06-21 01:49:14 UTC (rev 350)
+++ Mercury2/adv_set.c 2009-06-21 01:49:41 UTC (rev 351)
@@ -4,7 +4,7 @@
SOURCES="src/Mercury2.cpp src/MercuryAsset.cpp src/MercuryNode.cpp \
- src/MercuryThreads.cpp src/MercuryMath.cpp src/MercuryWindow.cpp src/RenderableNode.cpp \
+ src/MercuryThreads.cpp src/MercuryMath.cpp src/MercuryWindow.cpp\
src/TransformNode.cpp src/MercuryMatrix.cpp src/Viewport.cpp src/Quad.cpp src/MercuryUtil.cpp \
src/Texture.cpp src/RawImageData.cpp src/BMPLoader.cpp src/PNGLoader.cpp src/ImageLoader.cpp \
src/MercuryVBO.cpp src/MSemaphore.cpp src/UpdateThreader.cpp src/HGMDLMesh.cpp \
Modified: Mercury2/scenegraph.xml
===================================================================
--- Mercury2/scenegraph.xml 2009-06-21 01:49:14 UTC (rev 350)
+++ Mercury2/scenegraph.xml 2009-06-21 01:49:41 UTC (rev 351)
@@ -1,46 +1,40 @@
-<SceneGraph>
+<SceneGraph name="root">
<!-- <node type="cameranode" movx="6" movz="-5.5" movy="3" rotx="-45" roty="90">
<node type="viewport" fov="45" aspect="1.3333" near="0.01" far="100"/>
</node>
-->
- <node type="cameranode" movx="0" movz="0" movy="0" rotx="0" roty="0" rotz="0">
- <node type="viewport" fov="45" aspect="1.3333" near="0.01" far="100"/>
+ <node type="cameranode" movx="0" movz="0" movy="0" rotx="0" roty="0" rotz="0" name="camera">
+ <node type="viewport" fov="45" aspect="1.3333" near="0.01" far="100" name="vp"/>
</node>
- <node type="renderablenode">
- <asset type="texture" file="screenFBO_0" dynamic="true"/>
- <asset type="fullscreenquad"/>
- </node>
- <node type="mercuryfbo" width="640" height="480" depth="true" tnum="2" name="screenFBO" usescreensize="true">
- <asset type="shader" file="testShader"/>
+<!-- <asset type="texture" file="screenFBO_0" dynamic="true"/> -->
+<!-- <asset type="fullscreenquad"/> -->
+<!-- <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">
- <asset type="texture" file="map.png"/>
- <asset type="hgmdlmodel" file="map.hgmdl" />
- </node>
+ <asset type="texture" file="map.png"/>
+ <asset type="hgmdlmodel" file="map.hgmdl" />
</node>
- <node type="renderablenode" name="lampForest">
- <asset type="texture" file="lamp.png"/>
- <node type="transformnode" movz="-5" movx="0" movy="0" name="lamprow" >
- <node type="transformnode" rotx="-90" name="lamp">
- <node type="billboardnode" billboardaxis="0,0,1" spheremode="true" >
- <node type="renderablenode">
+ <node type="mercurynode" name="lampForest" >
+ <asset type="texture" file="lamp.png"/>
+ <node type="transformnode" movz="-5" movx="0" movy="0" name="lamprow" >
+ <node type="transformnode" rotx="-90" name="lamp">
+ <node type="billboardnode" billboardaxis="0,0,1" spheremode="true" >
<asset type="hgmdlmodel" file="lampN.hgmdl" />
</node>
</node>
+ <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" 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"/>
<node type="transformnode" movz="-8" fallback="lampForest.lamprow"/>
<node type="transformnode" movz="-9" fallback="lampForest.lamprow"/>
<node type="transformnode" movz="-4" fallback="lampForest.lamprow"/>
<node type="transformnode" movz="-3" fallback="lampForest.lamprow"/>
- </node>
- </node>
+ </node>-->
+<!-- </node> -->
</SceneGraph>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-06-21 02:53:13
|
Revision: 349
http://hgengine.svn.sourceforge.net/hgengine/?rev=349&view=rev
Author: axlecrusher
Date: 2009-06-21 01:44:12 +0000 (Sun, 21 Jun 2009)
Log Message:
-----------
optimize
Modified Paths:
--------------
Mercury2/testShader.frag
Modified: Mercury2/testShader.frag
===================================================================
--- Mercury2/testShader.frag 2009-06-21 00:50:41 UTC (rev 348)
+++ Mercury2/testShader.frag 2009-06-21 01:44:12 UTC (rev 349)
@@ -4,5 +4,6 @@
void main()
{
// gl_FragData[0] = texture2D(HG_Texture0, gl_TexCoord[0].st);
- gl_FragData[0].rgb = (normalize(normal)+1.0)/2.0;
+ vec3 n = normalize(normal);
+ gl_FragData[0].rgb = 0.5 + 0.5 * n;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-06-21 02:53:11
|
Revision: 352
http://hgengine.svn.sourceforge.net/hgengine/?rev=352&view=rev
Author: axlecrusher
Date: 2009-06-21 01:52:15 +0000 (Sun, 21 Jun 2009)
Log Message:
-----------
back to where we were before the removal of renderablenode
Modified Paths:
--------------
Mercury2/scenegraph.xml
Modified: Mercury2/scenegraph.xml
===================================================================
--- Mercury2/scenegraph.xml 2009-06-21 01:49:41 UTC (rev 351)
+++ Mercury2/scenegraph.xml 2009-06-21 01:52:15 UTC (rev 352)
@@ -6,35 +6,35 @@
<node type="cameranode" movx="0" movz="0" movy="0" rotx="0" roty="0" rotz="0" name="camera">
<node type="viewport" fov="45" aspect="1.3333" near="0.01" far="100" name="vp"/>
</node>
-<!-- <asset type="texture" file="screenFBO_0" dynamic="true"/> -->
-<!-- <asset type="fullscreenquad"/> -->
-<!-- <node type="mercuryfbo" width="640" height="480" depth="true" tnum="2" name="screenFBO" usescreensize="true"> -->
-<!-- <asset type="shader" file="testShader"/> -->
+ <asset type="texture" file="screenFBO_0" dynamic="true"/>
+ <asset type="fullscreenquad"/>
+ <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">
<asset type="texture" file="map.png"/>
<asset type="hgmdlmodel" file="map.hgmdl" />
</node>
<node type="mercurynode" name="lampForest" >
- <asset type="texture" file="lamp.png"/>
- <node type="transformnode" movz="-5" movx="0" movy="0" name="lamprow" >
- <node type="transformnode" rotx="-90" name="lamp">
- <node type="billboardnode" billboardaxis="0,0,1" spheremode="true" >
- <asset type="hgmdlmodel" file="lampN.hgmdl" />
- </node>
+ <asset type="texture" file="lamp.png"/>
+ <node type="transformnode" movz="-5" movx="0" movy="0" name="lamprow" >
+ <node type="transformnode" rotx="-90" name="lamp">
+ <node type="billboardnode" billboardaxis="0,0,1" spheremode="true" >
+ <asset type="hgmdlmodel" file="lampN.hgmdl" />
</node>
- <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" 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"/>
<node type="transformnode" movz="-8" fallback="lampForest.lamprow"/>
<node type="transformnode" movz="-9" fallback="lampForest.lamprow"/>
<node type="transformnode" movz="-4" fallback="lampForest.lamprow"/>
<node type="transformnode" movz="-3" fallback="lampForest.lamprow"/>
- </node>-->
-<!-- </node> -->
+ </node>
+ </node>
</SceneGraph>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-06-21 02:53:08
|
Revision: 350
http://hgengine.svn.sourceforge.net/hgengine/?rev=350&view=rev
Author: axlecrusher
Date: 2009-06-21 01:49:14 +0000 (Sun, 21 Jun 2009)
Log Message:
-----------
no more renderable node
Modified Paths:
--------------
Mercury2/src/BoundingBox.h
Mercury2/src/Mercury2.cpp
Mercury2/src/MercuryAsset.cpp
Mercury2/src/MercuryAsset.h
Mercury2/src/MercuryFBO.cpp
Mercury2/src/MercuryFBO.h
Mercury2/src/MercuryNode.cpp
Mercury2/src/MercuryNode.h
Mercury2/src/RenderGraph.cpp
Mercury2/src/RenderGraph.h
Mercury2/src/Shader.cpp
Mercury2/src/Texture.cpp
Mercury2/src/Viewport.cpp
Mercury2/src/Viewport.h
Modified: Mercury2/src/BoundingBox.h
===================================================================
--- Mercury2/src/BoundingBox.h 2009-06-21 01:44:12 UTC (rev 349)
+++ Mercury2/src/BoundingBox.h 2009-06-21 01:49:14 UTC (rev 350)
@@ -1,7 +1,7 @@
#ifndef BOUNDINGBOX_H
#define BOUNDINGBOX_H
-#include <MercuryNode.h>
+//#include <MercuryNode.h>
#include <MercuryVertex.h>
#include <MercuryMatrix.h>
#include <Frustum.h>
Modified: Mercury2/src/Mercury2.cpp
===================================================================
--- Mercury2/src/Mercury2.cpp 2009-06-21 01:44:12 UTC (rev 349)
+++ Mercury2/src/Mercury2.cpp 2009-06-21 01:49:14 UTC (rev 350)
@@ -1,12 +1,12 @@
#include <MercuryWindow.h>
#include <Quad.h>
-#include <RenderableNode.h>
+//#include <RenderableNode.h>
#include <Viewport.h>
#include <TransformNode.h>
#include <XMLParser.h>
-#include <RenderableNode.h>
+//#include <RenderableNode.h>
#include <MercuryCrash.h>
#include <MercuryBacktrace.h>
@@ -82,8 +82,10 @@
}
w->Clear();
- renderGraph.Render();
+// renderGraph.Render();
// RenderableNode::RecursiveRender(root);
+// printf("\n");
+ root->RecursiveRender();
w->SwapBuffers();
++m_count;
Modified: Mercury2/src/MercuryAsset.cpp
===================================================================
--- Mercury2/src/MercuryAsset.cpp 2009-06-21 01:44:12 UTC (rev 349)
+++ Mercury2/src/MercuryAsset.cpp 2009-06-21 01:49:14 UTC (rev 350)
@@ -1,6 +1,6 @@
#include <MercuryAsset.h>
-#include <RenderableNode.h>
-
+//#include <RenderableNode.h>
+#include <MercuryNode.h>
#include <GLHeaders.h>
MercuryAsset::MercuryAsset()
@@ -15,9 +15,8 @@
void MercuryAsset::Init(MercuryNode* node)
{
- RenderableNode* rn;
- if ( (rn=RenderableNode::Cast( node )) )
- rn->AddRender(this);
+// RenderableNode* rn;
+ if ( node ) node->AddRender(this);
}
void MercuryAsset::SetLoadState(LoadState ls)
Modified: Mercury2/src/MercuryAsset.h
===================================================================
--- Mercury2/src/MercuryAsset.h 2009-06-21 01:44:12 UTC (rev 349)
+++ Mercury2/src/MercuryAsset.h 2009-06-21 01:49:14 UTC (rev 350)
@@ -2,13 +2,16 @@
#define MERCURYASSET_H
#include <MAutoPtr.h>
-#include <MercuryNode.h>
#include <MessageHandler.h>
-#include <map>
#include <MercuryMatrix.h>
#include <BoundingBox.h>
#include <MSemaphore.h>
+#include <XMLParser.h>
+#include <Callback.h>
+#include <map>
+#include <list>
+
enum LoadState
{
LOADING,
@@ -16,6 +19,8 @@
NONE
};
+class MercuryNode;
+
/* Assets are stored in renderable nodes with MAuto pointers.
The renderable nodes handle the memory management
*/
Modified: Mercury2/src/MercuryFBO.cpp
===================================================================
--- Mercury2/src/MercuryFBO.cpp 2009-06-21 01:44:12 UTC (rev 349)
+++ Mercury2/src/MercuryFBO.cpp 2009-06-21 01:49:14 UTC (rev 350)
@@ -97,7 +97,7 @@
GLERRORCHECK;
}
- RenderableNode::PreRender(matrix);
+ MercuryNode::PreRender(matrix);
}
void MercuryFBO::Render(const MercuryMatrix& matrix)
@@ -117,7 +117,7 @@
if ( !m_useScreenSize ) glViewport(0,0,m_width, m_height);
GLERRORCHECK;
- RenderableNode::Render(matrix);
+ MercuryNode::Render(matrix);
GLERRORCHECK;
}
@@ -125,7 +125,7 @@
{
glPopAttrib();
- RenderableNode::PostRender(matrix);
+ MercuryNode::PostRender(matrix);
// for( uint8_t i = 0; i < m_numTextures; i++ )
// {
@@ -159,7 +159,7 @@
if ( !node.Attribute("usescreensize").empty() )
m_useScreenSize = node.Attribute("usescreensize") == "true"?true:false;
- RenderableNode::LoadFromXML(node);
+ MercuryNode::LoadFromXML(node);
}
//uint32_t MercuryFBO::m_lastRendered = NULL;
Modified: Mercury2/src/MercuryFBO.h
===================================================================
--- Mercury2/src/MercuryFBO.h 2009-06-21 01:44:12 UTC (rev 349)
+++ Mercury2/src/MercuryFBO.h 2009-06-21 01:49:14 UTC (rev 350)
@@ -1,10 +1,10 @@
#ifndef MERCURYFBO_H
#define MERCURYFBO_H
-#include <RenderableNode.h>
+#include <MercuryNode.h>
#include <Texture.h>
-class MercuryFBO : public RenderableNode
+class MercuryFBO : public MercuryNode
{
public:
MercuryFBO();
Modified: Mercury2/src/MercuryNode.cpp
===================================================================
--- Mercury2/src/MercuryNode.cpp 2009-06-21 01:44:12 UTC (rev 349)
+++ Mercury2/src/MercuryNode.cpp 2009-06-21 01:49:14 UTC (rev 350)
@@ -1,13 +1,19 @@
#include <MercuryNode.h>
#include <MercuryUtil.h>
#include <UpdateThreader.h>
+#include <TransformNode.h>
+#include <Viewport.h>
+
+#include <GLHeaders.h>
+#include <Shader.h>
+
using namespace std;
REGISTER_NODE_TYPE(MercuryNode);
MercuryNode::MercuryNode()
- :m_parent(NULL), m_prevSibling(NULL), m_nextSibling(NULL)
+ :m_parent(NULL), m_prevSibling(NULL), m_nextSibling(NULL), m_hidden(false)
{
}
@@ -98,6 +104,36 @@
child->RecursiveUpdate(dTime);
}
+void MercuryNode::RecursiveRender()
+{
+ MercuryMatrix modelView;
+ ShaderAttribute sa;
+
+ MercuryMatrix matrix = FindGlobalMatrix();
+
+ PreRender( matrix ); //calls on children assets
+ modelView = ManipulateMatrix( matrix );
+ if ( IsHidden() || IsCulled(modelView) ) return;
+ modelView.Transpose();
+
+ glLoadMatrixf( modelView.Ptr() );
+
+ sa.type = ShaderAttribute::TYPE_MATRIX;
+ sa.value.matrix = matrix.Ptr();
+ Shader::SetAttribute("HG_ModelMatrix", sa);
+
+ Render( modelView ); //calls on children assets
+
+ //call render on other render graph entries under me
+ std::list< MercuryNode* >::iterator i;
+ for (i = m_children.begin(); i != m_children.end(); ++i )
+ (*i)->RecursiveRender();
+
+ glLoadMatrixf( modelView.Ptr() );
+ Shader::SetAttribute("HG_ModelMatrix", sa);
+ PostRender( modelView ); //calls on children assets
+}
+
void MercuryNode::ThreadedUpdate(float dTime)
{
//XXX EXPERIMENTAL
@@ -111,6 +147,10 @@
void MercuryNode::LoadFromXML(const XMLNode& node)
{
SetName( node.Attribute("name") );
+
+ if ( !node.Attribute("hidden").empty() )
+ m_hidden = node.Attribute("hidden")=="true"?true:false;
+
//Not much to do here except run through all the children nodes
for (XMLNode child = node.Child(); child.IsValid(); child = child.NextNode())
{
@@ -121,9 +161,121 @@
node->LoadFromXML( child );
this->AddChild( node );
}
+ else if ( child.Name() == "asset" )
+ {
+ MString key = child.Attribute("file");
+ MAutoPtr< MercuryAsset > asset( AssetFactory::GetInstance().Generate( child.Attribute("type"), key ) );
+ if ( asset.IsValid() )
+ {
+ asset->LoadFromXML( child );
+ this->AddAsset( asset );
+ asset->Init( this );
+ }
+ }
}
}
+
+void MercuryNode::PreRender(const MercuryMatrix& matrix)
+{
+ list< MercuryAsset* >::iterator i;
+ for (i = m_prerender.begin(); i != m_prerender.end(); ++i )
+ (*i)->PreRender(this);
+}
+
+void MercuryNode::Render(const MercuryMatrix& matrix)
+{
+ list< MercuryAsset* >::iterator i;
+ for (i = m_render.begin(); i != m_render.end(); ++i )
+ (*i)->Render(this);
+}
+
+void MercuryNode::PostRender(const MercuryMatrix& matrix)
+{
+ list< MercuryAsset* >::iterator i;
+ for (i = m_postrender.begin(); i != m_postrender.end(); ++i )
+ (*i)->PostRender(this);
+}
+
+const MercuryMatrix& MercuryNode::FindGlobalMatrix() const
+{
+ const MercuryNode* n = NULL;
+ const TransformNode* tn;
+ for (n = this; n; n = n->Parent())
+ {
+ tn = TransformNode::Cast(n);
+ if ( tn )
+ return tn->GetGlobalMatrix();
+ }
+
+ return MercuryMatrix::Identity();
+}
+
+void MercuryNode::AddPreRender(MercuryAsset* asset)
+{
+#ifdef MCHECKASSETS
+ if ( !IsInAssetList(asset) ) //yell and scream
+ assert(!"Asset does not exist in list!");
+#endif
+
+ m_prerender.push_back(asset);
+}
+
+void MercuryNode::AddRender(MercuryAsset* asset)
+{
+#ifdef MCHECKASSETS
+ if ( !IsInAssetList(asset) ) //yell and scream
+ assert(!"Asset does not exist in list!");
+#endif
+
+ m_render.push_back(asset);
+}
+void MercuryNode::AddPostRender(MercuryAsset* asset)
+{
+#ifdef MCHECKASSETS
+ if ( !IsInAssetList(asset) ) //yell and scream
+ assert(!"Asset does not exist in list!");
+#endif
+
+ m_postrender.push_back(asset);
+}
+
+bool MercuryNode::IsInAssetList( MercuryAsset* asset ) const
+{
+ std::list< MAutoPtr< MercuryAsset > >::const_iterator i;
+ for (i = m_assets.begin(); i != m_assets.end(); ++i )
+ if ( (*i) == asset ) return true;
+ return false;
+}
+
+bool MercuryNode::IsCulled(const MercuryMatrix& matrix)
+{
+ bool clip = false;
+
+ std::list< MAutoPtr< MercuryAsset > >::iterator i;
+ for (i = m_assets.begin(); i != m_assets.end(); ++i )
+ {
+ const BoundingVolume* bv = (*i)->GetBoundingVolume();
+ if (bv)
+ {
+ BoundingVolume* v = bv->SpawnClone();
+ v->Transform( matrix );
+ clip = v->Clip( *FRUSTUM );
+ delete v;
+ if ( clip == false ) return false;
+ }
+ else
+ return false;
+ }
+ return clip;
+}
+
+MercuryMatrix MercuryNode::ManipulateMatrix(const MercuryMatrix& matrix)
+{
+ return VIEWMATRIX * matrix;
+}
+
+
NodeFactory& NodeFactory::GetInstance()
{
static NodeFactory* instance = NULL;
Modified: Mercury2/src/MercuryNode.h
===================================================================
--- Mercury2/src/MercuryNode.h 2009-06-21 01:44:12 UTC (rev 349)
+++ Mercury2/src/MercuryNode.h 2009-06-21 01:49:14 UTC (rev 350)
@@ -8,6 +8,8 @@
#include <MercuryUtil.h>
#include <MessageHandler.h>
+#include <MercuryAsset.h>
+
/** This is the basic node of the scene graph. It is not intended to be instanced.
Each node exists as a single entity in the scene graph.
**/
@@ -44,6 +46,9 @@
virtual void RecursiveUpdate(float dTime);
void ThreadedUpdate(float dTime);
+
+ void RecursiveRender();
+
///Run on parent when a child is added
virtual void OnAddChild() {};
@@ -65,6 +70,25 @@
inline void SetName(const MString& name) { m_name = name; }
inline MString GetName() const { return m_name; }
+ inline void AddAsset(MAutoPtr< MercuryAsset > asset) { m_assets.push_back(asset); }
+
+ void AddPreRender(MercuryAsset* asset);
+ void AddRender(MercuryAsset* asset);
+ void AddPostRender(MercuryAsset* asset);
+
+ virtual void PreRender(const MercuryMatrix& matrix);
+ virtual void Render(const MercuryMatrix& matrix);
+ virtual void PostRender(const MercuryMatrix& matrix);
+
+ ///This will get the world space matrix
+ const MercuryMatrix& FindGlobalMatrix() const;
+
+ virtual bool IsCulled(const MercuryMatrix& matrix);
+ bool IsHidden() { return m_hidden; }
+
+ virtual MercuryMatrix ManipulateMatrix(const MercuryMatrix& matrix);
+
+
protected:
std::list< MercuryNode* > m_children; //These nodes are unique, not instanced
MercuryNode* m_parent;
@@ -73,7 +97,19 @@
static bool m_rebuildRenderGraph;
MString m_name;
-
+ bool m_hidden;
+ private:
+ bool IsInAssetList(MercuryAsset* asset) const;
+
+ //The asset is actually stored here
+ std::list< MAutoPtr< MercuryAsset > > m_assets;
+
+ //we will just use normal pointers here because we don't want to waste too much time
+ //dereferencing the autopointer. As a precaution when assets are added to these lists,
+ //they must exist in m_assets.
+ std::list< MercuryAsset* > m_prerender;
+ std::list< MercuryAsset* > m_render;
+ std::list< MercuryAsset* > m_postrender;
};
class NodeFactory
Modified: Mercury2/src/RenderGraph.cpp
===================================================================
--- Mercury2/src/RenderGraph.cpp 2009-06-21 01:44:12 UTC (rev 349)
+++ Mercury2/src/RenderGraph.cpp 2009-06-21 01:49:14 UTC (rev 350)
@@ -49,12 +49,12 @@
void RenderGraph::Build( MercuryNode* node, RenderGraphEntry& entry)
{
RenderGraphEntry* lastEntry = &entry;
- RenderableNode* rn = RenderableNode::Cast(node);
+// MercuryNode* rn = MercuryNode::Cast(node);
- if ( rn )
+ if ( node )
{
//found a new renderable
- entry.m_children.push_back( RenderGraphEntry(&rn->FindGlobalMatrix(), rn) );
+ entry.m_children.push_back( RenderGraphEntry(&(node->FindGlobalMatrix()), node) );
lastEntry = &(entry.m_children.back());
}
Modified: Mercury2/src/RenderGraph.h
===================================================================
--- Mercury2/src/RenderGraph.h 2009-06-21 01:44:12 UTC (rev 349)
+++ Mercury2/src/RenderGraph.h 2009-06-21 01:49:14 UTC (rev 350)
@@ -2,7 +2,7 @@
#define RENDERGRAPH_H
#include <MercuryNode.h>
-#include <RenderableNode.h>
+//#include <RenderableNode.h>
class RenderGraphEntry
{
@@ -14,14 +14,14 @@
m_matrix = &MercuryMatrix::Identity();
}
- RenderGraphEntry(const MercuryMatrix* matrix, RenderableNode* node)
+ RenderGraphEntry(const MercuryMatrix* matrix, MercuryNode* node)
:m_node(node), m_matrix(matrix)
{}
void AddChild(RenderGraphEntry entry);
void Render();
private:
- RenderableNode* m_node; //we don't own this, no new or free
+ MercuryNode* m_node; //we don't own this, no new or free
std::list< RenderGraphEntry > m_children;
const MercuryMatrix* m_matrix;
};
Modified: Mercury2/src/Shader.cpp
===================================================================
--- Mercury2/src/Shader.cpp 2009-06-21 01:44:12 UTC (rev 349)
+++ Mercury2/src/Shader.cpp 2009-06-21 01:49:14 UTC (rev 350)
@@ -1,5 +1,5 @@
#include <Shader.h>
-#include <RenderableNode.h>
+#include <MercuryNode.h>
#include <MercuryFile.h>
#include <GLHeaders.h>
@@ -44,9 +44,8 @@
void Shader::Init(MercuryNode* node)
{
MercuryAsset::Init( node );
- RenderableNode* rn = RenderableNode::Cast( node );
- if ( rn )
- rn->AddPostRender( this );
+// RenderableNode* rn = RenderableNode::Cast( node );
+ if ( node ) node->AddPostRender( this );
}
void Shader::Render(const MercuryNode* node)
Modified: Mercury2/src/Texture.cpp
===================================================================
--- Mercury2/src/Texture.cpp 2009-06-21 01:44:12 UTC (rev 349)
+++ Mercury2/src/Texture.cpp 2009-06-21 01:49:14 UTC (rev 350)
@@ -1,7 +1,7 @@
#include <Texture.h>
-#include <RenderableNode.h>
+//#include <RenderableNode.h>
#include <ImageLoader.h>
-
+#include <MercuryNode.h>
#include <GLHeaders.h>
#include <Shader.h>
@@ -38,9 +38,8 @@
{
MercuryAsset::Init( node );
- RenderableNode* rn = RenderableNode::Cast( node );
- if ( rn )
- rn->AddPostRender( this );
+// RenderableNode* rn = RenderableNode::Cast( node );
+ if ( node ) node->AddPostRender( this );
}
void Texture::LoadFromRaw()
Modified: Mercury2/src/Viewport.cpp
===================================================================
--- Mercury2/src/Viewport.cpp 2009-06-21 01:44:12 UTC (rev 349)
+++ Mercury2/src/Viewport.cpp 2009-06-21 01:49:14 UTC (rev 350)
@@ -65,7 +65,7 @@
StrToFloat(node.Attribute("near")),
StrToFloat(node.Attribute("far")));
- RenderableNode::LoadFromXML(node);
+ MercuryNode::LoadFromXML(node);
}
Modified: Mercury2/src/Viewport.h
===================================================================
--- Mercury2/src/Viewport.h 2009-06-21 01:44:12 UTC (rev 349)
+++ Mercury2/src/Viewport.h 2009-06-21 01:49:14 UTC (rev 350)
@@ -1,7 +1,7 @@
#ifndef VIEWPORT_H
#define VIEWPORT_H
-#include <RenderableNode.h>
+#include <MercuryNode.h>
#include <MercuryMatrix.h>
#include <MercuryVertex.h>
#include <MercuryPlane.h>
@@ -12,7 +12,7 @@
extern MercuryVertex EYE;
extern MercuryVector LOOKAT;
-class Viewport : public RenderableNode
+class Viewport : public MercuryNode
{
public:
Viewport();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-06-21 02:07:07
|
Revision: 354
http://hgengine.svn.sourceforge.net/hgengine/?rev=354&view=rev
Author: axlecrusher
Date: 2009-06-21 02:07:05 +0000 (Sun, 21 Jun 2009)
Log Message:
-----------
use faster methods
Modified Paths:
--------------
Mercury2/src/MercuryNode.cpp
Modified: Mercury2/src/MercuryNode.cpp
===================================================================
--- Mercury2/src/MercuryNode.cpp 2009-06-21 01:54:13 UTC (rev 353)
+++ Mercury2/src/MercuryNode.cpp 2009-06-21 02:07:05 UTC (rev 354)
@@ -125,9 +125,8 @@
Render( modelView ); //calls on children assets
//call render on other render graph entries under me
- std::list< MercuryNode* >::iterator i;
- for (i = m_children.begin(); i != m_children.end(); ++i )
- (*i)->RecursiveRender();
+ for (MercuryNode* child = FirstChild(); child != NULL; child = NextChild(child))
+ child->RecursiveRender();
glLoadMatrixf( modelView.Ptr() );
Shader::SetAttribute("HG_ModelMatrix", sa);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2009-06-21 01:22:49
|
Revision: 348
http://hgengine.svn.sourceforge.net/hgengine/?rev=348&view=rev
Author: cnlohr
Date: 2009-06-21 00:50:41 +0000 (Sun, 21 Jun 2009)
Log Message:
-----------
get closer to actual run
Modified Paths:
--------------
Mercury2/tools/fonter/main.cpp
Modified: Mercury2/tools/fonter/main.cpp
===================================================================
--- Mercury2/tools/fonter/main.cpp 2009-06-21 00:10:49 UTC (rev 347)
+++ Mercury2/tools/fonter/main.cpp 2009-06-21 00:50:41 UTC (rev 348)
@@ -29,7 +29,7 @@
for( int y = 0; y < 1024; y++ )
{
imagedata[(x+y*1024)*2+0] = 255; //red
- imagedata[(x+y*1024)*2+1] = 255; //alpha
+ imagedata[(x+y*1024)*2+1] = 0; //alpha
// imagedata[(x+y*1024)*4+2] = 255; //blue
// imagedata[(x+y*1024)*4+3] = 255; //alpha
}
@@ -125,7 +125,7 @@
if( offy < 0 || offy >= yq*ypp ) continue;
imagedata[(offx + offy*(xq*xpp))*2+1] = l_bitmap.buffer[x+y*l_bitmap.pitch ];
- imagedata[(offx + offy*(xq*xpp))*2+0] = 0;
+ imagedata[(offx + offy*(xq*xpp))*2+0] = 255;
}
@@ -140,6 +140,8 @@
actualchar++;
}
+
+/* Draw grid
for( int x = 0; x < 1024; x+=64 )
for( int y = 0; y < 1024; y++ )
{
@@ -152,6 +154,7 @@
imagedata[(x+y*(xq*xpp))*2+0] = 0;
imagedata[(x+y*(xq*xpp))*2+1] = 255;
}
+*/
}
int my_write_png( const char * fname, unsigned char * imagedata, int width, int height )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2009-06-21 00:10:50
|
Revision: 347
http://hgengine.svn.sourceforge.net/hgengine/?rev=347&view=rev
Author: cnlohr
Date: 2009-06-21 00:10:49 +0000 (Sun, 21 Jun 2009)
Log Message:
-----------
better font tool
Modified Paths:
--------------
Mercury2/tools/fonter/main.cpp
Modified: Mercury2/tools/fonter/main.cpp
===================================================================
--- Mercury2/tools/fonter/main.cpp 2009-06-20 23:08:43 UTC (rev 346)
+++ Mercury2/tools/fonter/main.cpp 2009-06-21 00:10:49 UTC (rev 347)
@@ -8,9 +8,8 @@
# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf)
#endif
+FILE * fontfile;
-FILE * fout;
-
int my_write_png( const char * fname, unsigned char * imagedata, int x, int y );
int my_read_font( const char * fname, unsigned char * imagedata, int xpp, int ypp, int xq, int yq );
@@ -22,7 +21,7 @@
if( argc != 3 )
{
fprintf( stderr, "Mercury Fonter\n" );
- fprintf( stderr, "Usage: %s [font file] [output png]\n", argv[0] );
+ fprintf( stderr, "Usage: %s [font file] [font name]\n", argv[0] );
exit( -1 );
}
@@ -35,8 +34,22 @@
// imagedata[(x+y*1024)*4+3] = 255; //alpha
}
- my_read_font( argv[1], imagedata, 64, 64, 16, 8 );
- my_write_png( argv[2], imagedata, 1024, 1024 );
+ char fname[1024];
+ char pngname[1024];
+
+ sprintf( fname, "%s.%s", argv[2], "hgfont" );
+ sprintf( pngname, "%s.%s", argv[2], "png" );
+
+ fontfile = fopen( fname, "w" );
+ if( !fontfile )
+ {
+ fprintf( stderr, "Could not open font output file: %s\n", fname );
+ exit( -1 );
+ }
+ fprintf( fontfile, "%s\n", pngname );
+
+ my_read_font( argv[1], imagedata, 64, 64, 16, 16 );
+ my_write_png( pngname, imagedata, 1024, 1024 );
}
int my_read_font( const char * fname, unsigned char * imagedata, int xpp, int ypp, int xq, int yq )
@@ -68,16 +81,17 @@
exit( -1 );
}
- error = FT_Set_Pixel_Sizes( face, 0, 54 );
+ error = FT_Set_Pixel_Sizes( face, 0, 64 );
if( error )
{
fprintf( stderr, "Error with FT_Set_Pixel_Sizes\n" );
exit( -3 );
}
+ int actualchar = 0;
for( int ch = 0; ch < xq * yq; ch++ )
{
- glyph_index = FT_Get_Char_Index( face, ch );
+ glyph_index = FT_Get_Char_Index( face, actualchar );
error = FT_Load_Glyph( face, glyph_index, 0 ); //FT_LOAD_NO_BITMAP (try as last parameter)
@@ -96,13 +110,13 @@
FT_Bitmap l_bitmap = face->glyph->bitmap;
- printf( "%d (%c) %d %d\n", ch, ch, face->glyph->bitmap_left, face->glyph->bitmap_top );
-
+ int goffx = (xpp*(ch%xq));
+ int goffy = (ypp*(ch/xq));
for( int x = 0; x < xpp; x++ )
for( int y = 0; y < ypp; y++ )
{
- int offx = x+(xpp*(ch%xq)) + face->glyph->bitmap_left+0;
- int offy = y+(ypp*(ch/xq)) - face->glyph->bitmap_top+64;
+ int offx = x+goffx;
+ int offy = y+goffy;
if( x >= l_bitmap.width ) continue;
if( y >= l_bitmap.rows ) continue;
@@ -112,7 +126,18 @@
imagedata[(offx + offy*(xq*xpp))*2+1] = l_bitmap.buffer[x+y*l_bitmap.pitch ];
imagedata[(offx + offy*(xq*xpp))*2+0] = 0;
+
}
+
+ float loffx = float(goffx)/float(xpp*xq);
+ float loffy = float(goffy)/float(ypp*yq);
+ float loffxe = float(goffx+l_bitmap.width)/float(xpp*xq);
+ float loffye = float(goffy+l_bitmap.rows)/float(ypp*yq);
+
+ fprintf( fontfile, "%d %f %f %f %f %d %d %d %d\n", actualchar, loffx, loffy, loffxe, loffye,
+ l_bitmap.width, l_bitmap.rows, face->glyph->bitmap_left, face->glyph->bitmap_top );
+
+ actualchar++;
}
for( int x = 0; x < 1024; x+=64 )
@@ -131,6 +156,7 @@
int my_write_png( const char * fname, unsigned char * imagedata, int width, int height )
{
+ FILE * fout;
png_structp png_ptr;
png_infop info_ptr;
png_uint_32 k;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2009-06-20 23:08:44
|
Revision: 346
http://hgengine.svn.sourceforge.net/hgengine/?rev=346&view=rev
Author: cnlohr
Date: 2009-06-20 23:08:43 +0000 (Sat, 20 Jun 2009)
Log Message:
-----------
update
Modified Paths:
--------------
Mercury2/tools/fonter/main.cpp
Modified: Mercury2/tools/fonter/main.cpp
===================================================================
--- Mercury2/tools/fonter/main.cpp 2009-06-19 04:21:37 UTC (rev 345)
+++ Mercury2/tools/fonter/main.cpp 2009-06-20 23:08:43 UTC (rev 346)
@@ -35,7 +35,7 @@
// imagedata[(x+y*1024)*4+3] = 255; //alpha
}
- my_read_font( argv[1], imagedata, 64, 64, 16, 16 );
+ my_read_font( argv[1], imagedata, 64, 64, 16, 8 );
my_write_png( argv[2], imagedata, 1024, 1024 );
}
@@ -68,41 +68,65 @@
exit( -1 );
}
- error = FT_Set_Pixel_Sizes( face, 0, 64 );
+ error = FT_Set_Pixel_Sizes( face, 0, 54 );
if( error )
{
fprintf( stderr, "Error with FT_Set_Pixel_Sizes\n" );
exit( -3 );
}
- glyph_index = FT_Get_Char_Index( face, 65 );
+ for( int ch = 0; ch < xq * yq; ch++ )
+ {
+ glyph_index = FT_Get_Char_Index( face, ch );
+
+ error = FT_Load_Glyph( face, glyph_index, 0 ); //FT_LOAD_NO_BITMAP (try as last parameter)
+
+ if( error )
+ {
+ fprintf( stderr, "FT_Load_Glyph had a problem.\n" );
+ exit( -4 );
+ }
+
+ error = FT_Render_Glyph( face->glyph, FT_RENDER_MODE_NORMAL ); //try FT_LOAD_NO_HINTING
+ if( error )
+ {
+ fprintf( stderr, "FT_Render_Glyph had a problem.\n" );
+ exit( -4 );
+ }
- error = FT_Load_Glyph( face,
- glyph_index, 0 ); //FT_LOAD_NO_BITMAP (try as last thing)
+ FT_Bitmap l_bitmap = face->glyph->bitmap;
- if( error )
- {
- fprintf( stderr, "FT_Load_Glyph had a problem.\n" );
- exit( -4 );
+ printf( "%d (%c) %d %d\n", ch, ch, face->glyph->bitmap_left, face->glyph->bitmap_top );
+
+ for( int x = 0; x < xpp; x++ )
+ for( int y = 0; y < ypp; y++ )
+ {
+ int offx = x+(xpp*(ch%xq)) + face->glyph->bitmap_left+0;
+ int offy = y+(ypp*(ch/xq)) - face->glyph->bitmap_top+64;
+
+ if( x >= l_bitmap.width ) continue;
+ if( y >= l_bitmap.rows ) continue;
+
+ if( offx < 0 || offx >= xq*xpp ) continue;
+ if( offy < 0 || offy >= yq*ypp ) continue;
+
+ imagedata[(offx + offy*(xq*xpp))*2+1] = l_bitmap.buffer[x+y*l_bitmap.pitch ];
+ imagedata[(offx + offy*(xq*xpp))*2+0] = 0;
+ }
}
- error = FT_Render_Glyph( face->glyph, FT_RENDER_MODE_NORMAL );
- if( error )
+ for( int x = 0; x < 1024; x+=64 )
+ for( int y = 0; y < 1024; y++ )
{
- fprintf( stderr, "FT_Render_Glyph had a problem.\n" );
- exit( -4 );
+ imagedata[(x+y*(xq*xpp))*2+0] = 0;
+ imagedata[(x+y*(xq*xpp))*2+1] = 255;
}
-
- FT_Bitmap l_bitmap = face->glyph->bitmap;
-
for( int x = 0; x < 1024; x++ )
- for( int y = 0; y < 1024; y++ )
- {
- if( x > l_bitmap.width ) continue;
- if( y > l_bitmap.rows ) continue;
- imagedata[(x+y*1024)*2+1] = face->glyph->bitmap.buffer[x+y*l_bitmap.width ];
- }
-
+ for( int y = 0; y < 1024; y+=64 )
+ {
+ imagedata[(x+y*(xq*xpp))*2+0] = 0;
+ imagedata[(x+y*(xq*xpp))*2+1] = 255;
+ }
}
int my_write_png( const char * fname, unsigned char * imagedata, int width, int height )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2009-06-19 04:21:41
|
Revision: 345
http://hgengine.svn.sourceforge.net/hgengine/?rev=345&view=rev
Author: cnlohr
Date: 2009-06-19 04:21:37 +0000 (Fri, 19 Jun 2009)
Log Message:
-----------
beginnings of a fonter
Added Paths:
-----------
Mercury2/tools/fonter/
Mercury2/tools/fonter/Makefile
Mercury2/tools/fonter/main.cpp
Added: Mercury2/tools/fonter/Makefile
===================================================================
--- Mercury2/tools/fonter/Makefile (rev 0)
+++ Mercury2/tools/fonter/Makefile 2009-06-19 04:21:37 UTC (rev 345)
@@ -0,0 +1,7 @@
+all : hgfonter
+
+CFLAGS= -I/usr/include/freetype2
+CXXFLAGS=$(CFLAGS)
+
+hgfonter : main.o
+ g++ -o $@ $^ -lpng -lfreetype
Added: Mercury2/tools/fonter/main.cpp
===================================================================
--- Mercury2/tools/fonter/main.cpp (rev 0)
+++ Mercury2/tools/fonter/main.cpp 2009-06-19 04:21:37 UTC (rev 345)
@@ -0,0 +1,167 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <png.h>
+#include <ft2build.h>
+#include <freetype/freetype.h>
+
+#ifndef png_jmpbuf
+# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf)
+#endif
+
+
+FILE * fout;
+
+int my_write_png( const char * fname, unsigned char * imagedata, int x, int y );
+int my_read_font( const char * fname, unsigned char * imagedata, int xpp, int ypp, int xq, int yq );
+
+int main( int argc, char ** argv )
+{
+ unsigned char imagedata[1024*1024*4];
+ int x, y;
+
+ if( argc != 3 )
+ {
+ fprintf( stderr, "Mercury Fonter\n" );
+ fprintf( stderr, "Usage: %s [font file] [output png]\n", argv[0] );
+ exit( -1 );
+ }
+
+ for( int x = 0; x < 1024; x++ )
+ for( int y = 0; y < 1024; y++ )
+ {
+ imagedata[(x+y*1024)*2+0] = 255; //red
+ imagedata[(x+y*1024)*2+1] = 255; //alpha
+// imagedata[(x+y*1024)*4+2] = 255; //blue
+// imagedata[(x+y*1024)*4+3] = 255; //alpha
+ }
+
+ my_read_font( argv[1], imagedata, 64, 64, 16, 16 );
+ my_write_png( argv[2], imagedata, 1024, 1024 );
+}
+
+int my_read_font( const char * fname, unsigned char * imagedata, int xpp, int ypp, int xq, int yq )
+{
+ FT_Library library;
+ FT_Face face;
+ int error;
+ int glyph_index;
+ int x;
+ int y;
+
+ error = FT_Init_FreeType( &library );
+ if( error )
+ {
+ fprintf( stderr, "Error. Could not initialize freetype\n" );
+ exit( -1 );
+ }
+
+ error = FT_New_Face( library, fname, 0, &face );
+
+ if ( error == FT_Err_Unknown_File_Format )
+ {
+ fprintf( stderr, "Error. FT_Err_Unknown_File_Format\n" );
+ exit( -1 );
+ }
+ else if ( error )
+ {
+ fprintf( stderr, "Error. Something went wrong with FT_NewFace.\n" );
+ exit( -1 );
+ }
+
+ error = FT_Set_Pixel_Sizes( face, 0, 64 );
+ if( error )
+ {
+ fprintf( stderr, "Error with FT_Set_Pixel_Sizes\n" );
+ exit( -3 );
+ }
+
+ glyph_index = FT_Get_Char_Index( face, 65 );
+
+ error = FT_Load_Glyph( face,
+ glyph_index, 0 ); //FT_LOAD_NO_BITMAP (try as last thing)
+
+ if( error )
+ {
+ fprintf( stderr, "FT_Load_Glyph had a problem.\n" );
+ exit( -4 );
+ }
+
+ error = FT_Render_Glyph( face->glyph, FT_RENDER_MODE_NORMAL );
+ if( error )
+ {
+ fprintf( stderr, "FT_Render_Glyph had a problem.\n" );
+ exit( -4 );
+ }
+
+ FT_Bitmap l_bitmap = face->glyph->bitmap;
+
+ for( int x = 0; x < 1024; x++ )
+ for( int y = 0; y < 1024; y++ )
+ {
+ if( x > l_bitmap.width ) continue;
+ if( y > l_bitmap.rows ) continue;
+ imagedata[(x+y*1024)*2+1] = face->glyph->bitmap.buffer[x+y*l_bitmap.width ];
+ }
+
+}
+
+int my_write_png( const char * fname, unsigned char * imagedata, int width, int height )
+{
+ png_structp png_ptr;
+ png_infop info_ptr;
+ png_uint_32 k;
+ png_bytep row_pointers[height];
+
+ memset( &info_ptr, 0, sizeof( info_ptr ) );
+
+ fout = fopen( fname, "wb" );
+ if( !fout )
+ {
+ fprintf( stderr, "Error. Could not open output file.\n" );
+ exit( -1 );
+ }
+
+ png_ptr = png_create_write_struct( PNG_LIBPNG_VER_STRING, 0, 0, 0 );
+
+ if (png_ptr == NULL)
+ {
+ fclose(fout);
+ fprintf( stderr, "png_create_write_struct error.\n" );
+ exit( -1 );
+ }
+
+ info_ptr = png_create_info_struct(png_ptr);
+ if (info_ptr == NULL)
+ {
+ fclose(fout);
+ fprintf( stderr, "png_create_info_struct error.\n" );
+ png_destroy_write_struct(&png_ptr, png_infopp_NULL);
+ exit( -2 );
+ }
+
+ png_set_IHDR( png_ptr, info_ptr, width, height, 8, PNG_COLOR_TYPE_GRAY_ALPHA,
+ PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE );
+
+ if (setjmp(png_jmpbuf(png_ptr)))
+ {
+ /* If we get here, we had a problem reading the file */
+ fclose(fout);
+ png_destroy_write_struct(&png_ptr, &info_ptr);
+ fprintf( stderr, "Something bad happened.\n" );
+ exit( -3 );
+ }
+
+ png_init_io( png_ptr, fout );
+ png_write_info( png_ptr, info_ptr );
+
+
+ for (k = 0; k < height; k++)
+ row_pointers[k] = imagedata + k*width*2;
+
+ png_write_image( png_ptr, row_pointers );
+
+ png_write_end( png_ptr, info_ptr );
+
+ return 0;
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|