SDL_VKPToolkit
昨日(http://d.hatena.ne.jp/isshiki/20060628/p3)あんな事言ってたくせに、やっぱり気になったので group に入って落としてみてみた。
C++ で作られている。やっぱりそうだよねーとか思いつつ、とりあえずクラスを覗いて見ると、まあコンパクトにまとめられてるなあ、と。
- class Ch2D;
- class VKP_Keyboard;
- class VKP_Mouse;
- class VKP_Timer;
- class VKP_Sprite;
- class VKP_StdGraph;
- class VKP_MixSound;
- class VKP_Font;
- class VKP_Anim;
まあ、見れば大体何をしてるかわかるでしょうから説明は省略。
「class Ch2D」というのが親玉っぽいね。実際にはコイツに hogehoge して操作するっぽい。
「class VKP_StdGraph」は未実装。仮定義をみると、ようはプリミティブ描画用のクラスみたいね。こうなってるのよ。
他にも、サービス関数がいくつか。
class VKP_StdGraph {
public:
VKP_Sprite sgr;
Uint8 R, G, B;
Uint32 Color;VKP_StdGraph();
void SetColor(Uint8 r, Uint8 g, Uint8 b);
int CreateDrawSurface(int w, int h);
int SetPixel(int x, int y, int d, int alpha=-1, int R=-1, int G=-1, int B=-1);
int Line(int x1, int y1, int x2, int y2, int d, int alpha=-1);
int Circle(int x1, int y1, int Rad, int d, int alpha = -1);
int FillCircle(int x1, int y1, int Rad, int d, int alpha = -1);
int Rect(int x1, int y1, int x2, int y2, int d, int alpha=-1);
int FillRect(int x1, int y1, int x2, int y2, int d, int alpha=-1);
int Ellipse(int x, int y, int Radx, int Rady, int d, int alpha=-1);
int FillEllipse(int x, int y, int Radx, int Rady, int d, int alpha=-1);
int Round(int x, int y, int width, int height, int corner, int d, int alpha=-1);
int FillRound(int x, int y, int width, int height, int corner, int d, int alpha=-1);
};
- void InitSDL(void);
- int InitializeData(int argc, char* argv[]);
- void EventHandler(SDL_Event* e);
- void MainLoop(void);
- void RenderScene(void);
- void AtExit(void);
- int VKP_CollideBoundingBox(SDL_Surface *S1,int x1,int y1, SDL_Surface *S2,int x2, int y2);
- int VKP_CollidePixels(SDL_Surface *S1,int x1,int y1, SDL_Surface *S2,int x2, int y2);
- void VKP_KeepFrameRateAt(Uint16 FPS, bool ShowThem=false);
- Uint32 VKP_GetPixel(SDL_Surface *surface, int x, int y);
- int VKP_SetPixel(SDL_Surface *surface, int x, int y, Uint32 color);
- float VKP_CalculateTheta(float vx, float vy);
- Uint32** VKP_GetSurface(SDL_Surface *Src, int& w, int& h);
- int VKP_SetSurface(SDL_Surface *Dest, Uint32** Data, int w, int h);
- int VKP_DestroySurfaceDataMatrix(Uint32** Matrix, int w);
- int VKP_SetSurfaceColor(SDL_Surface *Dest, Uint8 r, Uint8 g, Uint8 b);
あと勘違いしていたのは、これは「ライブラリ」ではなく「スケルトン」であることか。まあ両者の垣根って結局何よ?と問われると返答に窮するわけだが。
で、main() とかはどうなってるかというと...
いやまーなんっつーか、スケルトン臭丸出しなソースですね。本当に(略
#include "SDL_VKPToolkit.h"
//#include "SDL_VKPFonts.h"
extern Ch2D h2D;
VKP_Sprite A;void InitSDL(void) {
h2D.SetWndText("SDL_Appl - VKPToolkit");
h2D.ScreenWidth = 640;
h2D.ScreenHeight = 480;
h2D.Set_FULLSCREEN = 0;
h2D.M.ShowCursor(true);
h2D.EscapeKEY = SDLK_ESCAPE;
h2D.SetBackground(false,196,196,196);
h2D.SleepTime=1000;
h2D.SetICON();
}int InitializeData(int argc, char* argv[]) {
// A.IMGLoad("Image.jpg");
A.IMGLoad("jake.bmp");
return 1;
}
void MainLoop(void) {
}
void RenderScene(void) {
A.Put(0,0,10);
}void AtExit(void) {
}
void EventHandler(SDL_Event* e) {
}