SIO2Widget help
3 posters
SIO2Widget help
I'm having a bit of trouble trying to get SIO2widget to work. I could only find an example of how to use it in tutorial07, so I tried to use what I found there to make my widget. However, my game crashes when executing sio2WidgetRender(). My widget is really just an image that needs to respond to taps/drags. Here's what I'm doing:
Anyone know what I'm doing wrong?
Thanks!
- Code:
if(hudWidget == NULL)
{
SIO2stream* tmpStream = sio2StreamOpen( "hud.jpg", 1 );
if( tmpStream )
{
SIO2image* tmpImage = sio2ImageInit( "hud.jpg" );
{
sio2ImageLoad( tmpImage, tmpStream );
sio2ImageGenId( tmpImage, NULL, 0.0f );
}
tmpStream = sio2StreamClose( tmpStream );
SIO2material* tmpMat = sio2MaterialInit( "hud" );
hudWidget = sio2WidgetInit("hud");
hudWidget->_SIO2material = tmpMat;
hudWidget->_SIO2transform->scl->x = 96.0f;
hudWidget->_SIO2transform->scl->y = 96.0f;
hudWidget->_SIO2transform->loc->x = 360.0f;
hudWidget->_SIO2transform->loc->x = 50.0f;
sio2TransformBindMatrix( hudWidget->_SIO2transform );
}
}
sio2WidgetRender(hudWidget, sio2->_SIO2window, 1);
Anyone know what I'm doing wrong?
Thanks!
CadetCrusher- Posts : 21
Join date : 2009-10-07
Re: SIO2Widget help
Hi,
Here is a good post on widgets with some sample code (down the bottom) that I found useful:
http://forum.sio2interactive.com/sio2-engine-f3/animating-and-parenting-an-sio2widget-t457.htm
Make sure you initialise the widget engine with the other SIO2 init stuff in eaglview.mm
Good luck!
Here is a good post on widgets with some sample code (down the bottom) that I found useful:
http://forum.sio2interactive.com/sio2-engine-f3/animating-and-parenting-an-sio2widget-t457.htm
Make sure you initialise the widget engine with the other SIO2 init stuff in eaglview.mm
Good luck!
Krypt- Posts : 15
Join date : 2009-09-21
Re: SIO2Widget help
Thanks for the help! Yep you were right, I needed sio2InitWidget() in EAGLView.mm. Doh!
Now the game doesn't crash, but the widget displays as a blank white square. Here's my widget init/render code:
What am I missing here?
Thanks!
Now the game doesn't crash, but the widget displays as a blank white square. Here's my widget init/render code:
- Code:
if(hudWidget == NULL)
{
SIO2stream* tmpStream = sio2StreamOpen( "hud.jpg", 1 );
if( tmpStream )
{
SIO2image* tmpImage = sio2ImageInit( "hud.jpg" );
{
sio2ImageLoad( tmpImage, tmpStream );
sio2ImageGenId( tmpImage, NULL, 0.0f );
}
tmpStream = sio2StreamClose( tmpStream );
SIO2material* tmpMat = sio2MaterialInit( "hud" );
{
tmpMat->_SIO2image[ SIO2_MATERIAL_CHANNEL0 ] = tmpImage;
tmpMat->diffuse->w = 1.0f;
tmpMat->blend = SIO2_MATERIAL_COLOR;
}
hudWidget = sio2WidgetInit("hud");
hudWidget->_SIO2material = tmpMat;
hudWidget->_SIO2transform->scl->x = 96.0f;
hudWidget->_SIO2transform->scl->y = 96.0f;
instrumentPanelWidget->_SIO2transform->loc->x = 360.0f;
hudWidget->_SIO2transform->loc->x = 50.0f;
sio2EnableState( &hudWidget->flags, SIO2_WIDGET_VISIBLE |
SIO2_WIDGET_ENABLED );
sio2TransformBindMatrix( hudWidget->_SIO2transform );
}
}
sio2WidgetRender(hudWidget, sio2->_SIO2window, 1);
What am I missing here?
Thanks!
CadetCrusher- Posts : 21
Join date : 2009-10-07
Re: SIO2Widget help
Ok, it looks like it might be an image formatting problem. When I use the original (non re-sized) image, it displays but it's 512x512, so I had to resize it to 96x96 with GIMP. I don't do anything special when saving the resized image, I just save it as a JPEG. Are there any precautions I should take when making images to use with widgets (I haven't had this problem when making texture images)? Should I use a different format?
Thanks.
Thanks.
CadetCrusher- Posts : 21
Join date : 2009-10-07
Re: SIO2Widget help
Images have to be a power of 2 (e.g. 64x64, 96x96, etc)
Francescu- Posts : 136
Join date : 2009-03-18
Re: SIO2Widget help
Thanks! Oh man, I knew that images had to be square and a power of 2 for textures, but I didn't think it mattered for widget images. DOH!
Phew! Now on to some real work. Thanks again.
Phew! Now on to some real work. Thanks again.
CadetCrusher- Posts : 21
Join date : 2009-10-07
Similar topics
» SIO2widget in v1.3??
» SIO2widget change in 1.4?
» How to use a sio2widget as a textbox?
» Rotating SIO2Widget?
» What is sio2Widget and are there any use examples out there?
» SIO2widget change in 1.4?
» How to use a sio2widget as a textbox?
» Rotating SIO2Widget?
» What is sio2Widget and are there any use examples out there?
Permissions in this forum:
You cannot reply to topics in this forum