void Render(double time) { gl.Clear().ColorBuffer().DepthBuffer(); auto camera = CamMatrixf::Orbiting( Vec3f(), field.Radius()*(1.4 + SineWave(time / 6.0) * 0.2), FullCircles(time * 0.1), Degrees(SineWave(time / 30.0) * 90) ); auto light = CamMatrixf::Orbiting( Vec3f(), field.Radius()*1.6, FullCircles(0.33-time * 0.07), Degrees(SineWave(time / 31.0) * 80) ); prog.camera_matrix.Set(camera); prog.light_position.Set(light.Position()); GLfloat fade_coef = 1.1*(1.0-CosineWave01(time / 90.0)); prog.fade_coef.Set(fade_coef); field.Draw(); }
LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) { static Field field; HDC hDc; PAINTSTRUCT ps; static POINT from; static POINT to; static int a = 0; switch( message ) { case WM_PAINT: { HDC mem = CreateCompatibleDC( 0 ); hDc = BeginPaint( hWnd, &ps ); field.Draw( hDc ); if( a >= 2 ) { int fromCol = from.x / SQUARE_SIZE - 1; int fromRow = from.y / SQUARE_SIZE - 1; int destCol = to.x / SQUARE_SIZE - 1; int destRow = to.y / SQUARE_SIZE - 1; // if( !field.Get( fromRow, fromCol ).isFilled ) // return 0; bool isSucMove = field.Move( hDc, fromRow, fromCol, destRow, destCol ); Coordinate coordinate; coordinate.row = destCol; coordinate.col = destRow; CircleGroup cg; cg = field.GetSameColoredCircles( coordinate ); if( !field.EraseCircles( cg ) && isSucMove && ( ( fromCol != destCol ) && ( fromRow != destRow ) ) ) { field.FillWithRandColors( ); } a = 0; } field.Draw( hDc ); EndPaint( hWnd, &ps ); break; } case WM_LBUTTONDOWN: { if( a == 0 ) { from.x = LOWORD( lParam ); from.y = HIWORD( lParam ); } else { to.x = LOWORD( lParam ); to.y = HIWORD( lParam ); InvalidateRect( hWnd, 0, TRUE ); } a ++; break; } case WM_DESTROY: { PostQuitMessage( 0 ); break; } default: { return DefWindowProc( hWnd, message, wParam, lParam ); } } return 0; }