★ TouchArcade needs your help. Click here to support us on Patreon.

OGRE and SDL - iPhone Port Version

08-21-2009, 01:37 PM
#1
Joined: Aug 2009
Posts: 67
OGRE and SDL - iPhone Port Version

Hello,

We are working on two games for iPhone.

The first game is in development and we are using OGRE with C/C++ . And when finish port to iPhone. With this we can have the game also for Windows and Mac.

Ogre iPhone Port SDK:
http://www.ogre3d.org/forums/viewtopic.php?f=4&t=51151



The other coder have much experience in SDL. The problem with SDL is that Apple not allow "Dynamically linking with SDL" only "statically linking with SDL". And for make commercial iPhones games with SDL i think we need to buy a SDL License why "statical linking" is only legal with a license buyed.

You can view Here: http://galaxygameworks.com/

Anybody knows how much cost the 1.3 license version of SDL ? I was send a email but i still waiting for response...


BTW, Whats your opinion about it? Anybody made iPhone games with any of this ways¿?
08-21-2009, 03:54 PM
#2
check http://www.libsdl.org/tmp/ - you can get 1.3 latest src there.. it goes under LGPL.. I did not find anything about paying for linking static libs..

Who is this galaxygameworks anyway?

Of course, LGPL may or may not fit your particular development needs..

<< Check out our AppStore game titles: Tyrian, Super Methane Brothers, Cryptix, Powermanga, Rise Of The Triad >>

Last edited by mobilainteractive; 08-21-2009 at 04:10 PM.

08-21-2009, 04:11 PM
#3
Joined: Aug 2009
Posts: 67
Quote:
Originally Posted by mobilainteractive View Post
check http://www.libsdl.org/tmp/ - you can get 1.3 latest src there.. it goes under LGPL.. I did not find anything about paying for linking static libs..

Who is this galaxygameworks anyway?
GalaxyGameWorks = http://galaxygameworks.com/about.html , Sam Lantinga, The founder of galaxygameworks is the Author of SDL .

Yes, you can get the 1.3 version from the webpage of SDL and use. But reading the page, you only can make iPhone games using "dynamically linking with SDL" and Apple not Allow this, only "Static Linking". And for use "static linking" you need to buy a license of SDL...
08-21-2009, 05:28 PM
#4
I don't get it...
v1.3 SDL source comes with LGPL licence, attached to it.
There is no place in GNU LGPL that says that you have to pay anyone to statically link the product. Now if the publisher wants to charge for licensing, he/she better put it in some sort of license attached to the distro... of course I am no lawyer, so I can be wrong...
[EDIT]
Some additional thoughts...
There are plenty of examples of GNU GPL software in the appstore. xPilot is the most recent that comes to mind:
http://ask.slashdot.org/askslashdot/...1/169247.shtml
Now LGPL is less restrictive so it's gotta be OK as long as it's v2. (version 3 GPL has some stuff which makes it incompatible with Apple's policies.) The trick is - you have to comply with the license, i.e. make the source code available. This is why it may not be the best way to go for some commercial applications. For instance, anyone can request xpilot src, recompile and sell the game in appstore at lower price OR give it out for free...

Now this guy, Sam Lantinga, wants to sell you the library under a different license. This way you don't have to give up your IP. I am not even convinced that he has the right to do so at this point, as many other people has contributed to the project and it's not solely "his" to sell or revert the license... I may be wrong about this though...

There are still ways to use SDL and protect your IP: for example you can license your data files, music and graphics under a different license. This way if someone "borrows" the entire game you can still take them to court for violating those licenses...

<< Check out our AppStore game titles: Tyrian, Super Methane Brothers, Cryptix, Powermanga, Rise Of The Triad >>

Last edited by mobilainteractive; 08-21-2009 at 06:43 PM.
08-21-2009, 06:53 PM
#5
Joined: Apr 2009
Location: Wellington, New Zealand
Posts: 210
Send a message via AIM to Firestar
Quote:
Originally Posted by matriax View Post
Hello,

We are working on two games for iPhone.

The first game is in development and we are using OGRE with C/C++ . And when finish port to iPhone. With this we can have the game also for Windows and Mac.

Ogre iPhone Port SDK:
http://www.ogre3d.org/forums/viewtopic.php?f=4&t=51151



The other coder have much experience in SDL. The problem with SDL is that Apple not allow "Dynamically linking with SDL" only "statically linking with SDL". And for make commercial iPhones games with SDL i think we need to buy a SDL License why "statical linking" is only legal with a license buyed.

You can view Here: http://galaxygameworks.com/

Anybody knows how much cost the 1.3 license version of SDL ? I was send a email but i still waiting for response...


BTW, Whats your opinion about it? Anybody made iPhone games with any of this ways¿?
Hi. I'm currently porting another game to the iPhone using SDL. I'm using the open source SDL for the iPhone. The link is here: http://code.google.com/p/iphone-sdl-1-3/
We're having some trouble with rendering the game view onto the screen. If you have any tips they would be most appreciated.
08-21-2009, 07:09 PM
#6
Quote:
Originally Posted by Firestar View Post
Hi. I'm currently porting another game to the iPhone using SDL. I'm using the open source SDL for the iPhone. The link is here: http://code.google.com/p/iphone-sdl-1-3/
We're having some trouble with rendering the game view onto the screen. If you have any tips they would be most appreciated.
1) why not use the "official" version from LIBSDL.org - it seems to be more mature and has same license?
2) it's hard to give tips if you don't give any details... The "official" sdl version comes with a few examples that you can build and test

