FORUM CLOSED, PLEASE REGISTER AT FORUM.SIO2INTERACTIVE.COM
Would you like to react to this message? Create an account in a few clicks or log in to continue.

SIO2Widget help

3 posters

Go down

SIO2Widget help Empty SIO2Widget help

Post  CadetCrusher Wed Oct 14, 2009 12:20 am

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:

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

Back to top Go down

SIO2Widget help Empty Re: SIO2Widget help

Post  Krypt Wed Oct 14, 2009 12:58 am

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!

Krypt

Posts : 15
Join date : 2009-09-21

Back to top Go down

SIO2Widget help Empty Re: SIO2Widget help

Post  CadetCrusher Wed Oct 14, 2009 10:05 am

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:

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

Back to top Go down

SIO2Widget help Empty Re: SIO2Widget help

Post  CadetCrusher Wed Oct 14, 2009 11:01 am

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.

CadetCrusher

Posts : 21
Join date : 2009-10-07

Back to top Go down

SIO2Widget help Empty Re: SIO2Widget help

Post  Francescu Wed Oct 14, 2009 11:16 am

Images have to be a power of 2 (e.g. 64x64, 96x96, etc)

Francescu

Posts : 136
Join date : 2009-03-18

Back to top Go down

SIO2Widget help Empty Re: SIO2Widget help

Post  CadetCrusher Wed Oct 14, 2009 11:24 am

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.

CadetCrusher

Posts : 21
Join date : 2009-10-07

Back to top Go down

SIO2Widget help Empty Re: SIO2Widget help

Post  Sponsored content


Sponsored content


Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum