MCPcopy Create free account
hub / github.com/SpartanJ/eepp / mainLoop

Function mainLoop

src/examples/external_shader/external_shader.cpp:90–198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88using namespace Demo_ExternalShader;
89
90void mainLoop() {
91 win->clear();
92
93 imp->update();
94
95 if ( imp->isKeyDown( KEY_ESCAPE ) ) {
96 win->close();
97 }
98
99 if ( imp->isKeyUp( KEY_F ) ) {
100 if ( win->isWindowed() ) {
101 win->setSize( win->getDesktopResolution().getWidth(),
102 win->getDesktopResolution().getHeight(), false );
103 } else {
104 win->setSize( 960, 640, true );
105 win->centerToDisplay();
106 }
107 }
108
109 Float p;
110 Vector2f mf = imp->getMousePos().asFloat();
111 Float tratio = tw / th;
112 Float touchX = ( mf.x / tw - 1 ) * tratio;
113 Float touchY = -( mf.y / th - 1 );
114 bool touch = imp->isMouseLeftPressed();
115
116 for ( Uint32 i = 0; i < ParticlesNum; i += 2 ) {
117 // copy old positions
118 vertices[i].x = vertices[i + 1].x;
119 vertices[i].y = vertices[i + 1].y;
120
121 // inertia
122 velocities[i].x *= velocities[i].z;
123 velocities[i].y *= velocities[i].z;
124
125 // horizontal
126 p = vertices[i + 1].x;
127 p += velocities[i].x;
128
129 if ( p < -aspectRatio ) {
130 p = -aspectRatio;
131 velocities[i].x = eeabs( velocities[i].x );
132 } else if ( p > aspectRatio ) {
133 p = aspectRatio;
134 velocities[i].x = -eeabs( velocities[i].x );
135 }
136 vertices[i + 1].x = p;
137
138 // vertical
139 p = vertices[i + 1].y;
140 p += velocities[i].y;
141 if ( p < -aspectRatio ) {
142 p = -aspectRatio;
143 velocities[i].y = eeabs( velocities[i].y );
144 } else if ( p > aspectRatio ) {
145 p = aspectRatio;
146 velocities[i].y = -eeabs( velocities[i].y );
147 }

Callers

nothing calls this directly

Calls 15

eeabsFunction · 0.85
randfFunction · 0.85
MillisecondsFunction · 0.85
isKeyDownMethod · 0.80
isKeyUpMethod · 0.80
isWindowedMethod · 0.80
centerToDisplayMethod · 0.80
isMouseLeftPressedMethod · 0.80
drawArraysMethod · 0.80
displayMethod · 0.80
closeMethod · 0.65
clearMethod · 0.45

Tested by

no test coverage detected