cross-platform code

Oldtimer
Posts: 834
Joined: 2002.09
Post: #16
Heh... At this point, I would think that you've made some odd mistake somewhere. Throw it all away (keep whatever source code you have) and set it all up again. These should be the steps:

Create the new project
Add the source
Drag the frameworks into the project
Include the framework by: #include <SDL/sdl.h>
Clean and build

Sometimes, you can save time by restarting. ;-) Hope this helps.
Quote this message in a reply
leggo
Unregistered
 
Post: #17
Fenris Wrote:Heh... At this point, I would think that you've made some odd mistake somewhere. Throw it all away (keep whatever source code you have) and set it all up again. These should be the steps:

Create the new project
Add the source
Drag the frameworks into the project
Include the framework by: #include <SDL/sdl.h>
Clean and build

Sometimes, you can save time by restarting. ;-) Hope this helps.

now it seems to work...
I've created a new project, added the frameworks and the source and added -framework SDL to the link flags
however now when I hit "build and run" it says "no launchable executable present to run"
lol...
well I'll read some documentation now

tnx! Wink
Quote this message in a reply
Oldtimer
Posts: 834
Joined: 2002.09
Post: #18
Uh? That's what would happen if you have selected to build a framework or a library - did you select "Cocoa application" when you were prompted for a project type? (Back when you set it all up)
Quote this message in a reply
leggo
Unregistered
 
Post: #19
Fenris Wrote:Uh? That's what would happen if you have selected to build a framework or a library - did you select "Cocoa application" when you were prompted for a project type? (Back when you set it all up)

no... i selcted "empty project"...
Quote this message in a reply
Oldtimer
Posts: 834
Joined: 2002.09
Post: #20
Ah, there you go! Smile A bit confusing, isn't it? You want a "Cocoa application". The reason is that SDL is built on top of Cocoa. (I think. Smile
Quote this message in a reply
leggo
Unregistered
 
Post: #21
Fenris Wrote:Ah, there you go! Smile A bit confusing, isn't it? You want a "Cocoa application". The reason is that SDL is built on top of Cocoa. (I think. Smile


isn't cocoa a mac-only language?
I wanted to make an easy portable code... Blink
Quote this message in a reply
Oldtimer
Posts: 834
Joined: 2002.09
Post: #22
Ah, yes. Here's the REALLY confusing part. It will still be cross-platform. The thing is that on Mac, SDL is written in Objective-C (using Cocoa - there's a language/API duality there). On Windows, SDL is written in C, and probably on Linux as well. The thing is that it doesn't matter what language SDL is written in, just what language YOUR code is in. If you write a game on a Mac, using SDL and say, C++, the code YOU write will compile just fine with the C-SDL on Windows and so on.

So, the bottom line here is: yes, SDL is in Cocoa on Mac, but you won't ever see a single line of it. Good luck, and keep asking!

Edit: If you want help right away, I'm in the #idevgames chatroom on Freenode.net
Quote this message in a reply
Member
Posts: 156
Joined: 2002.10
Post: #23
Take a look at my SDLGameBase code. It's available at http://www.pyramid-productions.net/downl...mebase.sit

It has a complete XCode project set up with the SDL (and SDL_mixer etc.) all included. Have a look at the build settings and also take a look at some of the header files (I think Game.h has an SDL include in it, but you should be able to find it by looking around).

Also notice that the SDL frameworks are copied into the application bundle using the 'Copy Files Build Phase' so that the App will run on any system, without requiring the user to install SDL.

If you like you can just use my code as a base for what you want to write, but be warned, I haven't set up anything for OpenGL, the Viewer part of the MVC is purely designed for SDL 2D blitting.

- Iain
Quote this message in a reply
leggo
Unregistered
 
Post: #24
ok I think I've understood now... I hope Rasp
IBethune I'll look into your code! I'm sure it will help me a lot Grin

thank you all for your help!
Quote this message in a reply
Moderator
Posts: 439
Joined: 2002.09
Post: #25
Installed correctly, you should be able to start a new project, choose the SDL OpenGL template, and have a compilable, working SDL OpenGL app generated for you. Then you can cannibilize it.

If you can't create the project might try reinstalling SDL. (They've had installer permission problems in the past, sometimes people have had to manually fix permissions on the template projects before they would work.)

Measure twice, cut once, curse three or four times.
Quote this message in a reply
leggo
Unregistered
 
Post: #26
MattDiamond Wrote:Installed correctly, you should be able to start a new project, choose the SDL OpenGL template, and have a compilable, working SDL OpenGL app generated for you. Then you can cannibilize it.

If you can't create the project might try reinstalling SDL. (They've had installer permission problems in the past, sometimes people have had to manually fix permissions on the template projects before they would work.)

I've tried with SDL OpenGL app and it works! Ninja
However I noticed some problems... for example
Code:
glBegin(GL_QUADS);
glVertex2f(-1.0f, 1.0f);
glVertex2f(-1.0f, -1.0f);
glVertex2f(1.0f, -1.0f)
glVertex2f(1.0f, 1.0f);
glEnd();

draws a rectangle and not a square Blink
and if i try to translate z by -1.0 or less the quad disappears from the screen Blink

well I'll make some more tries when I have more time!
sigh I was just starting to understand how things worked Mad
Quote this message in a reply
Oldtimer
Posts: 834
Joined: 2002.09
Post: #27
Ohwell, at least you're into crossplatform territory. Smile From here on, it's all OpenGL trouble.

The answer to your question is gluPerspective - you probably haven't set up the window aspect ration properly. But, head over to the OpenGL forum, and we'll help you out from there! Welcome! Smile
Quote this message in a reply
leggo
Unregistered
 
Post: #28
Fenris Wrote:Ohwell, at least you're into crossplatform territory. Smile From here on, it's all OpenGL trouble.

The answer to your question is gluPerspective - you probably haven't set up the window aspect ration properly. But, head over to the OpenGL forum, and we'll help you out from there! Welcome! Smile

mmm? aren't we already in the opengl forum? Blink
however now I'm truly ready to start coding! Grin

if someone has win and wants to try mi first game I made little ago
http://legomania.web.ctonet.it/AriX.exe

W,A,S,D,K and M to move the big cube
you have to catch the pink ones before they disappear to earn points!
Quote this message in a reply
honkFactory
Unregistered
 
Post: #29
Quote:If you've installed SDL via one of the packages at the SDL site, you should already have the option of an "SDL OpenGL Application" in the New Project window of Xcode anyway...

I just installed the SDL package but I don't see "SDL OpenGL Application" as an option in the New Project window. Why might this be?
Quote this message in a reply
honkFactory
Unregistered
 
Post: #30
Never mind. I had installed just the runtime libraries. Once I has installed the Development Libraries it appear just like magic.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Cross platform question kordeul 13 5,097 Aug 22, 2007 03:09 AM
Last Post: kordeul
  Cross-platform gui? Duane 13 5,582 Jul 6, 2007 06:38 PM
Last Post: mac_girl
  Best cross platform API for PC &amp; MAC Tarek Demiati 6 3,268 Apr 16, 2006 03:07 PM
Last Post: Dan Potter
  Cross platform game code on a budget Carlos Camacho 7 3,754 Apr 19, 2003 09:29 PM
Last Post: Mars_999
  Cross-platform Solutions DJBlufire 13 4,999 Feb 16, 2003 02:40 PM
Last Post: athomson