<< Check out our AppStore game titles: Tyrian, Super Methane Brothers, Cryptix, Powermanga, Rise Of The Triad >>
08-21-2009, 08:22 PM
#7
Joined: Apr 2009
Location: Wellington, New Zealand
Posts: 210
Send a message via AIM to Firestar
Sorry, I should clarify. The iPhone version which I linked to adds code for the accelerometer, touch controls etc.
The problem I'm having is getting it to recognise the screen output in the SuperTux computer main loop and display it onto the screen. That's as far as we've actually got with that bit, the rest has been cleaning up the code.
So the question is, how do you get the xib file to load information from the main.mm file?
Note: I am a newbie at iPhone development.
08-21-2009, 09:39 PM
#8
Quote:
Originally Posted by Firestar View Post
Sorry, I should clarify. The iPhone version which I linked to adds code for the accelerometer, touch controls etc.
The problem I'm having is getting it to recognise the screen output in the SuperTux computer main loop and display it onto the screen. That's as far as we've actually got with that bit, the rest has been cleaning up the code.
So the question is, how do you get the xib file to load information from the main.mm file?
Note: I am a newbie at iPhone development.
I did a superTux port for PSP a few years back :-) - fun game.. should be a pretty straight forward port.. but is not the last version licensed under GPL v3, which is not AppStore friendly??
Still the sdllib.org iphone version has support for accelerometer and touch (although maybe not the best implementation, which, of course can be overridden or disabled if needed... anyway, if you use any of the provided examples you pretty much have the basic SDL app project which outputs something to a screen..

You can also try to dump pixels from SDL_Surface to a memory chunk for later display with EAGLView
The code below assumes that the Surface is 8 bit and 320x200
It's copy-pasted from Rise Of Triad port that we are doing...
I hope it makes sense to you :-)
EAGLView code code is borrowed from one of Apple's code demos..
(GLLamp i think..)
Once you have it in EAGLView - you can stretch, rotate and flip it all you want...

Code:
#define RGB(b,g,r) (short)((((b>>3) & 0x1F)<<11)|(((g>>3) & 0x1F)<<6)|(((r>>3) & 0x1F)<<1))



unsigned short  pixels[512*512];

void BlitScreen(SDL_Surface *s) {
        int i,j;
        int x=0;
        int y=0;
	Uint8 index;
	SDL_Color color;
		
        for (i=0; i<200; i++) {
        	for (j=0; j<320; j++) {
			index= *(Uint8 *) (&s->pixels[j+y]);
					color= (s->format->palette->colors[index]);
               		
					pixels[x+j]=RGB(color.r,color.g,color.b);
				
		}
                x+=512;
                y+=320;
        }
	draw_c_wrapper();   //c wrapper to call the drawView method of EAGLView

}

