| 88 | using namespace Demo_ExternalShader; |
| 89 | |
| 90 | void 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 | } |
nothing calls this directly
no test coverage detected