public void Paint(object sender, PaintEventArgs e) { if (null == sender) { return; } if (false == (sender is GRControl)) { return; } GRControl grControl = (sender as GRControl); GR gr = grControl.GetGR( ); int clientWidth = grControl.ClientRectangle.Width; int clientHeight = grControl.ClientRectangle.Height; if (clientWidth <= 0) { clientWidth = 1; } if (clientHeight <= 0) { clientHeight = 1; } // Viewport gr.glViewport(0, 0, clientWidth, clientHeight); // Clear the viewport gr.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); gr.glClear(GR.GL_COLOR_BUFFER_BIT | GR.GL_DEPTH_BUFFER_BIT); // Basic rendering conditions gr.glEnable(GR.GL_DEPTH_TEST); gr.glDepthFunc(GR.GL_LEQUAL); gr.glEnable(GR.GL_CULL_FACE); gr.glCullFace(GR.GL_BACK); gr.glFrontFace(GR.GL_CCW); gr.glMatrixMode(GR.GL_PROJECTION); gr.glLoadIdentity( ); gr.gluOrtho2D(0.0, (double)clientWidth, 0.0, (double)clientHeight); gr.glMatrixMode(GR.GL_MODELVIEW); gr.glLoadIdentity( ); // TETRIS GAME ITERATION STUserInterface.PerformGameIterations ( STEngine.GetGame( ), grControl.GetPreviousFrameDurationSeconds( ) ); // TETRIS GAME DRAWING System.Drawing.Point controlRelativePoint = grControl.PointToClient(Cursor.Position); int clientRelativeCursorX = controlRelativePoint.X; int clientRelativeCursorY = controlRelativePoint.Y; STGameDrawing.DrawScreen ( clientWidth, clientHeight, clientRelativeCursorX, clientRelativeCursorY, gr, STEngine.GetGame( ), STEngine.GetConsole( ) ); // Flush all the current rendering and flip the back buffer to the front. gr.wglSwapBuffers(grControl.GetHDC( )); }