-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
114 lines (89 loc) · 2.78 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#include <SDL2/SDL.h>
#include <SDL2/SDL_ttf.h>
#include <SDL2/SDL_image.h>
#define GLEW_STATIC
#include <GL/glew.h>
#include <glm/glm.hpp>
#include <ft2build.h>
#include FT_FREETYPE_H
#include <iostream>
#include <stdio.h>
int main()
{
///////////////////////
// Make sure SDL2 inits
///////////////////////
if (SDL_Init(SDL_INIT_VIDEO) != 0)
{
std::cout << "SDL_Init Error: " << SDL_GetError() << std::endl;
return 1;
}
///////////////////////////
// Make sure SDL2_ttf inits
///////////////////////////
SDL_version compileVersion;
SDL_TTF_VERSION(&compileVersion);
const SDL_version* ttfLinkVersion = TTF_Linked_Version();
printf("compiled with SDL_ttf version: %d.%d.%d\n",
compileVersion.major,
compileVersion.minor,
compileVersion.patch);
printf("running with SDL_ttf version: %d.%d.%d\n",
ttfLinkVersion->major,
ttfLinkVersion->minor,
ttfLinkVersion->patch);
if(TTF_Init() == -1)
{
printf("TTF_Init: %s\n", TTF_GetError());
return 1;
}
/////////////////////////////
// Make sure SDL2_image inits
/////////////////////////////
SDL_IMAGE_VERSION(&compileVersion);
const SDL_version *imgLinkVersion = IMG_Linked_Version();
printf("compiled with SDL_image version: %d.%d.%d\n",
compileVersion.major,
compileVersion.minor,
compileVersion.patch);
printf("running with SDL_image version: %d.%d.%d\n",
imgLinkVersion->major,
imgLinkVersion->minor,
imgLinkVersion->patch);
int flags = IMG_INIT_JPG | IMG_INIT_PNG;
int initted = IMG_Init(flags);
if(initted & flags != flags) {
printf("IMG_Init: Failed to init required jpg and png support!\n");
printf("IMG_Init: %s\n", IMG_GetError());
return 1;
}
///////////////////////
// Make sure GLEW works
///////////////////////
SDL_Window* window = SDL_CreateWindow("test", 0, 0, 100, 100, SDL_WINDOW_OPENGL);
SDL_GLContext glContext = SDL_GL_CreateContext(window);
glewExperimental = GL_TRUE;
if (glewInit() != GLEW_OK)
{
std::cout << "Failed to initialize GLEW" << std::endl;
return 1;
}
SDL_Quit();
////////////////////////
// Make sure we link glm
////////////////////////
glm::vec3 v = glm::vec3(1.0f, 1.0f, 0.0f);
std::cout << "vector length: " << glm::length(v) << std::endl;
///////////////////////////
// Make sure FreeType inits
///////////////////////////
FT_Library ft;
if (FT_Init_FreeType(&ft))
{
std::cout << "Could not initialize FreeType" << std::endl;
return 1;
}
FT_Done_FreeType(ft);
////////////////
return 0;
}