Problem using multiple source files

View previous topic View next topic Go down

Problem using multiple source files

Post  wildicv on Sat May 02, 2009 3:47 pm

Hello im new to sio2 and i love how everything's works but the only thing that is driving me crazy is the need for everything to be in one source file.. I tried to make a simple splash screen class but i get a bad_access_error when it try's to access the widget here is the code.

Code:
/*
 *  SplashScreen.h
 *  template
 *
 *  Created by wildicv on 4/21/09.
 *  Copyright 2009 __MyCompanyName__. All rights reserved.
 *
 */

#include "../src/sio2/sio2.h"

@interface SplashScreen : NSObject{
   SIO2stream    *_SIO2stream;
   SIO2widget    *_SIO2widget;
   SIO2material *_SIO2material;
   SIO2image    *_SIO2image;
   int time;
}

- (void)startSplash: (int)d setwindow:(SIO2window*)b;
- (void)loadSplash;

@end

Code:
//
//  SplashScreen.m
//  template
//
//  Created by wildicv on 4/21/09.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//
#import "SplashScreen.h"

@implementation SplashScreen

-(void)startSplash: (int)d setwindow:(SIO2window*)b{
   time = d;
   if(time){
      if(time < 1){
         _SIO2widget->_SIO2material->diffuse->w = time;
      }
         sio2WidgetRender(_SIO2widget,b,0);
      
         sio2MaterialReset();
         time -= sio2->_SIO2window->d_time;
      if(time < 0){
         time = 0;
      }
   
   
   }else{
   
      _SIO2widget = sio2WidgetFree(_SIO2widget);
      sio2MaterialFree(_SIO2material);
      _SIO2image = sio2ImageFree(_SIO2image);
      sio2MaterialReset();
      sio2WidgetReset();
   }
   
}

-(void)loadSplash{
   {
   _SIO2stream = sio2StreamOpen("Splash.jpg",1);
   
   _SIO2widget  = sio2WidgetInit("splash");
   _SIO2material = sio2MaterialInit("splash");
   _SIO2image    = sio2ImageInit("splash");
   
   sio2ImageLoad(_SIO2image, _SIO2stream);
   
   sio2ImageGenId(_SIO2image, 0, 0.0f);
   
   _SIO2widget->_SIO2material = _SIO2material;
   _SIO2material->_SIO2image[SIO2_MATERIAL_CHANNEL0] = _SIO2image;
   
   _SIO2material->blend = SIO2_MATERIAL_ALPHA;
   
   _SIO2widget->_SIO2transform->scl->x = _SIO2image->width;
   _SIO2widget->_SIO2transform->scl->y = _SIO2image->height;
   
   _SIO2stream = sio2StreamClose( _SIO2stream );         
   }
}
@end

Code:
SplashScreen *splash = [[SplashScreen alloc]init];

void templateRender( void )
{
   glMatrixMode( GL_MODELVIEW );
   glLoadIdentity();

   glClear( GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT );
   
   sio2WindowEnter2D(sio2->_SIO2window,0.0,100.0f);
   {
      
      [splash startSplash: 2 setwindow:sio2->_SIO2window];      
      
      
   }
   
   sio2WindowLeave2D();
   
}

void templateLoading( void ){

   [splash loadSplash];
   
   
   sio2->_SIO2window->_SIO2windowrender= templateRender;
}


wildicv

Posts : 3
Join date : 2009-05-02

View user profile

Back to top Go down

Re: Problem using multiple source files

Post  sio2interactive on Sat May 02, 2009 4:32 pm

Check tutorial17 for more info... but just a question... where do you call sio2Init, sio2InitGL and sio2InitWidget??

_________________
SIO2 Interactive
Free Open Source 3D Game Engine for iPhone and iPod Touch
http://sio2interactive.com
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: Problem using multiple source files

Post  wildicv on Sat May 02, 2009 4:50 pm

the last snippet of code from template.mm is just showing how i call the class. The splash screen code is exactly from template 17 just in a class form. but it doesn't seem to work.

wildicv

Posts : 3
Join date : 2009-05-02

View user profile

Back to top Go down

Re: Problem using multiple source files

Post  sio2interactive on Sat May 02, 2009 5:16 pm

Well Im sure that a short session of GDB will show you what is not initialized...

_________________
SIO2 Interactive
Free Open Source 3D Game Engine for iPhone and iPod Touch
http://sio2interactive.com
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: Problem using multiple source files

Post  wildicv on Tue May 12, 2009 8:42 pm

I just had a chance to look at this now. Can someone plz point out what isnt being initialized i just cant seem to find it.

wildicv

Posts : 3
Join date : 2009-05-02

View user profile

Back to top Go down

Re: Problem using multiple source files

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