[ create a new paste ] login | about

Link: http://codepad.org/qcDhqmZH    [ raw code | output | fork ]

C++, pasted on Jan 5:
// 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;
}


Output:
1
2
3
4
5
6
7
8
9
10
Line 19: error: stdafx.h: No such file or directory
Line 16: error: SDL.h: No such file or directory
cc1plus: warnings being treated as errors
Line 9: warning: ignoring #pragma comment 
Line 10: warning: ignoring #pragma comment 
Line 20: error: SDL_ttf.h: No such file or directory
Line 13: warning: ignoring #pragma comment 
Line 24: error: han2unicode.h: No such file or directory
Line 17: error: expected constructor, destructor, or type conversion before '*' token
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: