SIO2 Widgets

Important: be sure that you have added sio2InitWidget(); in EAGLView.mm after sio2InitGL(); Make sure your images are a power of 2 in size.

In your loading function:

NAMEOFYOURSTREAM = sio2StreamOpen( "NAMEOFIMAGEFILE.tga", 1 );
      if( NAMEOFYOURSTREAM )
      {
         NAMEOFYOURIMAGE = sio2ImageInit( "HUD.tga" );
         {
            sio2ImageLoad( NAMEOFYOURIMAGE, NAMEOFYOURSTREAM );
            sio2ImageGenId( NAMEOFYOURIMAGE, NULL, 0.0f );
         }

         NAMEOFYOURSTREAM = sio2StreamClose( NAMEOFYOURSTREAM );
         NAMEOFYOURMATERIAL = sio2MaterialInit( "HUD" );

         //Use SIO2_MATERIAL_COLOR instead of SIO2_MATERIAL_ALPHA since it's no more valid in 1.4
         {
            NAMEOFYOURMATERIAL->blend = SIO2_MATERIAL_ALPHA;
            NAMEOFYOURMATERIAL->_SIO2image[ SIO2_MATERIAL_CHANNEL0 ] = NAMEOFYOURIMAGE;
         }

         NAMEOFYOURWIDGET = sio2WidgetInit( "HUD" );        
         NAMEOFYOURWIDGET->_SIO2material = NAMEOFYOURMATERIAL;       
         NAMEOFYOURWIDGET->_SIO2transform->scl->x = 512.0f;
         NAMEOFYOURWIDGET->_SIO2transform->scl->y = 32.0f;       
         NAMEOFYOURWIDGET->_SIO2transform->loc->x  = -15.0f;
         NAMEOFYOURWIDGET->_SIO2transform->loc->y  = 283.0f;         
         sio2EnableState( & NAMEOFYOURWIDGET->flags, SIO2_WIDGET_VISIBLE    );         
      }

In your render function:

sio2WindowEnter2D( sio2->_SIO2window, 0.0f, 1.0f );
      {
         sio2WindowEnterLandscape2D( sio2->_SIO2window );
         {                                                    
            sio2TransformBindMatrix( ANYWIDGETNAME->_SIO2transform );

            // Render our widget 
            sio2WidgetRender( ANYWIDGETNAME, sio2->_SIO2window, 1 );

            // Reset the rendering states set by SIO2widget.
            sio2WidgetReset();
            sio2MaterialReset();                            
         }

         sio2WindowLeaveLandscape2D( sio2->_SIO2window );
      }

      sio2WindowLeave2D();

Note: If you want the widget to respond to touch events you must have at least visible and enabled flags turned on.

sio2EnableState( & NAMEOFYOURWIDGET->flags, SIO2_WIDGET_VISIBLE | SIO2_WIDGET_ENABLED  );
page_revision: 8, last_edited: 1255552008|%e %b %Y, %H:%M %Z (%O ago)
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License