MCPcopy Create free account
hub / github.com/InkboxSoftware/all-screen-keyboard / initialize

Method initialize

keyboard/src/graphics.cpp:124–223  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

122}
123
124int window::initialize(int windowWidth, int windowHeight, bool fullScreen){
125 this->windowWidth = windowWidth;
126 this->windowHeight = windowHeight;
127 //init SDL
128 SDL_Init(SDL_INIT_VIDEO);
129 //init window var
130 window = NULL;
131 //create OpenGL context
132 glContext = NULL;
133
134 shader = new shader_h();
135
136 //request OpenGL ES 3.0
137 SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
138 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
139 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
140
141 //force usage of GLES backend
142 SDL_SetHint(SDL_HINT_OPENGL_ES_DRIVER, "1");
143
144 //double buffering
145 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
146
147 //create window
148 int fullscreenVal = SDL_WINDOW_FULLSCREEN;
149 if (!fullScreen){
150 fullscreenVal = 0;
151 }
152
153 window = SDL_CreateWindow("Keyboard", SDL_WINDOWPOS_CENTERED,
154 SDL_WINDOWPOS_CENTERED, windowWidth, windowHeight, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | fullscreenVal);
155 //disable mouse
156 SDL_ShowCursor(SDL_DISABLE);
157
158 //create context
159 glContext = SDL_GL_CreateContext(window);
160
161
162 //load the texture shader program
163 textureShaderProgram = loadShaderProgram("src/shaders/texture.vert", "src/shaders/texture.frag");
164 if (!textureShaderProgram){
165 return -1;
166 }
167 //load the color shader program
168 colorShaderProgram = loadShaderProgram("src/shaders/colorShape.vert", "src/shaders/colorShape.frag");
169 if (!colorShaderProgram){
170 return -1;
171 }
172 //load the text shader program
173 textShaderProgram = loadShaderProgram("src/shaders/text.vert", "src/shaders/text.frag");
174 if (!textShaderProgram){
175 return -1;
176 }
177
178 //GLint textureSamplerUniformLocation to set which texture unit to use later
179 textureSamplerUniformLocation = glGetUniformLocation(textureShaderProgram, "textureSampler");
180 if (textureSamplerUniformLocation < 0){
181 SDL_Log("Could not get textureSampler's location");

Callers 1

keyboardMethod · 0.45

Calls 2

textureLoadFunction · 0.85
vaoTextCreateFunction · 0.70

Tested by

no test coverage detected