Image Troubles

View previous topic View next topic Go down

Image Troubles

Post  samson on Sun Jan 04, 2009 3:07 am

I'm sorry to bother everyone with such a basic question, but I can't figure out how to render a 2d image. I've got fonts working, but I don't understand how to apply the technique to images.
So far I've got this:

Code:

if( _SIO2stream )
   {
      _SIO2image = sio2ImageInit( "RFlag.tga" );
      {
      sio2ImageLoad( _SIO2image, _SIO2stream );
      sio2ImageGenId( _SIO2image, 0 );
      }
      _SIO2stream = sio2StreamClose( _SIO2stream );
      
      _SIO2image->height = 480.0f;//_SIO2video->_SIO2image->width;
      _SIO2image->width = 240.0f;//_SIO2video->_SIO2image->height;

and then this in my rendering loop:

Code:

sio2WindowEnter2D( sio2->_SIO2window, 0.0f, 1.0f );
      {
         sio2WindowEnterLandscape2D( sio2->_SIO2window );
         {
         
            // Render our widget
            sio2ImageRender(_SIO2image);

etc.

What I don't understand is how i link ImageRender to the image that I set up in the stream, since images don't have an sio2FontBuild like fonts do. Is there some equivalent that I am missing? Thanks in advance!

samson

Posts : 27
Join date : 2008-11-29

View user profile

Back to top Go down

Re: Image Troubles

Post  sio2interactive on Sun Jan 04, 2009 3:43 am

You need to use widget check tutorial07 for quick widget demo...
avatar
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 38
Location : Shanghai

View user profile http://sio2interactive.com

Back to top Go down

Re: Image Troubles

Post  samson on Sun Jan 04, 2009 12:19 pm

Hmm I tried that too and didn't have any luck. This is as far as I got:

Code:

   _SIO2stream = sio2StreamOpen( "RFlag.tga", 1 );
   
   if( _SIO2stream )
   {
      _SIO2image = sio2ImageInit( "RFlag.tga" );
      {
      sio2ImageLoad( _SIO2image, _SIO2stream );
      sio2ImageGenId( _SIO2image, 0 );
      }
      _SIO2stream = sio2StreamClose( _SIO2stream );
      
      _SIO2material = sio2MaterialInit( "RFlag" );
      {
      _SIO2material->blend = SIO2_MATERIAL_DIVIDE;
      _SIO2material->_SIO2image[ SIO2_MATERIAL_CHANNEL0 ] = _SIO2image;
      }
      _SIO2widget = sio2WidgetInit( "RFlag" );
      
      _SIO2widget->_SIO2material = _SIO2material;
      
      // Initialize the size of the widget to be the same as our
      // video image.
      _SIO2widget->size->x = 480.0f;//_SIO2video->_SIO2image->width;
      _SIO2widget->size->y = 240.0f;//_SIO2video->_SIO2image->height;
      
      
      _SIO2widget->pos->x  = 0.5f;
      _SIO2widget->pos->y  = 0.5f;
      
      
      sio2EnableState( &_SIO2widget->flags,
                  SIO2_WIDGET_VISIBLE | SIO2_WIDGET_CENTERED |
                  SIO2_WIDGET_ALIGNH  | SIO2_WIDGET_ALIGNV );
      
      glClear( GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT );
   }

and then

Code:

sio2WindowEnter2D( sio2->_SIO2window, 0.0f, 1.0f );
      {
         sio2WindowEnterLandscape2D( sio2->_SIO2window );
         {
         
            // Render our widget
            sio2WidgetRender( _SIO2widget, sio2->_SIO2window );
            
            // Reset the rendering states set by SIO2widget.
            sio2WidgetReset();

It crashes when I use SIO2_WIDGET_VISIBLE

samson

Posts : 27
Join date : 2008-11-29

View user profile

Back to top Go down

Re: Image Troubles

Post  meteors on Sun Jan 04, 2009 1:07 pm

You need to initialize the widget in EAGLview.mm.

Search the forum please; there was another thread on this just a few days ago.


-j
avatar
meteors

Posts : 241
Join date : 2008-11-08
Location : Sunny Florida

View user profile

Back to top Go down

Re: Image Troubles

Post  samson on Sun Jan 04, 2009 1:31 pm

Thank you meteors, that did it. My apologies, I had searched the forum for widget and didn't see any threads that answered my question Smile

samson

Posts : 27
Join date : 2008-11-29

View user profile

Back to top Go down

Re: Image Troubles

Post  Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

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