トップページgamedev
987コメント396KB

SDLスレ

レス数が950を超えています。1000を超えると書き込みができなくなります。
0001login:Penguin01/11/11 17:59ID:u0HMN7qC
マルチプラットホームな汎用ゲームライブラリの
SDLについてのスレッドです。
最新情報、参考になるソース、質問等

とりあえず、本山
http://www.libsdl.org/
0971名前は開発中のものです。2006/02/16(木) 19:07:44ID:RDmCVz1R
>>970
あなたが知らないのならわかる人を連れてきてください。
それすらできないようならあなたなんかに用はありません。
0972名称未設定2006/02/16(木) 19:18:34ID:6HFR4Et4
最近は bash が Mac OS X のデフォルトのログインシェルなんで、
~/.cshrc に書いても読まれていない罠の可能性が… ( echo $SHELL すればわかる、かも)
~/.bashrc とかに書かなきゃいけないかもよ?

とにかく、エラーがとんでもなくでたんならそのエラーと
そのときのコマンドラインを貼り付けれ。
長すぎて迷惑だと思うならどこか手軽なアップローダを探せばいい。

新・mac板に行ってTerminal初心者スレあたりでたずねることも検討しなさいな。
初心者だって開発してみたいだろうさ。
0973名前は開発中のものです。2006/02/16(木) 20:24:20ID:4CJdjj+H
シェルをtcshからbashに変えて
~/.bash_profileにexport PATH=$PATH":/SDL-1.2.9"と記述しました

~/SDL-1.2.9 および ~/SDL-1.2.9/testにて
sdl-config --cflags --libsだけで実行すると
-bash: sdl-config: command not found

~/SDL-1.2.9にて
./sdl-config --cflags --libsで実行すると
-I/usr/local/include/SDL -D_THREAD_SAFE
-L/usr/local/lib -lSDLmain -lSDL -framework Cocoa -framework OpenGL
となりました。これはこのディレクトリ内にsdl-configがあるので当たり前なんですが…
0974名前は開発中のものです。2006/02/16(木) 20:39:00ID:4CJdjj+H
~/SDL-1.2.9/testにて
cc testwin.c `sdl-config --cflags --libs`を実行すると