unsigned short * getPixels() {
	return pixels;
}



--------------------------------------
EAGLView.mm
-----------------------
#import <QuartzCore/QuartzCore.h>
#import <OpenGLES/EAGLDrawable.h>
#import "EAGLView.h"

@interface EAGLView (EAGLViewPrivate)

- (BOOL)createFramebuffer;
- (void)destroyFramebuffer;

@end

@interface EAGLView (EAGLViewSprite)

- (void)setupView;

@end


extern unsigned short* getPixels(void) ;

@implementation EAGLView

//unsigned short pixels[];
//unsigned short pixels1[];

GLubyte *spriteData;
// You must implement this
+ (Class) layerClass
{
	return [CAEAGLLayer class];
}


- (id)initWithFrame:(CGRect) frame
{
	self.alpha=0.0;
	if((self = [super initWithFrame:frame])) {
		CAEAGLLayer *eaglLayer = (CAEAGLLayer*) self.layer;
		
		eaglLayer.opaque = YES;
		eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
										[NSNumber numberWithBool:FALSE], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGB565, kEAGLDrawablePropertyColorFormat, nil];
		
		context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1];
		
		if(!context || ![EAGLContext setCurrentContext:context] || ![self createFramebuffer]) {
			[self release];
			return nil;
		}
		
		
		
		[self setupView];
		self.alpha=1.0;
		
		//[self drawView];
		//[NSTimer scheduledTimerWithTimeInterval:0.015 target:self selector:@selector(drawView) userInfo:nil repeats:YES];
	}
	return self;
}


- (void)layoutSubviews
{
	[EAGLContext setCurrentContext:context];
	[self destroyFramebuffer];
	[self createFramebuffer];
	[self drawView];
}


- (BOOL)createFramebuffer
{
	glGenFramebuffersOES(1, &viewFramebuffer);
	glGenRenderbuffersOES(1, &viewRenderbuffer);
	
	glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);
	glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
	[context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(id<EAGLDrawable>)self.layer];
	glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, viewRenderbuffer);
	
	glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth);
	glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight);
	
	if(glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) {
		//NSLog(@"failed to make complete framebuffer object %x", glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES));
		return NO;
	}
	
	return YES;
}


- (void)destroyFramebuffer
{
	glDeleteFramebuffersOES(1, &viewFramebuffer);
	viewFramebuffer = 0;
	glDeleteRenderbuffersOES(1, &viewRenderbuffer);
	viewRenderbuffer = 0;
	
	if(depthRenderbuffer) {
		glDeleteRenderbuffersOES(1, &depthRenderbuffer);
		depthRenderbuffer = 0;
	}
}






// Sets up an array of values to use as the sprite vertices.
//top

const GLfloat spriteVertices[] = {
-1.0f, -1.0f,
1.0f, -1.0f,
-1.0f,  1.0f,
1.0f,  1.0f,
};
/*
const GLfloat spriteVertices1[] = {
-1.0f, -1.0f,
0.0f, -1.0f,
-1.0f,  1.0f,
0.0f,  1.0f,
};

const GLfloat spriteVertices2[] = {
-0.001f, -1.0f,
0.25f, -1.0f,
-0.001f,  1.0f,
0.25f,  1.0f,
};
*/

const GLfloat spriteVertices1[] = {
-1.0f, -1.0f,
-0.75f, -1.0f,
-1.0f,  1.0f,
-0.75f,  1.0f,
};

const GLfloat spriteVertices2[] = {
-0.75f, -1.0f,
0.25f, -1.0f,
-0.75f,  1.0f,
0.25f,  1.0f,
};

// Sets up an array of values for the texture coordinates.
const GLshort spriteTexcoords[] = {
0, 0,
1, 0,
0, 1,
1, 1,
};

