MCPcopy Create free account
hub / github.com/HackerPoet/FractalSoundExplorer / main

Function main

Main.cpp:308–610  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

306INT WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR lpCmdLine, INT nCmdShow) {
307#else
308int main(int argc, char *argv[]) {
309#endif
310 //Make sure shader is supported
311 if (!sf::Shader::isAvailable()) {
312 std::cerr << "Graphics card does not support shaders" << std::endl;
313 return 1;
314 }
315
316 //Load the vertex shader
317 sf::Shader shader;
318 if (!shader.loadFromFile("vert.glsl", sf::Shader::Vertex)) {
319 std::cerr << "Failed to compile vertex shader" << std::endl;
320 system("pause");
321 return 1;
322 }
323
324 //Load the fragment shader
325 if (!shader.loadFromFile("frag.glsl", sf::Shader::Fragment)) {
326 std::cerr << "Failed to compile fragment shader" << std::endl;
327 system("pause");
328 return 1;
329 }
330
331 //Load the font
332 sf::Font font;
333 if (!font.loadFromFile("RobotoMono-Medium.ttf")) {
334 std::cerr << "Failed to load font" << std::endl;
335 system("pause");
336 return 1;
337 }
338
339 //Create the full-screen rectangle to draw the shader
340 sf::RectangleShape rect;
341 rect.setPosition(0, 0);
342
343 //GL settings
344 sf::ContextSettings settings;
345 settings.depthBits = 24;
346 settings.stencilBits = 8;
347 settings.antialiasingLevel = 4;
348 settings.majorVersion = 3;
349 settings.minorVersion = 0;
350
351 //Create the window
352 sf::RenderWindow window;
353 sf::RenderTexture renderTexture;
354 bool is_fullscreen = false;
355 bool toggle_fullscreen = false;
356 make_window(window, renderTexture, settings, is_fullscreen);
357
358 //Create audio synth
359 Synth synth(window.getSystemHandle());
360
361 //Setup the shader
362 shader.setUniform("iCam", sf::Vector2f((float)cam_x, (float)cam_y));
363 shader.setUniform("iZoom", (float)cam_zoom);
364 SetFractal(shader, starting_fractal, synth);
365

Callers

nothing calls this directly

Calls 8

make_windowFunction · 0.85
SetFractalFunction · 0.85
resize_windowFunction · 0.85
ScreenToPtFunction · 0.85
PtToScreenFunction · 0.85
playMethod · 0.80
SetPointMethod · 0.80
stopMethod · 0.80

Tested by

no test coverage detected