cc: sdl-config --cflags --libs: No such file or directory
testwin.c:12:17: SDL.h: No such file or directory
testwin.c:14: error: parse error before '*' token
testwin.c: In function `DrawPict':
testwin.c:17: error: `SDL_Surface' undeclared (first use in this function)
testwin.c:17: error: (Each undeclared identifier is reported only once
testwin.c:17: error: for each function it appears in.)
testwin.c:17: error: `picture' undeclared (first use in this function)
testwin.c:18: error: `SDL_Rect' undeclared (first use in this function)
testwin.c:18: error: parse error before "dest"
testwin.c:21: error: `SDL_Color' undeclared (first use in this function)
testwin.c:21: error: `colors' undeclared (first use in this function)
testwin.c:21: error: `cmap' undeclared (first use in this function)
testwin.c:24: error: `bmpfile' undeclared (first use in this function)
testwin.c:38: error: parse error before ')' token
testwin.c:39: error: parse error before ')' token
testwin.c:47: error: parse error before ')' token
testwin.c:48: error: parse error before ')' token
testwin.c:63: error: `screen' undeclared (first use in this function)
testwin.c:73: error: `Uint32' undeclared (first use in this function)
testwin.c:73: error: parse error before "black"
testwin.c:74: error: `Uint8' undeclared (first use in this function)
testwin.c:74: error: `pixels' undeclared (first use in this function)
testwin.c:76: error: `black' undeclared (first use in this function)
testwin.c:77: error: parse error before ')' token
testwin.c:88: error: `speedy' undeclared (first use in this function)
testwin.c:89: error: `displayfmt' undeclared (first use in this function)
0975名前は開発中のものです。2006/02/16(木) 20:40:31ID:4CJdjj+H
testwin.c:102: error: `SDL_HWSURFACE' undeclared (first use in this function)
testwin.c:107: error: `dest' undeclared (first use in this function)
testwin.c:113: error: `update' undeclared (first use in this function)
testwin.c:118: error: `flip' undeclared (first use in this function)
testwin.c:135: error: `nofade' undeclared (first use in this function)
testwin.c:137: error: parse error before "final"
testwin.c:140: error: parse error before "Sint16"
testwin.c:140: warning: no semicolon at end of struct or union
testwin.c:141: error: `cdist' undeclared (first use in this function)
testwin.c:145: error: `maxstep' undeclared (first use in this function)
testwin.c:146: error: `final' undeclared (first use in this function)
testwin.c:149: error: `palcolors' undeclared (first use in this function)
testwin.c:96: error: label `done' used but not defined
testwin.c: At top level:
testwin.c:220: error: parse error before ':' token
testwin.c:223: warning: parameter names (without types) in function declaration
testwin.c:223: error: conflicting types for `free'
/usr/include/stdlib.h:136: error: previous declaration of `free'
testwin.c:223: warning: data definition has no type or storage class
testwin.c:223: warning: parameter names (without types) in function declaration
testwin.c:223: warning: data definition has no type or storage class
testwin.c:224: error: parse error before "return"
0976名前は開発中のものです。2006/02/16(木) 20:41:22ID:4CJdjj+H
testwin.c: In function `main':
testwin.c:229: error: `SDL_Surface' undeclared (first use in this function)
testwin.c:229: error: `screen' undeclared (first use in this function)
testwin.c:235: error: `Uint32' undeclared (first use in this function)
testwin.c:235: error: parse error before "video_flags"
testwin.c:247: error: `video_flags' undeclared (first use in this function)
testwin.c:302: error: `SDL_HWPALETTE' undeclared (first use in this function)
testwin.c:307: error: `SDL_HWSURFACE' undeclared (first use in this function)
testwin.c:312: error: `SDL_DOUBLEBUF' undeclared (first use in this function)
testwin.c:317: error: `SDL_FULLSCREEN' undeclared (first use in this function)
testwin.c:324: error: `SDL_INIT_VIDEO' undeclared (first use in this function)
testwin.c:329: error: `SDL_Quit' undeclared (first use in this function)
testwin.c:353: error: `then' undeclared (first use in this function)
testwin.c:355: error: `now' undeclared (first use in this function)
0977名前は開発中のものです。2006/02/16(木) 21:18:11ID:/cQBzdnu
>>974 とりあえずはこれでいいかも

cc testwin.c -I. -D_THREAD_SAFE -L. -lSDLmain -lSDL -framework Cocoa -framework OpenGL

シェルの使用法がわかっていないようなので、
先にそちらを理解してからのほうがいいと思う。
0978名称未設定2006/02/16(木) 21:31:05ID:6HFR4Et4
ヒマだから付き合うけど

書き方が悪かったかもしれないけど、別に bash を使え、と強制しているわけじゃないよ。
Linux ユーザーには bash を使う人が多いので、その分情報収集に有利かもしれないけど。

~/SDL-1.2.9 とは $HOME/SDL-1.2.9 のことで、 Mac OS X では普通は
/Users/$USER のこと。 $USER は >>976 のユーザー名ね。
~/SDL-1.2.9 にパスを通したいなら、

export PATH="/Users/nanashitan/SDL-1.2.9:$PATH"

なり、

export PATH="~/SDL-1.2.9:$PATH"

なり書く必要がある。 >>973 で書いた書き方 (export PATH=$PATH":/SDL-1.2.9") だと、
起動ディスクの直下に SDL-1.2.9 を置いていて、そこにパスを通したい場合の書き方になる。
(古めかしい書き方だと Macintosh HD:SDL-1.2.9: とかいうことね。)

起動ディスクの直下にモノをごちゃごちゃ置くのはお勧めできないので、
>それはさておき /SDL-1.2.9 に入れてそこにパス通すのはどんなもんよ。
みたいなツッコミが入ることになる。
0979名称未設定2006/02/16(木) 21:47:01ID:6HFR4Et4
で、パスを通す、の意味なんだが…

