Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SDL_ttf

2 views
Skip to first unread message

�������

unread,
Sep 15, 2009, 10:21:00 AM9/15/09
to
������ ����.

���� ������� ���, ������� ������� ������� ����������� SDL_ttf. �ӣ ��������.
������, ���� � ��� �������� ������������ ������� ������ � ����� ������� �
����������� �� ������� �������, ��������, ��� ������� ������� - ����� ������
�� ������������.
����������, ����������.
���������� gcc(mingw), �������� Dev-C++
�������.

H��� ����������� ���.

#include <cstdlib>
#include <iostream>
#include <SDL/SDL.h>
#include <stdio.h>
#include <SDL/SDL_ttf.h>


using namespace std;
//void print_ttf(SDL_Surface *screen, char* message, char* font, int size,
SDL_Color color, SDL_Rect dest);

void draw(SDL_Surface *screen);

int main (int argc, char *argv[])
{
if ( SDL_Init(SDL_INIT_AUDIO|SDL_INIT_VIDEO) < 0 )
{
printf("Unable to init SDL: %s\n", SDL_GetError());
exit(1);
}

SDL_Surface *screen;
putenv("SDL_VIDEO_WINDOW_POS=50,50");

screen=SDL_SetVideoMode(800,600,32,SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_NOFRAME);

if ( screen == NULL )
{
printf("Unable to set 640x480 video: %s\n", SDL_GetError());
exit(1);
}
//���� ����� �����������, �� ��������
//draw(screen);

int done=0;

while(done == 0){

SDL_Event event;
while ( SDL_PollEvent(&event) ){

if ( event.type == SDL_QUIT ){
done = 1;
}

if ( event.type == SDL_KEYDOWN ){

if ( event.key.keysym.sym == SDLK_ESCAPE ){
done = 1;
}
if ( event.key.keysym.sym == SDLK_SPACE ){
draw (screen);
}
}

}
}
SDL_Quit();
return EXIT_SUCCESS;
}

void draw(SDL_Surface *screen){
cout << "Yes" <<endl;

TTF_Init();
SDL_Color clr;
clr.r = 255;
clr.g = 255;
clr.b = 0;
SDL_Rect dest;
dest.x = 0;
dest.y = 0;

TTF_Font *fnt = TTF_OpenFont("Unreal.TTF", 34);
SDL_Surface *sText = TTF_RenderText_Blended( fnt, "Test", clr);
SDL_BlitSurface( sText,NULL, screen, &dest );
SDL_FreeSurface( sText );

TTF_CloseFont( fnt );

//print_ttf(screen, "����", "Unreal.TTF", 34, clr, dest);
TTF_Quit();
}

//void print_ttf(SDL_Surface *screen, char *message, char* font, int size,
SDL_Color clr, SDL_Rect dest){

// TTF_Font *fnt = TTF_OpenFont(font, size);
// SDL_Surface *sText = TTF_RenderText_Blended( fnt, message, clr);
// SDL_BlitSurface( sText,NULL, screen,&dest );
// SDL_FreeSurface( sText );
// TTF_CloseFont( fnt );
//}

�������

unread,
Sep 15, 2009, 10:34:02 AM9/15/09
to
SDL_Flip(screen);


Tue Sep 15 2009 20:21, ������� wrote to All:

�> From: "�������" <kvit...@mail.ru>

�> ������ ����.

�> H��� ����������� ���.

�> void draw(SDL_Surface *screen);

�> );

�> if ( screen == NULL )

0 new messages