MCPcopy Create free account
hub / github.com/SFML/SFML / initialize

Function initialize

examples/X11/X11.cpp:24–64  ·  view source on GitHub ↗

/////////////////////////////////////////////////////// Initialize OpenGL states into the specified view \param Window Target window to initialize \return True if operation was successful, false otherwise ///////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

22///
23////////////////////////////////////////////////////////////
24[[nodiscard]] bool initialize(sf::Window& window)
25{
26 // Activate the window
27 if (!window.setActive())
28 {
29 std::cerr << "Failed to set the window as active" << std::endl;
30 return false;
31 }
32
33 // Setup OpenGL states
34 // Set color and depth clear value
35
36#ifdef SFML_OPENGL_ES
37 glClearDepthf(1.f);
38#else
39 glClearDepth(1.f);
40#endif
41
42 glClearColor(0.f, 0.5f, 0.5f, 0.f);
43
44 // Enable Z-buffer read and write
45 glEnable(GL_DEPTH_TEST);
46 glDepthMask(GL_TRUE);
47
48 // Setup a perspective projection
49 glMatrixMode(GL_PROJECTION);
50 glLoadIdentity();
51 const float extent = std::tan(sf::degrees(45).asRadians());
52
53#ifdef SFML_OPENGL_ES
54 glFrustumf(-extent, extent, -extent, extent, 1.0f, 500.0f);
55#else
56 glFrustum(-extent, extent, -extent, extent, 1.0f, 500.0f);
57#endif
58
59 // Enable position and texture coordinates vertex components
60 glEnableClientState(GL_VERTEX_ARRAY);
61 glEnableClientState(GL_COLOR_ARRAY);
62
63 return true;
64}
65
66////////////////////////////////////////////////////////////
67/// Draw the OpenGL scene (a rotating cube) into

Callers 15

JoystickManagerMethod · 0.85
SensorManagerMethod · 0.85
createMethod · 0.85
initializeMethod · 0.85
createMethod · 0.85
WindowImplX11Method · 0.85
onCreateMethod · 0.85
resizeMethod · 0.85
ImplMethod · 0.85
initializeMethod · 0.85
ImplMethod · 0.85
initializeMethod · 0.85

Calls 1

setActiveMethod · 0.45

Tested by

no test coverage detected