>>973 は ~/SDL-1.2.9 にコマンドを置いているので、何も考えずに
$ ~/SDL-1.2.9/sdl-config

とコマンドを入力しても正しく動作するのだよ。いちいち ~/SDL-1.2.9 と
タイプするのが面倒な人は、環境変数 PATH に ~/SDL-1.2.9 を追加しておく、と。
で、環境変数の設定方法が bash では export だ、ということ。

SDL のインストールが(ソースからやったなら make install まで)終わっているなら、
おそらく /usr/local/bin に sdl-config もインストールされていると思うので、
/usr/local/bin/sdl-config としてもいいし、 PATH に /usr/local/bin を登録しておくのもよいかと。

俺の場合、 Fink っつーパッケージ管理システムを使っているので、
/usr/local は使わないことにしているんだけどね。これは余談。

あと、 `` は、中のコマンドの出力結果で置き換えるためのカッコ。
>>977 を見ればピンとくるだろうか。

いろいろシェルの使い方を検索しつつがんばれ。
個人的にはまっさらに無知な春休みの学生が最低限どれだけの知識があれば
開発を始められるのか、興味深いところではあるw
0980名前は開発中のものです。2006/02/16(木) 22:24:14ID:4CJdjj+H
ID:6HFR4Et4さんありがとうございます!!
おかげさまでパス通りました!

>>977さんのコンパイル方法をやってみましたが
全く同じエラーが出たのでまだ入れなければいけないものがあるんでしょうね
本家サイトからとってきて試したいと思います
0981& ◆F7sVjZIqRE 2006/02/16(木) 22:28:20ID:6HFR4Et4
まったく同じじゃないでしょう。少なくとも
「cc: sdl-config --cflags --libs: No such file or directory」の行が消えたはず。
エラーのはじまりと終わりは重要なことが多いので、気をつけて。

で、 /usr/local/lib とか /usr/local/include が
Mac OS X ではデフォルトでリンカのパスに含まれていないので、

gcc のコマンドラインに -I/usr/local/include -L/usr/local/lib を入れてみな。
0982名称未設定2006/02/16(木) 22:32:32ID:6HFR4Et4
っと。間違えた。ごめ。
とりあえず、パスが通ったんなら

cc testwin.c `sdl-config --cflags --libs`

を初心に返って試してみなされ。
0983名前は開発中のものです。2006/02/16(木) 22:36:59ID:4CJdjj+H
コンパイルできちゃいました…
でも実行はどうやって?
./testwinではないのでしょうか?
重ね重ねすいません…
0984名称未設定2006/02/16(木) 22:54:48ID:6HFR4Et4
ここからはSDLスレの住人の出番ではなかろうか。
とりあえず、エスパー的に回答すると

cc のコマンドラインに -o testwin を付けてみればいいに 1ペリカ。
0985名前は開発中のものです。2006/02/16(木) 23:55:15ID:4CJdjj+H
ID:6HFR4Et4さんtestwin実行成功しました
ありがとうございました

いろいろサンプルプログラムを実行していましたがSDL_imageなしで画像を読み込んで使っているプログラムがありましたが
SDL_imageはどのような場合に必要なのでしょうか?これなしでは画像は使えないと思っていました…
0986名前は開発中のものです。2006/02/17(金) 00:18:25ID:9Dty7h0+
すいません、よく考えたら聞き過ぎですね(汗
自分でがんばってみます。
ありがとうございました。
0987名前は開発中のものです。2006/02/17(金) 05:35:05ID:PbVp7kBa
>>985
ttp://zinnia.dyndns.org/~cvsweb/sdldoc-jp/
ここのリファレンスをよくみれば、BMPファイルを読み込み
扱う機能があることはわかる

SDL_imageはその他のいろいろな形式の画像ファイルを
読み込む機能を提供してくれているだけ
ただ、SDL_imageやSDL_gfxなど、補助ライブラリについても
詳しく知りたいなら英語のドキュメントを覚悟してください
レス数が950を超えています。1000を超えると書き込みができなくなります。