Results 1 to 12 of 12

Thread: Textures render perfectly on emulator, all white on galaxy nexus.

  1. #1

    Default Textures render perfectly on emulator, all white on galaxy nexus.

    ported my game from Irrlicht to Proton using the Proton-Irrlicht and have everything working on the emulator, but as soon as i run it on my galaxy nexus, all textures render white. game is 2D using ortho projection. render code is.

    Code:
    	irr::video::IVideoDriver *driver = device->getVideoDriver();
    
    	scene::ICameraSceneNode *cam = (scene::ICameraSceneNode *)device->getSceneManager()->getSceneNodeFromType(scene::ESNT_CAMERA);
    
    	if(cam == NULL)
    	{
    		cam = device->getSceneManager()->addCameraSceneNode();
    	}
    
    	core::matrix4 matproj;
    	matproj.buildProjectionMatrixOrthoLH(SCREEN_WIDTH, -SCREEN_HEIGHT, -100.0f, 100.0f);
    	matproj.setTranslation(core::vector3df(1, 1, 0));
    
    	cam->setProjectionMatrix(matproj, true);
    Code:
    void Draw2D::DrawImage(irr::video::ITexture* texture , irr::core::vector2df position, irr::core::dimension2di size, irr::core::rect<irr::s32> sourceRect, irr::f32 rotation, irr::video::SColor color, irr::core::position2d<irr::s32> rotationPoint)
    {
    	if(texture == NULL || device == NULL)
    		return;
    
    	irr::video::IVideoDriver *driver = device->getVideoDriver();
    
    	if(!size.Width || !size.Height)
    	{
    		size.Width = texture->getSize().Width;
    		size.Height = texture->getSize().Height;
    	}
    
    	if(!sourceRect.getWidth() || !sourceRect.getHeight())
    	{
    		sourceRect.UpperLeftCorner.X = 0;
    		sourceRect.UpperLeftCorner.Y = 0;
    		sourceRect.LowerRightCorner.X = texture->getSize().Width;
    		sourceRect.LowerRightCorner.Y = texture->getSize().Height;
    	}
    	else
    	{
    		sourceRect.LowerRightCorner.X += sourceRect.UpperLeftCorner.X;
    		sourceRect.LowerRightCorner.Y += sourceRect.UpperLeftCorner.Y;
    	}
    
    	if(rotationPoint == irr::core::position2d<irr::s32>(-1, -1))
    		rotationPoint = irr::core::position2d<irr::s32>((size.Width / 2) + position.X, (size.Height / 2) + position.Y);
    
    	irr::video::SMaterial material;
    
    	// Find the positions of corners
    	irr::core::vector2df corner[4];
    
    	corner[0] = irr::core::vector2df(position.X, position.Y);
    	corner[1] = irr::core::vector2df(position.X + size.Width, position.Y);
    	corner[2] = irr::core::vector2df(position.X, position.Y + size.Height);
    	corner[3] = irr::core::vector2df(position.X + size.Width, position.Y + size.Height);
    
    	// Rotate corners
    	if(rotation != 0.0f)
    		for(int x = 0; x < 4; x++)
    			corner[x].rotateBy(rotation,irr::core::vector2df(rotationPoint.X, rotationPoint.Y));
    
    
    	// Find the uv coordinates of the sourceRect
    	irr::core::vector2df uvCorner[4];
    	uvCorner[0] = irr::core::vector2df(sourceRect.UpperLeftCorner.X, sourceRect.UpperLeftCorner.Y);
    	uvCorner[1] = irr::core::vector2df(sourceRect.LowerRightCorner.X, sourceRect.UpperLeftCorner.Y);
    	uvCorner[2] = irr::core::vector2df(sourceRect.UpperLeftCorner.X, sourceRect.LowerRightCorner.Y);
    	uvCorner[3] = irr::core::vector2df(sourceRect.LowerRightCorner.X, sourceRect.LowerRightCorner.Y);
    	for(int x = 0; x < 4; x++)
    	{
    		float uvX = uvCorner[x].X/(float)texture->getSize().Width;
    		float uvY = uvCorner[x].Y/(float)texture->getSize().Height;
    
    		Clamp(uvX, 0.0, 1.0);
    		Clamp(uvY, 0.0, 1.0);
    
    		uvCorner[x] = irr::core::vector2df(uvX,uvY);
    	}
    
    	// Vertices for the image
    	irr::video::S3DVertex vertices[4];
    	irr::u16 indices[6] = { 0, 1, 2, 3 ,2 ,1 };
    
    	for(int x = 0; x < 4; x++)
    	{
    		vertices[x].Pos = irr::core::vector3df(corner[x].X,corner[x].Y, 0);
    		vertices[x].TCoords = uvCorner[x];
    		vertices[x].Color = color;
    	}
    	material.Lighting = false;
    	material.ZWriteEnable = false;
    	material.TextureLayer[0].Texture = texture;
    	material.TextureLayer[0].TextureWrapU = video::ETC_CLAMP;
    	material.TextureLayer[0].TextureWrapV = video::ETC_CLAMP;
    	//material.MaterialType = irr::video::ETC_CLAMP;
    	//material.Wireframe = true;
    	material.ZBuffer = video::ECFN_NEVER;
    	material.setFlag(video::EMF_BILINEAR_FILTER, true);
    
    	material.MaterialType = irr::video::EMT_TRANSPARENT_ALPHA_CHANNEL;
    
    	driver->setMaterial(material);
    	driver->drawIndexedTriangleList(vertices, 4, indices, 2);
    	
    	//__android_log_print(ANDROID_LOG_INFO, "Irrlicht", "texture size is %d x %d", texture->getSize().Width, texture->getSize().Height);	
    }
    thanks for any help.

  2. #2
    Administrator Seth's Avatar
    Join Date
    Jul 2002
    Location
    Japan
    Posts
    4,617

    Default

    Quote Originally Posted by Lee Morton View Post
    ported my game from Irrlicht to Proton using the Proton-Irrlicht and have everything working on the emulator, but as soon as i run it on my galaxy nexus, all textures render white. game is 2D using ortho projection. render code is.
    Hmm, can you try the RT3DApp example on your phone? If the Quake example gets white textures, but the rest of the demos in that app work ok, I might have an idea of how to fix it.
    Seth A. Robinson
    Robinson Technologies

  3. #3

    Default

    thank you for the reply.

    yes everything is textured except quake3 map

  4. #4
    Administrator Seth's Avatar
    Join Date
    Jul 2002
    Location
    Japan
    Posts
    4,617

    Default

    Quote Originally Posted by Lee Morton View Post
    thank you for the reply.

    yes everything is textured except quake3 map
    Ok, good, because the same thing happens on one of my devices so that means I have a way to duplicate/fix it, and if I do that, it will probably fix your game.

    Can't give a good time estimate on when I can do that though, except it won't be in the next 48 hours, Ludumdare 48 is about to start!
    Seth A. Robinson
    Robinson Technologies

  5. #5

    Default

    thanks, and good luck.

  6. #6

    Default

    Just wondering, what is actually causing this problem?

    Thanks

  7. #7
    Administrator Seth's Avatar
    Join Date
    Jul 2002
    Location
    Japan
    Posts
    4,617

    Default

    Fixed on svn. Irrlicht was trying to convert the RGB of the embedded lightmap to ABGR and the Adreno 205 (Tegra2 also) didn't like it I guess.
    Seth A. Robinson
    Robinson Technologies

  8. #8

    Default

    Thank you.

    but still a little problem,

    the first texture loads and renders correctly. once my scene changes everything is white again. im not sure if this is my code, android sytem or irrlicht. but my game loads textures when needed and not on game load.

    any insight?

  9. #9
    Administrator Seth's Avatar
    Join Date
    Jul 2002
    Location
    Japan
    Posts
    4,617

    Default

    Does the RT3DApp Quake example now work on your phone, including if you enter/exit/enter the level?

    It does work here, so I'd need a small example showing how to reproduce it if it's something in irrlicht/proton I could fix.

    Note: It does crash when going to the home screen and back though.. I assume because Irrlicht doesn't handle reloading the lightmap texture from the bsp which Android needs after losing focus...
    Seth A. Robinson
    Robinson Technologies

  10. #10

    Default

    still only see lightmaps on quake level.

  11. #11
    Administrator Seth's Avatar
    Join Date
    Jul 2002
    Location
    Japan
    Posts
    4,617

    Default

    Quote Originally Posted by Lee Morton View Post
    still only see lightmaps on quake level.
    Hmm, it may be a problem specific to that graphic chip (PowerVR SGX540 it looks like) - unfortunately until I have a phone with that chip I won't be able to reproduce or fix the problem. :wheelchair:
    Seth A. Robinson
    Robinson Technologies

  12. #12

    Default

    well. completly rewrite almost everything. now only uses proton not irrlicht at all. and works perfectly.

    thanks for a great library.

Similar Threads

  1. white texture on iOS
    By osgoz in forum Proton SDK
    Replies: 2
    Last Post: 02-17-2012, 08:46 AM
  2. Tanked - Palm Pre2 vs Samsung Galaxy S2
    By Blast07 in forum Tanked
    Replies: 2
    Last Post: 12-17-2011, 10:50 PM
  3. white in VIP!
    By soccerfu in forum Tanked
    Replies: 6
    Last Post: 11-29-2011, 01:02 AM
  4. OpenGL Textures
    By ElephantHunter in forum ClanLib: Help
    Replies: 2
    Last Post: 09-09-2008, 03:03 AM
  5. ZX Spectrum Emulator using ClanLib
    By syluridae in forum ClanLib: Developer Chat
    Replies: 3
    Last Post: 10-31-2006, 06:30 AM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •