I've been following both the FreeType2 tutorial and the WikiBooks tuorial, trying to combine things from them both in order to load and render fonts using the FreeType library. I used the font loading code from the FreeType2 tutorial and tried to implement the rendering code from the wikibooks tutorial (tried being the keyword as I'm still trying to learn model OpenGL, I'm using 3.2). Everything loads correctly and I have the shader program to render the text with working, but I can't get the text to render. I'm 99% sure that it has something to do with how I cam passing data to the shader, or how I set up the screen.
These are the code segments that handle OpenGL initialization, as well as Font initialization and rendering:
//Init glfw
if (!glfwInit())
{
fprintf(stderr, "GLFW Initialization has failed!\n");
exit(EXIT_FAILURE);
}
printf("GLFW Initialized.\n");
//Process the command line arguments
processCmdArgs(argc, argv);
//Create the window
glfwWindowHint(GLFW_SAMPLES, g_aaSamples);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
g_mainWindow = glfwCreateWindow(g_screenWidth, g_screenHeight, "Voxel Shipyard", g_fullScreen ? glfwGetPrimaryMonitor() : nullptr, nullptr);
if (!g_mainWindow)
{
fprintf(stderr, "Could not create GLFW window!\n");
closeOGL();
exit(EXIT_FAILURE);
}
glfwMakeContextCurrent(g_mainWindow);
printf("Window and OpenGL rendering context created.\n");
glClearColor(0.2f, 0.2f, 0.2f, 1.0f);
//Are these necessary for Modern OpenGL (3.0+)?
glViewport(0, 0, g_screenWidth, g_screenHeight);
glOrtho(0, g_screenWidth, g_screenHeight, 0, -1, 1);
//Init glew
int err = glewInit();
if (err != GLEW_OK)
{
fprintf(stderr, "GLEW initialization failed!\n");
fprintf(stderr, "%s\n", glewGetErrorString(err));
closeOGL();
exit(EXIT_FAILURE);
}
printf("GLEW initialized.\n");
Here is the font file (it's slightly too big to post): CFont.h/CFont.cpp
Here is the solution zipped up: [solution]
(https://dl.dropboxusercontent.com/u/36062916/VoxelShipyard.zip), if anyone feels they need the entire solution. If anyone could take a look at the code, it would be greatly appreciated.
Also if someone has a tutorial that is a little more user friendly, that would also be appreciated.
Thanks.