// sdl강좌1.cpp : 콘솔 응용 프로그램에 대한 진입점을 정의합니다.
//
#include "stdafx.h"
#include <SDL.h>
#pragma comment (lib,"SDL")
#pragma comment (lib,"SDLmain")
#include <SDL_ttf.h>
#pragma comment (lib,"SDL_ttf")
#include "han2unicode.h"
SDL_Surface *screen;
TTF_Font *font;
SDL_Surface *text;
void DrawSurface(SDL_Surface *dst,int x,int y,SDL_Surface *src){
SDL_Rect rectDst;
rectDst.x = x;
rectDst.y = y;
SDL_BlitSurface(src,NULL,dst,&rectDst);
}
void DrawSprite(SDL_Surface *screen,int x,int y,SDL_Surface *surface,int w,int h,int step){
SDL_Rect rectDst,rectSrc;
rectDst.x = x;
rectDst.y = y;
rectSrc.x = (step % w) * surface->w/w;
rectSrc.y = (step / w) * surface->h/h;
rectSrc.w = surface->w/w;
rectSrc.h = surface->h/h;
SDL_BlitSurface(surface,&rectSrc,screen,&rectDst);
};
void Render(){
DrawSurface(screen,0,0,text);
SDL_Flip(screen);
}
int main(int argc,char **argv){
SDL_Init(SDL_INIT_VIDEO);
TTF_Init();
screen = SDL_SetVideoMode(640,480,32,SDL_HWSURFACE | SDL_DOUBLEBUF);
font = TTF_OpenFont("c:\\windows\\fonts\\gulim.ttc",15);
SDL_Color color;
color.r = 255;
color.g = 255;
color.b = 255;
unsigned short unicode[128];
han2unicode("안녕세계야",unicode);
text = TTF_RenderUNICODE_Blended(font,unicode,color);
bool quit = false;
SDL_Event event;
while(!quit){
if(SDL_PollEvent(&event)){
switch(event.type){
case SDL_QUIT:
quit = true;
break;
}
}
Render();
SDL_Delay(100);
}
TTF_Quit();
SDL_Quit();
return 0;
}