Okay i am learning tons here as i go , sorry but i need to paste a bit of code here. The end result of this code is nothing , i have probably made a mistake in my understanding of SDL ... so any pointers as to why (no pun intended) woud be most welcome. (i have bolded the area where i think it has all gone to hell)..... :blink:
#include <stdlib.h>
#include <unistd.h>
#include "SDL.h"
#include "SDL_ttf.h"
int main(int argc, char *argv[])
{
FILE *OutFilePtr;
OutFilePtr = fopen("/mnt/sd/ebook/debug.txt","w");
SDL_Surface *screen;
int done = 0;
if (SDL_Init(SDL_INIT_VIDEO) < 0)
return 1;
screen = SDL_SetVideoMode(320, 240, 16, SDL_SWSURFACE);
if (!screen)
{
fprintf(OutFilePtr, "Couldn't set video mode: %s\n", SDL_GetError());
return 1;
}
int i = fprintf(OutFilePtr,"Debug ouput!\n");
SDL_ShowCursor(SDL_DISABLE);
if(TTF_Init()==-1)
{
i = fprintf(OutFilePtr,"TTF init failed");
fprintf(OutFilePtr, "TTF_Init: %s\n", TTF_GetError());
exit(2);
}
//FreeMono.ttf
// load font.ttf at size 10 into font
TTF_Font *font;
font=TTF_OpenFont("/mnt/sd/FreeMono.ttf", 10);
if(!font)
{
i = fprintf(OutFilePtr,"Open font file failed.");
fprintf(OutFilePtr, "TTF_OpenFont: %s\n", TTF_GetError());
}
SDL_Color color={0, 0, 255,0};
i = fprintf(OutFilePtr,"had a bash at doing it\n");
SDL_Surface *text_surface=TTF_RenderText_Solid(font,"Hello World!",color);
SDL_Rect rcDest = {20,50,0,0};
SDL_BlitSurface(text_surface,NULL,screen,&rcDest);
SDL_FreeSurface(text_surface);
i = fprintf(OutFilePtr,"Done out of here\n");
fflush(OutFilePtr);
fclose(OutFilePtr);
sync();
done=0;
SDL_Flip(text_surface);
while (!done)
{
SDL_Event event;
SDL_WaitEvent(&event);
switch (event.type)
{
case SDL_KEYDOWN:
case SDL_QUIT:
done = 1;
break;
}
}
SDL_Quit();
return 0;
}
#include <stdlib.h>
#include <unistd.h>
#include "SDL.h"
#include "SDL_ttf.h"
int main(int argc, char *argv[])
{
FILE *OutFilePtr;
OutFilePtr = fopen("/mnt/sd/ebook/debug.txt","w");
SDL_Surface *screen;
int done = 0;
if (SDL_Init(SDL_INIT_VIDEO) < 0)
return 1;
screen = SDL_SetVideoMode(320, 240, 16, SDL_SWSURFACE);
if (!screen)
{
fprintf(OutFilePtr, "Couldn't set video mode: %s\n", SDL_GetError());
return 1;
}
int i = fprintf(OutFilePtr,"Debug ouput!\n");
SDL_ShowCursor(SDL_DISABLE);
if(TTF_Init()==-1)
{
i = fprintf(OutFilePtr,"TTF init failed");
fprintf(OutFilePtr, "TTF_Init: %s\n", TTF_GetError());
exit(2);
}
//FreeMono.ttf
// load font.ttf at size 10 into font
TTF_Font *font;
font=TTF_OpenFont("/mnt/sd/FreeMono.ttf", 10);
if(!font)
{
i = fprintf(OutFilePtr,"Open font file failed.");
fprintf(OutFilePtr, "TTF_OpenFont: %s\n", TTF_GetError());
}
SDL_Color color={0, 0, 255,0};
i = fprintf(OutFilePtr,"had a bash at doing it\n");
SDL_Surface *text_surface=TTF_RenderText_Solid(font,"Hello World!",color);
SDL_Rect rcDest = {20,50,0,0};
SDL_BlitSurface(text_surface,NULL,screen,&rcDest);
SDL_FreeSurface(text_surface);
i = fprintf(OutFilePtr,"Done out of here\n");
fflush(OutFilePtr);
fclose(OutFilePtr);
sync();
done=0;
SDL_Flip(text_surface);
while (!done)
{
SDL_Event event;
SDL_WaitEvent(&event);
switch (event.type)
{
case SDL_KEYDOWN:
case SDL_QUIT:
done = 1;
break;
}
}
SDL_Quit();
return 0;
}