gluongraphics loadtexture example
Ashwin
ashwin_rajeev at hotmail.com
Sat Aug 20 13:56:18 UTC 2011
I created two items and load two different textures.But when displayed both
have same texture.
git diff of program
diff --git a/graphics/examples/loadtexture/main.cpp
b/graphics/examples/loadtexture/main.cpp
index a112b1d..228483a 100644
--- a/graphics/examples/loadtexture/main.cpp
+++ b/graphics/examples/loadtexture/main.cpp
@@ -54,9 +54,16 @@ int main( int argc, char* argv[] )
GluonGraphics::Item* item = GluonGraphics::Engine::instance()-
>createItem( "default" );
//Load a custom texture from file
- GluonGraphics::Texture* tex = GluonGraphics::Engine::instance()-
>createTexture( "textureName" );
- tex->load( QUrl( GluonCore::DirectoryProvider::instance()-
>dataDirectory() + "/gluon/defaults/default.png" ) );
- item->materialInstance()->setProperty( "texture0", "textureName" );
+ GluonGraphics::Texture* tex = GluonGraphics::Engine::instance()-
>createTexture( "ball" );
+ tex->load( QUrl( GluonCore::DirectoryProvider::instance()-
>dataDirectory()
+ + "/gluon/games/ball.gluon/assets/textures/ball.png" ) );
+ item->materialInstance()->setProperty( "texture0", "ball" );
+
+ GluonGraphics::Item* item2 = GluonGraphics::Engine::instance()-
>createItem( "default" );
+ GluonGraphics::Texture* tex2 = GluonGraphics::Engine::instance()-
>createTexture( "trap" );
+ tex2->load( QUrl( GluonCore::DirectoryProvider::instance()-
>dataDirectory()
+ + "/gluon/games/ball.gluon/assets/textures/trap.png" )
);
+ item2->materialInstance()->setProperty( "texture0", "trap" );
QMatrix4x4 mat;
mat.translate( -1.5f, -1.5f );
More information about the Gluon
mailing list