Problem using multiple source files
2 posters
Problem using multiple source files
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
Re: Problem using multiple source files
Check tutorial17 for more info... but just a question... where do you call sio2Init, sio2InitGL and sio2InitWidget??
Re: Problem using multiple source files
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
Re: Problem using multiple source files
Well Im sure that a short session of GDB will show you what is not initialized...
Re: Problem using multiple source files
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
Similar topics
» Using Multiple Resources and sio2 files
» resetting scenes, sio2 resource files, and multiple levels
» Need help with multiple textures
» Render unlit surface
» Dot3 Normal Bump Mapping + Per Pixel Lighting
» resetting scenes, sio2 resource files, and multiple levels
» Need help with multiple textures
» Render unlit surface
» Dot3 Normal Bump Mapping + Per Pixel Lighting
Permissions in this forum:
You cannot reply to topics in this forum