Right. I used VS Express 2012 to compile the following code:
- {l Code}: {l Select All Code}
#include "SDL.h"
#include "SDL_ttf.h"
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char** argv) {
// SDL vars...
SDL_Window *window = nullptr;
SDL_Renderer *renderer = nullptr;
// Setting up SDL...
if (SDL_Init(SDL_INIT_EVERYTHING) == -1) {
cout << SDL_GetError() << endl;
return 1;
}
// ...create the window...
window = SDL_CreateWindow("Input-Test", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, SDL_WINDOW_SHOWN);
if (window == nullptr) {
cout << SDL_GetError() << endl;
return 1;
}
// ...and the renderer.
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
if (renderer == nullptr) {
cout << SDL_GetError() << endl;
return 1;
}
// Set up TTF.
if (TTF_Init() != 0) {
string msg = TTF_GetError();
cout << msg << endl;
}
// Background
SDL_Rect backgroundRect;
backgroundRect.x = 0;
backgroundRect.y = 0;
backgroundRect.w = 640;
backgroundRect.h = 480;
// Load the font.
TTF_Font *font = TTF_OpenFont("VeraMono.ttf", 18);
if (font == nullptr) {
string msg = TTF_GetError();
cout << msg << endl;
return 1;
}
SDL_Color fontColor = {255,255,255,255};
SDL_Surface *fontSurface = TTF_RenderText_Blended(font, "Press c to open console, Esc to abort and Enter to confirm.", fontColor);
SDL_Texture *fontTexture = SDL_CreateTextureFromSurface(renderer, fontSurface);
// The main loop.
bool quit = false;
SDL_Event event;
while (!quit) {
// Events and updates...
while (SDL_PollEvent(&event)) {
if (event.type == SDL_QUIT)
quit = true;
if (event.type == SDL_KEYDOWN) {
if (event.key.keysym.sym == SDLK_q) {
quit = true;
}
}
}
// Draw stuff.
SDL_RenderClear(renderer);
SDL_SetRenderDrawColor(renderer, 51, 130, 152, 0);
SDL_RenderFillRect(renderer, &backgroundRect);
SDL_RenderCopy(renderer, fontTexture, nullptr, nullptr);
SDL_RenderPresent(renderer);
SDL_Delay(10);
}
TTF_CloseFont(font);
SDL_DestroyTexture(fontTexture);
SDL_FreeSurface(fontSurface);
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
TTF_Quit();
SDL_Quit();
return 0;
}
The SDL part worked, since the blue background was shown
before i included the font code, but for some reasons i can't load the font.
I also checked file permission.
The directory looks like this, so I guess, no file is missing.

- the folder content
- dir.png (16.02 KiB) Viewed 11649 times
Thanks for your help!
Edit: Forgot to mention, i compile this on Windows 7 64 as 32 bit file.
Edit 2: I found the problems.
* For suspicious reasons the executable has to be started without the visual studio debugger, because VS fails at loading ressources like fonts or images in SDL.
*
For another strange reason (unlike in my image test project) the executable expects the font file to be placed in project folder, not in the executable folder. 
Sometimes, it works, sometimes not... Very strange.
It's stuff like this which makes me wish for the simple gcc toolchain.