- (void)setupView
{
	
	size_t	width, height;
	
	// Sets up matrices and transforms for OpenGL ES
	glViewport(0, 0, backingWidth, backingHeight);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glOrthof(-1.0f, 1.0f, -1.5f, 1.5f, -1.0f, 1.0f);
	glMatrixMode(GL_MODELVIEW);
	
	// Clears the view with black
	glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
	
	// Sets up pointers and enables states needed for using vertex arrays and textures
	glVertexPointer(2, GL_FLOAT, 0, spriteVertices1);
	glEnableClientState(GL_VERTEX_ARRAY);
	glTexCoordPointer(2, GL_SHORT, 0, spriteTexcoords);
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
	
	width=512; height=256;
	
		
		spriteData =  getPixels();
	
	
		
		// Use OpenGL ES to generate a name for the texture.
		glGenTextures(1, &spriteTexture);
		// Bind the texture name. 
		//glBindTexture(GL_TEXTURE_2D, spriteTexture);
	//glBindTexture(1, spriteTexture);
		// Speidfy a 2D texture image, provideing the a pointer to the image data in memory
		//glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 512, 256, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, spriteData);
		
		
		// Set the texture parameters to use a minifying filter and a linear filer (weighted average)
		
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 
	//glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 
	//glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 
	//glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 
	
	glDisable(GL_DEPTH_TEST); 
	
		// Enable use of the texture
		glEnable(GL_TEXTURE_2D);
		// Set a blending function to use
			// Enable blending
		//glEnable(GL_BLEND);
		glRotatef(180.0f, 1.0f, 0.0f, 0.0f);
		glRotatef(90.0f, 0.0f, 0.0f, 1.0f);
		glTranslatef(0.92f,0.28f,0.0f);
		//glTranslatef(.11f,0.0f,0.0f);
		glScalef(2.42, 1.28, 1.0);
	
}



int count=0;

//extern JE_integer PX, PY;
int touch_x,touch_y;
long mouse_clicked=0;

UITouch *touch;
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
	
	mouse_clicked=1;
	touch = [touches anyObject];
	CGPoint touchPoint = [touch locationInView:self];
	touch_x=touchPoint.x;
	touch_y=touchPoint.y;
	
}


- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
	touch = [touches anyObject];
	CGPoint touchPoint = [touch locationInView:self];
	touch_x=touchPoint.x;
	touch_y=touchPoint.y;
	
	
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
	mouse_clicked=-1;
}



- (void) bringToFront {
	[self.superview bringSubviewToFront:self];
}

extern int ingame;
extern int frame;

- (void)drawView
{

	
	
		glVertexPointer(2, GL_FLOAT, 0, spriteVertices);
		glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 512, 256, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, spriteData);
		glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
	
	
	[context presentRenderbuffer:GL_RENDERBUFFER_OES];

}

// Stop animating and release resources when they are no longer needed.
- (void)dealloc
{
	
	if([EAGLContext currentContext] == context) {
		[EAGLContext setCurrentContext:nil];
	}
	
	[context release];
	context = nil;
	
	[super dealloc];
}

@end

<< Check out our AppStore game titles: Tyrian, Super Methane Brothers, Cryptix, Powermanga, Rise Of The Triad >>
08-21-2009, 11:16 PM
#9
Joined: Apr 2009
Location: Wellington, New Zealand
Posts: 210
Send a message via AIM to Firestar
Works brilliantly. Thank you so much! By the way, it's licensed under GNU v2, which is fine with reselling games so long as I link to the Subversion respiratory.
08-21-2009, 11:30 PM
#10
Quote:
Originally Posted by Firestar View Post
Works brilliantly. Thank you so much! By the way, it's licensed under GNU v2, which is fine with reselling games so long as I link to the Subversion respiratory.
Well good luck with it.. I hope to see it soon in the Appstore :-)
I was actually considering an iPhone port of this game a few days ago ;-)
But I am kinda busy with other projects... :-(
Here is the link to my PSP port
http://deniska.dcemu.co.uk/homebrew-games-16086.html

Pleeease make sure you optimize the rendering and controls before you release it - I'd hate to see this game butchered and getting bad reviews - it has so much potential :-)

[EDIT]
LOL, you are right about the license - although the tux website links to GPL v3 page, the source code still has v2 :-)

<< Check out our AppStore game titles: Tyrian, Super Methane Brothers, Cryptix, Powermanga, Rise Of The Triad >>

Last edited by mobilainteractive; 08-21-2009 at 11:34 PM.