/// <summary> /// Handles the OpenGLDraw event of the openGLControl control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RenderEventArgs"/> instance containing the event data.</param> public void openGLControl_OpenGLDraw(object sender, RenderEventArgs e) { // Get the OpenGL object. gl = openGLControl.OpenGL; // Clear the color and depth buffer. gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); // Load the identity matrix. gl.LoadIdentity(); // Rotate around the Y axis. //gl.Rotate(rotation, 0.0f, 1.0f, 0.0f); cord = ComInput.Coordinates.Instance; this.ModelRotater(gl); gl.Enable(OpenGL.GL_BLEND); gl.BlendFunc(OpenGL.GL_SRC_ALPHA, OpenGL.GL_ONE_MINUS_SRC_ALPHA); // Draw a coloured parallelepiped. gl.Begin(OpenGL.GL_QUADS); gl.Color(0.0f, 1.0f, 0.0f); gl.Vertex(-2.0f, -0.25f, -1.0f); gl.Color(0.0f, 1.0f, 0.0f); gl.Vertex(2.0f, -0.25f, -1.0f); gl.Color(0.0f, 1.0f, 0.0f); gl.Vertex(2.0f, 0.25f, -1.0f); gl.Color(0.0f, 1.0f, 0.0f); gl.Vertex(-2.0f, 0.25f, -1.0f); //------------------------------------- gl.Color(1.0f, 0.0f, 0.0f); gl.Vertex(-2.0f, -0.25f, -1.0f); gl.Color(1.0f, 0.0f, 0.0f); gl.Vertex(-2.0f, -0.25f, 1.0f); gl.Color(1.0f, 0.0f, 0.0f); gl.Vertex(-2.0f, 0.25f, 1.0f); gl.Color(1.0f, 0.0f, 0.0f); gl.Vertex(-2.0f, 0.25f, -1.0f); //------------------------------------- gl.Color(0.0f, 1.0f, 0.0f); gl.Vertex(-2.0f, -0.25f, 1.0f); gl.Color(0.0f, 1.0f, 0.0f); gl.Vertex(2.0f, -0.25f, 1.0f); gl.Color(0.0f, 1.0f, 0.0f); gl.Vertex(2.0f, 0.25f, 1.0f); gl.Color(0.0f, 1.0f, 0.0f); gl.Vertex(-2.0f, 0.25f, 1.0f); //------------------------------------- gl.Color(1.0f, 0.0f, 0.0f); gl.Vertex(2.0f, -0.25f, 1.0f); gl.Color(1.0f, 0.0f, 0.0f); gl.Vertex(2.0f, -0.25f, -1.0f); gl.Color(1.0f, 0.0f, 0.0f); gl.Vertex(2.0f, 0.25f, -1.0f); gl.Color(1.0f, 0.0f, 0.0f); gl.Vertex(2.0f, 0.25f, 1.0f); //------------------------------------- gl.Color(0.0f, 1.0f, 1.0f); gl.Vertex(-2.0f, 0.25f, -1.0f); gl.Color(0.0f, 1.0f, 1.0f); gl.Vertex(2.0f, 0.25f, -1.0f); gl.Color(0.0f, 1.0f, 1.0f); gl.Vertex(2.0f, 0.25f, 1.0f); gl.Color(0.0f, 1.0f, 1.0f); gl.Vertex(-2.0f, 0.25f, 1.0f); //-------------------------------------- gl.Color(0.0f, 0.0f, 1.0f); gl.Vertex(-2.0f, -0.25f, -1.0f); gl.Color(0.0f, 0.0f, 1.0f); gl.Vertex(2.0f, -0.25f, -1.0f); gl.Color(0.0f, 0.0f, 1.0f); gl.Vertex(2.0f, -0.25f, 1.0f); gl.Color(0.0f, 0.0f, 1.0f); gl.Vertex(-2.0f, -0.25f, 1.0f); gl.End(); //-------------------Angle indicator prototype is here---------------------------------------------- gl.LoadIdentity(); gl.Rotate(cord.getX(), 1.0f, 0.0f, 0.0f); gl.Begin(OpenGL.GL_TRIANGLES); gl.Vertex(0.0f, 2.75f, 0.0f); gl.Vertex(0.25f, 3.25f, 0.0f); gl.Vertex(-0.25f, 3.25f, 0.0f); gl.End(); gl.LoadIdentity(); gl.Rotate(cord.getZ(), 0.0f, 1.0f, 0.0f); gl.Begin(OpenGL.GL_TRIANGLES); gl.Vertex(0.0f, 0.0f, 2.75f); gl.Vertex(0.0f, 0.25f, 3.25f); gl.Vertex(0.0f, -0.25f, 3.25f); gl.End(); gl.LoadIdentity(); gl.Rotate(cord.getY(), 0.0f, 0.0f, 1.0f); gl.Begin(OpenGL.GL_TRIANGLES); gl.Vertex(2.75f, 0.0f, 0.0f); gl.Vertex(3.25f, 0.0f, 0.25f); gl.Vertex(3.25f, 0.0f, -0.25f); gl.End(); //------------------Circles of planes is here----------------------------------------------- gl.LoadIdentity(); gl.Begin(OpenGL.GL_LINE_LOOP); for(int i = 0; i < 200; i++) { float theta = 2.0f * 3.1415926f * (float)i / 200f;//get the current angle float x = 3f * (float)System.Math.Cos(theta);//calculate the x component float y = 3f * (float)System.Math.Sin(theta);//calculate the y component gl.Color(0.0f, 1.0f, 0.0f); gl.Vertex(0f, y + 0.0f, x + 0.0f);//output vertex } gl.End(); gl.Begin(OpenGL.GL_LINE_LOOP); for (int i = 0; i < 200; i++) { float theta = 2.0f * 3.1415926f * (float)i / 200f;//get the current angle float x = 3f * (float)System.Math.Cos(theta);//calculate the x component float y = 3f * (float)System.Math.Sin(theta);//calculate the y component gl.Vertex(x + 0.0f, 0.0f, y + 0.0f);//output vertex } gl.End(); gl.Begin(OpenGL.GL_LINE_LOOP); for (int i = 0; i < 200; i++) { float theta = 2.0f * 3.1415926f * (float)i / 200f;//get the current angle float x = 3f * (float)System.Math.Cos(theta);//calculate the x component float y = 3f * (float)System.Math.Sin(theta);//calculate the y component gl.Vertex(x + 0.0f, y + 0.0f, 0.0f);//output vertex } gl.End(); /* //--------------Coordinate axis's is here-------------------------------------------- gl.LoadIdentity(); gl.Begin(OpenGL.GL_LINE_STRIP); gl.Color(1.0f, 1.0f, 1.0f); gl.Vertex(-4.0f, 0.5f, 1.5f); gl.Vertex(2.5f, 0.5f, 1.5f); gl.Vertex(2.5f, 0.5f, -4.5f); gl.Vertex(2.5f, 0.5f, 1.5f); gl.Vertex(2.5f, 4.0f, 1.5f); gl.End(); */ //------------Shpere is here----------------------------- gl.LoadIdentity(); gl.Color(0.85f, 0.85f, 0.85f, 0.5f); gl.Begin(OpenGL.GL_QUADS); for (int i = 0; i < 1; i++) { this.draw_sphere(gl, 3); } gl.End(); //---------------3D Text prototype is here------------------- gl.LoadIdentity(); gl.Translate(0.0f, 3.5f, -3.0f); gl.Color(0.0f, 1.0f, 0.65f); gl.Rotate(270.0f, 0.0f, 1.0f, 0.0f); gl.DrawText3D("a", 0.2f, 1.0f, 0.1f, "osX: 0"); // Nudge the rotation. rotation += 2.0f; }
private void openGLControl_OpenGLDraw(object sender, SharpGL.RenderEventArgs args) { var gravityForce = -Vector3d.UpDirection() * ball.RigidBody.Mass * Constants.G; if (ball.Center.Y - ball.Radius > 0) { force += gravityForce; ball.Center.X += force.X; ball.Center.Z += force.Z; if (-force.Y > ball.Radius) { ball.Center.Y = ball.Radius; } else { ball.Center.Y += force.Y; } } else { force.Y = -force.Y * 0.4; force -= force * frictionKoef; if (force.Length < gravityForce.Length) { force = new Vector3d(0, 0, 0); } ball.Center.Y = ball.Radius; ball.Center += new Vector3d(0, force.Y, 0); } scene.Draw(); }
private void openGLControl_OpenGLDraw(object sender, SharpGL.RenderEventArgs args) // Hàm quản lí việc vẽ các hình. { OpenGL gl = openGLControl.OpenGL; // Lấy đối tượng OpenGL. gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); // Xóa tất cả các hình đã vẽ. gl.MatrixMode(OpenGL.GL_MODELVIEW); // Chuyển qua dùng ma trận Model.View gl.LoadIdentity(); // Lấy ma trận đơn vị và lưu vào stack. gl.LookAt(MyEye.x, MyEye.y, MyEye.z, MyEye.tx, MyEye.ty, MyEye.tz, 0, 1, 0); // Nhìn vào gốc tọa độ. this.updateCurrentCoordinate(); // Cập nhật vị trí mắt hiện tại. CoorGrid.draw(gl); // Vẽ hệ tọa độ Oxyz. for (int i = 0; i < this.list_shape.Count; i++) // Bắt đầu vẽ các hình trong danh sách hình. { if (this.list_shape[i].is_apply_texture) // Nếu hình đã chọn gán texture thì gán. { this.list_shape[i].applyTexture(gl); // Gán texture. } else { this.list_shape[i].draw(gl); // Nếu không gán texture thì chỉ vẽ bình thường. } } if (this.curindex != -1) // Vẽ biên cho hình được chọn. { this.list_shape[curindex].drawBoundary(gl); // Gọi hàm vẽ biên cho hình được chọn. } }
private void openGLControl_OpenGLDraw(object sender, SharpGL.RenderEventArgs args) { OpenGL gl = this.openGLControl.OpenGL; gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); gl.ClearColor(baseColor.R, baseColor.G, baseColor.B, baseColor.A); gl.LoadIdentity(); // a bit magic numbers gl.Translate(0, 0, -1.3f); gl.Color(1.0, 1.0, 1.0, 1.0); gl.Rotate(rotate, 0, 0, 1); gl.Enable(OpenGL.GL_TEXTURE_2D); texture.Bind(gl); gl.Begin(OpenGL.GL_QUADS); var width = 0.3; var height = 0.3; var startX = -width / 2; var startY = -width / 2; gl.TexCoord(0, 1); gl.Vertex(new[] { startX, startY }); gl.TexCoord(1, 1); gl.Vertex(new[] { startX + width, startY }); gl.TexCoord(1, 0); gl.Vertex(new[] { startX + width, startY + height }); gl.TexCoord(0, 0); gl.Vertex(new[] { startX, startY + height }); gl.End(); gl.Disable(OpenGL.GL_TEXTURE_2D); gl.Flush(); }
private void openGLControl1_OpenGLDraw(object sender, SharpGL.RenderEventArgs args) { SharpGL.OpenGL gl = this.openGLControl1.OpenGL; gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); gl.LoadIdentity(); gl.LookAt(0, 20, 30, 0, 0, 0, 0, 1, 0); //desenha o piso gl.Enable(OpenGL.GL_TEXTURE_2D); grass.Bind(gl); gl.Begin(OpenGL.GL_QUADS); gl.Color(0.0f, 1.0f, 0.0f); gl.TexCoord(0.0f, 0.0f); gl.Vertex(-100.0f, 0.0f, -100.0f); gl.TexCoord(100.0f, 0.0f); gl.Vertex(100.0f, 0.0f, -100.0f); gl.TexCoord(100.0f, 100.0f); gl.Vertex(100.0f, 0.0f, 100.0f); gl.TexCoord(0.0f, 100.0f); gl.Vertex(-100.0f, 0.0f, 100.0f); gl.End(); gl.Disable(OpenGL.GL_TEXTURE_2D); foreach (Polygon polygon in polygons) { polygon.PushObjectSpace(gl); polygon.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render); polygon.PopObjectSpace(gl); } gl.Flush(); }
private void UI_3DView_OpenGLDraw(object sender, SharpGL.RenderEventArgs args) { OpenGL gl = UI_3DView.OpenGL; gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); gl.LoadIdentity(); // Auto-correct rotation values to keep them sane. if (rotationY > 360f) { rotationY -= 360f; } else if (rotationY < -360f) { rotationY += 360f; } gl.Rotate(rotationY, 0.0f, 1.0f, 0.0f); // Rotate Y gl.Enable(OpenGL.GL_TEXTURE_2D); foreach (Mesh mesh in meshes) { if (mesh.ShouldRender) { mesh.Draw(gl); } } gl.Disable(OpenGL.GL_TEXTURE_2D); if (autoRotate) { rotationY += 3.0f; } }
private void openGLControl1_OpenGLDraw(object sender, RenderEventArgs e) { // Get the OpenGL object, for quick access. var gl = this.openGLControl1.OpenGL; // Clear and load the identity. gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); gl.LoadIdentity(); // View from a bit away the y axis and a few units above the ground. gl.LookAt(-10, 10, -10, 0, 0, 0, 0, 1, 0); // Rotate the objects every cycle. gl.Rotate(rotate, 0.0f, 0.0f, 1.0f); // Move the objects down a bit so that they fit in the screen better. gl.Translate(0, 0, -1); // Draw every polygon in the collection. foreach (Polygon polygon in polygons) { polygon.PushObjectSpace(gl); polygon.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render); polygon.PopObjectSpace(gl); } // Rotate a bit more each cycle. rotate += 1.0f; }
private void openGLControl1_OpenGLDraw(object sender, SharpGL.RenderEventArgs args) { if (!isDrawed) { gl.ClearColor(1f, 1f, 1f, 1f); gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); gl.LoadIdentity(); gl.Translate(0, 0, -2.25f); DrawGrid(); if (selectedAction == Actions.SetLocalization) { DrawComponents(); } else if (selectedAction == Actions.DrawAttractor) { DrawAttractor(); } isDrawed = true; } }
private void openGLControl1_OpenGLDraw(object sender, SharpGL.RenderEventArgs args) { OpenGL gl = openGLControl.OpenGL; gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); //Bắt đầu vẽ //Lấy màu gl.Color(userChoose.R / 255.0, userChoose.G / 255.0, userChoose.B / 255.0, userChoose.A / 255.0); if (mode == 1) { //Lấy độ đậm if (!float.TryParse(textBoxThickness.Text, out thickness)) { thickness = 1.0f; } //Xem lựa chọn của user và chọn hinh vẽ và vẽ newShapeItem = Draw.TimHinhVe(openGLControl, chooseImg, start, end, userChoose, thickness); } else if (mode == 3) { if (mouseLeft == true) { newPolygonItem.Draw(openGLControl); } } else if (mode == 4) { } lPolygon.ForEach(x => x.Draw(openGLControl)); Draw.ThucHienVe(openGLControl); }
private void openGLControl1_OpenGLDraw(object sender, SharpGL.RenderEventArgs args) { gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); gl.LoadIdentity(); gl.Translate(-1.5f, 0.0f, -6.0f); gl.Begin(OpenGL.GL_QUADS); draw(); }
private void openGLControlTimerBased_OpenGLDraw(object sender, SharpGL.RenderEventArgs args) { // Get the OpenGL object, just to clean up the code. var gl = openGLControlTimerBased.OpenGL; gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); gl.LoadIdentity(); gl.Translate(0f, 0.0f, -7.0f); // Move Right And Into The Screen gl.Rotate(rquad, 1.0f, 1.0f, 1.0f); // Rotate The Cube On X, Y & Z gl.Begin(OpenGL.GL_QUADS); // Start Drawing The Cube gl.Color(0.0f, 1.0f, 0.0f); // Set The Color To Green gl.Vertex(1.0f, 1.0f, -1.0f); // Top Right Of The Quad (Top) gl.Vertex(-1.0f, 1.0f, -1.0f); // Top Left Of The Quad (Top) gl.Vertex(-1.0f, 1.0f, 1.0f); // Bottom Left Of The Quad (Top) gl.Vertex(1.0f, 1.0f, 1.0f); // Bottom Right Of The Quad (Top) gl.Color(1.0f, 0.5f, 0.0f); // Set The Color To Orange gl.Vertex(1.0f, -1.0f, 1.0f); // Top Right Of The Quad (Bottom) gl.Vertex(-1.0f, -1.0f, 1.0f); // Top Left Of The Quad (Bottom) gl.Vertex(-1.0f, -1.0f, -1.0f); // Bottom Left Of The Quad (Bottom) gl.Vertex(1.0f, -1.0f, -1.0f); // Bottom Right Of The Quad (Bottom) gl.Color(1.0f, 0.0f, 0.0f); // Set The Color To Red gl.Vertex(1.0f, 1.0f, 1.0f); // Top Right Of The Quad (Front) gl.Vertex(-1.0f, 1.0f, 1.0f); // Top Left Of The Quad (Front) gl.Vertex(-1.0f, -1.0f, 1.0f); // Bottom Left Of The Quad (Front) gl.Vertex(1.0f, -1.0f, 1.0f); // Bottom Right Of The Quad (Front) gl.Color(1.0f, 1.0f, 0.0f); // Set The Color To Yellow gl.Vertex(1.0f, -1.0f, -1.0f); // Bottom Left Of The Quad (Back) gl.Vertex(-1.0f, -1.0f, -1.0f); // Bottom Right Of The Quad (Back) gl.Vertex(-1.0f, 1.0f, -1.0f); // Top Right Of The Quad (Back) gl.Vertex(1.0f, 1.0f, -1.0f); // Top Left Of The Quad (Back) gl.Color(0.0f, 0.0f, 1.0f); // Set The Color To Blue gl.Vertex(-1.0f, 1.0f, 1.0f); // Top Right Of The Quad (Left) gl.Vertex(-1.0f, 1.0f, -1.0f); // Top Left Of The Quad (Left) gl.Vertex(-1.0f, -1.0f, -1.0f); // Bottom Left Of The Quad (Left) gl.Vertex(-1.0f, -1.0f, 1.0f); // Bottom Right Of The Quad (Left) gl.Color(1.0f, 0.0f, 1.0f); // Set The Color To Violet gl.Vertex(1.0f, 1.0f, -1.0f); // Top Right Of The Quad (Right) gl.Vertex(1.0f, 1.0f, 1.0f); // Top Left Of The Quad (Right) gl.Vertex(1.0f, -1.0f, 1.0f); // Bottom Left Of The Quad (Right) gl.Vertex(1.0f, -1.0f, -1.0f); // Bottom Right Of The Quad (Right) gl.End(); // Done Drawing The Q gl.Flush(); rtri += 3.0f; // 0.2f; // Increase The Rotation Variable For The Triangle rquad -= 3.0f; // 0.15f; // Decrease The Rotation Variable For The Quad }
private void openGLControl1_OpenGLDraw(object sender, RenderEventArgs e) { // Get the OpenGL object, for quick access. SharpGL.OpenGL gl = this.openGLControl1.OpenGL; gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); gl.LoadIdentity(); gl.Translate(0.0f, 0.0f, -6.0f); gl.Rotate(rtri, 0.0f, 1.0f, 0.0f); // Bind the texture. texture.Bind(gl); gl.Begin(OpenGL.GL_QUADS); // Front Face gl.TexCoord(0.0f, 0.0f); gl.Vertex(-1.0f, -1.0f, 1.0f); // Bottom Left Of The Texture and Quad gl.TexCoord(1.0f, 0.0f); gl.Vertex(1.0f, -1.0f, 1.0f); // Bottom Right Of The Texture and Quad gl.TexCoord(1.0f, 1.0f); gl.Vertex(1.0f, 1.0f, 1.0f); // Top Right Of The Texture and Quad gl.TexCoord(0.0f, 1.0f); gl.Vertex(-1.0f, 1.0f, 1.0f); // Top Left Of The Texture and Quad // Back Face gl.TexCoord(1.0f, 0.0f); gl.Vertex(-1.0f, -1.0f, -1.0f); // Bottom Right Of The Texture and Quad gl.TexCoord(1.0f, 1.0f); gl.Vertex(-1.0f, 1.0f, -1.0f); // Top Right Of The Texture and Quad gl.TexCoord(0.0f, 1.0f); gl.Vertex(1.0f, 1.0f, -1.0f); // Top Left Of The Texture and Quad gl.TexCoord(0.0f, 0.0f); gl.Vertex(1.0f, -1.0f, -1.0f); // Bottom Left Of The Texture and Quad // Top Face gl.TexCoord(0.0f, 1.0f); gl.Vertex(-1.0f, 1.0f, -1.0f); // Top Left Of The Texture and Quad gl.TexCoord(0.0f, 0.0f); gl.Vertex(-1.0f, 1.0f, 1.0f); // Bottom Left Of The Texture and Quad gl.TexCoord(1.0f, 0.0f); gl.Vertex(1.0f, 1.0f, 1.0f); // Bottom Right Of The Texture and Quad gl.TexCoord(1.0f, 1.0f); gl.Vertex(1.0f, 1.0f, -1.0f); // Top Right Of The Texture and Quad // Bottom Face gl.TexCoord(1.0f, 1.0f); gl.Vertex(-1.0f, -1.0f, -1.0f); // Top Right Of The Texture and Quad gl.TexCoord(0.0f, 1.0f); gl.Vertex(1.0f, -1.0f, -1.0f); // Top Left Of The Texture and Quad gl.TexCoord(0.0f, 0.0f); gl.Vertex(1.0f, -1.0f, 1.0f); // Bottom Left Of The Texture and Quad gl.TexCoord(1.0f, 0.0f); gl.Vertex(-1.0f, -1.0f, 1.0f); // Bottom Right Of The Texture and Quad // Right face gl.TexCoord(1.0f, 0.0f); gl.Vertex(1.0f, -1.0f, -1.0f); // Bottom Right Of The Texture and Quad gl.TexCoord(1.0f, 1.0f); gl.Vertex(1.0f, 1.0f, -1.0f); // Top Right Of The Texture and Quad gl.TexCoord(0.0f, 1.0f); gl.Vertex(1.0f, 1.0f, 1.0f); // Top Left Of The Texture and Quad gl.TexCoord(0.0f, 0.0f); gl.Vertex(1.0f, -1.0f, 1.0f); // Bottom Left Of The Texture and Quad // Left Face gl.TexCoord(0.0f, 0.0f); gl.Vertex(-1.0f, -1.0f, -1.0f); // Bottom Left Of The Texture and Quad gl.TexCoord(1.0f, 0.0f); gl.Vertex(-1.0f, -1.0f, 1.0f); // Bottom Right Of The Texture and Quad gl.TexCoord(1.0f, 1.0f); gl.Vertex(-1.0f, 1.0f, 1.0f); // Top Right Of The Texture and Quad gl.TexCoord(0.0f, 1.0f); gl.Vertex(-1.0f, 1.0f, -1.0f); // Top Left Of The Texture and Quad gl.End(); gl.Flush(); rtri += 1.0f;// 0.2f; // Increase The Rotation Variable For The Triangle }
private void openGLControl_OpenGLDraw(object sender, SharpGL.RenderEventArgs args) { OpenGL gl = openGLControl.OpenGL; // Clear the color and depth buffer. gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); drawAllShape(gl); gl.Flush();// Thực hiện lệnh vẽ ngay lập tức thay vì đợi sau 1 khoảng thời gian }
private void openGLControl_OpenGLDraw(object sender, SharpGL.RenderEventArgs args) { OpenGL gl = openGLControl.OpenGL; // Clear the color and depth buffer. gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); foreach (DrawHelper drawHelper in listDrawPolygonHelper) { drawHelper.draw(); } foreach (DrawHelper drawHelper in listDrawEllipseHelper) { drawHelper.draw(); } foreach (DrawHelper drawHelper in listDrawColor) { drawHelper.draw(); } List <Point> controlPoints = selectedPoints; if (controlPoints.Count > 0) { DrawHelper controlPointsDraw = new DrawHelper(gl, OpenGL.GL_POINTS, controlPoints, colorDialog1.Color, 1.0f, 5.0f); controlPointsDraw.draw(); } if (started) // neu mouse dang down va di chuyen, ve duong live tuy vao draw cai gi { if (drawingRadio.Checked) { int drawingMode = getDrawingOption(); DrawChosenOption liveDraw = new DrawChosenOption(drawingMode, pStart, pEnd, gl); uint openglMode = (drawingMode == DrawChosenOption.DRAW_LINE) ? OpenGL.GL_LINES : OpenGL.GL_LINE_LOOP; DrawHelper liveDrawHelper = new DrawHelper(gl, openglMode, liveDraw.getDrawingPoints(), colorDialog1.Color, (float)numericUpDown1.Value); liveDrawHelper.draw(); } else if (drawRandomRadio.Checked) { List <Point> points = drawRandomPolygon.getControlPoints(); points.Add(new Point(pEnd.X, pEnd.Y)); DrawHelper liveDrawHelper = new DrawHelper(gl, OpenGL.GL_LINE_LOOP, points, colorDialog1.Color, (float)numericUpDown1.Value); liveDrawHelper.draw(); } } if (ended) // da mouse up, tinh thoi gian ve hinh { watch.Stop(); var elapsedMs = watch.ElapsedMilliseconds; textBox1.Text = elapsedMs.ToString() + " ms"; ended = false; } }
private void openGLControl1_OpenGLDraw(object sender, SharpGL.RenderEventArgs args) { SharpGL.OpenGL gl = this.openGLControl1.OpenGL; gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); gl.LoadIdentity(); gl.Translate(0.0f, 0.0f, -6.0f); //绘制正方体,Rotate The Quad On The X, Y, And Z Axes gl.Rotate(x, -1.0f, 0.0f, 0.0f); gl.Rotate(y, 0.0f, 0.0f, 1.0f); gl.Rotate(z, 0.0f, 1.0f, 0.0f); gl.BindTexture(OpenGL.GL_TEXTURE_2D, textures[0]); gl.Begin(OpenGL.GL_QUADS); // Front Face gl.TexCoord(0.0f, 0.0f); gl.Vertex(-1.0f, -1.0f, 1.0f); // Bottom Left Of The Texture and Quad gl.TexCoord(1.0f, 0.0f); gl.Vertex(1.0f, -1.0f, 1.0f); // Bottom Right Of The Texture and Quad gl.TexCoord(1.0f, 1.0f); gl.Vertex(1.0f, 1.0f, 1.0f); // Top Right Of The Texture and Quad gl.TexCoord(0.0f, 1.0f); gl.Vertex(-1.0f, 1.0f, 1.0f); // Top Left Of The Texture and Quad // Back Face gl.TexCoord(1.0f, 0.0f); gl.Vertex(-1.0f, -1.0f, -1.0f); // Bottom Right Of The Texture and Quad gl.TexCoord(1.0f, 1.0f); gl.Vertex(-1.0f, 1.0f, -1.0f); // Top Right Of The Texture and Quad gl.TexCoord(0.0f, 1.0f); gl.Vertex(1.0f, 1.0f, -1.0f); // Top Left Of The Texture and Quad gl.TexCoord(0.0f, 0.0f); gl.Vertex(1.0f, -1.0f, -1.0f); // Bottom Left Of The Texture and Quad // Top Face gl.TexCoord(0.0f, 1.0f); gl.Vertex(-1.0f, 1.0f, -1.0f); // Top Left Of The Texture and Quad gl.TexCoord(0.0f, 0.0f); gl.Vertex(-1.0f, 1.0f, 1.0f); // Bottom Left Of The Texture and Quad gl.TexCoord(1.0f, 0.0f); gl.Vertex(1.0f, 1.0f, 1.0f); // Bottom Right Of The Texture and Quad gl.TexCoord(1.0f, 1.0f); gl.Vertex(1.0f, 1.0f, -1.0f); // Top Right Of The Texture and Quad // Bottom Face gl.TexCoord(1.0f, 1.0f); gl.Vertex(-1.0f, -1.0f, -1.0f); // Top Right Of The Texture and Quad gl.TexCoord(0.0f, 1.0f); gl.Vertex(1.0f, -1.0f, -1.0f); // Top Left Of The Texture and Quad gl.TexCoord(0.0f, 0.0f); gl.Vertex(1.0f, -1.0f, 1.0f); // Bottom Left Of The Texture and Quad gl.TexCoord(1.0f, 0.0f); gl.Vertex(-1.0f, -1.0f, 1.0f); // Bottom Right Of The Texture and Quad // Right face gl.TexCoord(1.0f, 0.0f); gl.Vertex(1.0f, -1.0f, -1.0f); // Bottom Right Of The Texture and Quad gl.TexCoord(1.0f, 1.0f); gl.Vertex(1.0f, 1.0f, -1.0f); // Top Right Of The Texture and Quad gl.TexCoord(0.0f, 1.0f); gl.Vertex(1.0f, 1.0f, 1.0f); // Top Left Of The Texture and Quad gl.TexCoord(0.0f, 0.0f); gl.Vertex(1.0f, -1.0f, 1.0f); // Bottom Left Of The Texture and Quad // Left Face gl.TexCoord(0.0f, 0.0f); gl.Vertex(-1.0f, -1.0f, -1.0f); // Bottom Left Of The Texture and Quad gl.TexCoord(1.0f, 0.0f); gl.Vertex(-1.0f, -1.0f, 1.0f); // Bottom Right Of The Texture and Quad gl.TexCoord(1.0f, 1.0f); gl.Vertex(-1.0f, 1.0f, 1.0f); // Top Right Of The Texture and Quad gl.TexCoord(0.0f, 1.0f); gl.Vertex(-1.0f, 1.0f, -1.0f); // Top Left Of The Texture and Quad gl.End(); gl.Flush(); }
private void openGLControl1_OpenGLDraw(object sender, SharpGL.RenderEventArgs args) { gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); if (isStopped) { return; } var width = openGLControl1.Width; var height = openGLControl1.Height; gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); gl.MatrixMode(OpenGL.GL_PROJECTION); gl.LoadIdentity(); gl.Ortho2D(0.0, width, 0.0, height); gl.MatrixMode(OpenGL.GL_MODELVIEW); gl.LoadIdentity(); gl.Translate(offX, offY, 0); gl.Scale(scale, scale, 0); float x = (float)(-offX / scale); float y = (float)(-offY / scale); float w = (float)(width / scale); float h = (float)(height / scale); world.viewport = new RectangleF(x, y, w, h); if (isDraw) { world.draw(gl, width, height); } int die = 0, alive = 0; die = world.botsList.Count(bot => bot.isDie); alive = world.botsList.Count - die; if (!isPause) { for (int i = 0; i < multiply; i++) { world.step(); } } if (watchFreq.ElapsedMilliseconds >= 300) { fps = Utils.minFormat(Math.Floor(1000f / watch.ElapsedMilliseconds), 3); watchFreq.Restart(); } gl.DrawText(30, height - 30, 0, 1f, 0, "monospace", 14f, String.Format("FPS: {0}\tSTEPS: {1}\tALIVE: {2}\tDEAD: {3}\tBOTS COUNT: {4}", fps, Utils.minFormat(this.world.cyclesCounter, 8, "0"), Utils.minFormat(alive, Constant.BOT_LIMIT.ToString().Length), Utils.minFormat(die, Constant.BOT_LIMIT.ToString().Length), Utils.minFormat(this.world.botsDraw, Constant.BOT_LIMIT.ToString().Length))); watch.Restart(); }
private void openGLControl1_OpenGLDraw(object sender, SharpGL.RenderEventArgs args) { _spinSpeed += (float)rotationSpeed.Value; Program.GL.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); Program.GL.LoadIdentity(); Program.GL.LineWidth((float)lineSize.Value); Program.GL.PointSize((float)pointSize.Value); Program.GL.Translate(0, 0, -1); Program.GL.Rotate(0, _spinSpeed, 0); Program.GL.Color((float)colorR.Value, (float)colorG.Value, (float)colorB.Value); _image.Draw(); Program.GL.Flush(); }
protected uint BlurTexture = 0; // An Unsigned Int To Store The Texture Number private void openGLControl1_OpenGLDraw(object sender, RenderEventArgs e) { OpenGL gl = openGLControl1.OpenGL; gl.ClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Set The Clear Color To Black gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer gl.LoadIdentity(); // Reset The View RenderToTexture(); // Render To A Texture ProcessHelix(); // Draw Our Helix DrawBlur(25,0.02f); // Draw The Blur Effect gl.Flush (); // Flush The GL Rendering Pipeline angle += 0.5f; }
private void openGLControl1_OpenGLDraw(object sender, SharpGL.RenderEventArgs args) { // 创建一个GL对象 SharpGL.OpenGL gl = this.openGLControl1.OpenGL; gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); gl.LoadIdentity(); // gl.LookAt(212, 60, 194 , 186, 55, 171, 0, 1, 0); gl.LookAt(200, 30, 160 + eye_z, 0, 0, 0, 0, 1, 0);//设置视角位置 gl.Scale(scaleValue, scaleValue * HEIGHT_RATIO, scaleValue); RenderHeightMap(heightMap); }
/// <summary> /// Partie GDI (2D) de l'affichage /// </summary> /// <param name="sender"></param> /// <param name="args"></param> void onGDIDraw(object sender, SharpGL.RenderEventArgs args) { Graphics g = args.Graphics; moveAll(g); try { g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; g.TextRenderingHint = TextRenderingHint.AntiAlias; g.CompositingQuality = CompositingQuality.HighQuality; Color Couleur = _couleur.GetRGB(); // Afficher tous les objets foreach (DisplayedObject b in _listeObjets) { b.AfficheGDI(g, _temps, Bounds, Couleur); } #if TRACER if (_afficheDebug) { afficheDebug(g); } #endif if (_afficherAide) { StringBuilder s = new StringBuilder(Resources.c); foreach (DisplayedObject b in _listeObjets) { b.AppendHelpText(s); } g.DrawString(s.ToString(), _fontHelp, Brushes.White, 10, 10); } else if (_temps._temps.Subtract(_debut).TotalMilliseconds < 10000) { g.DrawString("Pressez H pour de l'aide", _fontHelp, Brushes.White, 10, 10); } } catch (Exception ex) { MessageBox.Show(ex.Message + "\n" + ex.StackTrace, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); } }
private void openGLControl1_OpenGLDraw(object sender, SharpGL.RenderEventArgs args) { OpenGL gl = this.openGLControl.OpenGL; gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); gl.ClearColor(baseColor.R, baseColor.G, baseColor.B, baseColor.A); gl.Color(1.0, 1.0, 1.0, 1.0); gl.LoadIdentity(); scene.CreateModelviewAndNormalMatrix(); // Clear the color and depth buffer. gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT | OpenGL.GL_STENCIL_BUFFER_BIT); scene.RenderImmediateMode(gl); }
private void openGLControl_OpenGLDraw(object sender, SharpGL.RenderEventArgs args) { // Get the OpenGL object. OpenGL gl = openGLControl.OpenGL; // Clear the color and depth buffer. gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); if (this.fontElement != null) { this.fontElement.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render); } DrawPyramide(gl); }
void onOpenGLDraw(object sender, SharpGL.RenderEventArgs args) { // Get the OpenGL object, just to clean up the code. OpenGL gl = openGLControl.OpenGL; Color Couleur = _couleur.GetRGB(); // Deplacer et Afficher tous les objets foreach (DisplayedObject b in _listeObjets) { gl.PushAttrib(OpenGL.GL_ENABLE_BIT); b.AfficheOpenGL(gl, _temps, Bounds, Couleur); gl.PopAttrib(); } gl.End(); // Done Drawing The Q gl.Flush(); }
/// <summary> /// Handles the OpenGLDraw event of the openGLControl control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RenderEventArgs"/> instance containing the event data.</param> private void openGLControl_OpenGLDraw(object sender, RenderEventArgs e) { // Get the OpenGL object. OpenGL gl = openGLControl.OpenGL; // Clear the color and depth buffer. gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); // Load the identity matrix. gl.LoadIdentity(); // Rotate around the Y axis. gl.Rotate(rotation, 0.0f, 1.0f, 0.0f); // Draw a coloured pyramid. gl.Begin(OpenGL.GL_TRIANGLES); gl.Color(1.0f, 0.0f, 0.0f); gl.Vertex(0.0f, 1.0f, 0.0f); gl.Color(0.0f, 1.0f, 0.0f); gl.Vertex(-1.0f, -1.0f, 1.0f); gl.Color(0.0f, 0.0f, 1.0f); gl.Vertex(1.0f, -1.0f, 1.0f); gl.Color(1.0f, 0.0f, 0.0f); gl.Vertex(0.0f, 1.0f, 0.0f); gl.Color(0.0f, 0.0f, 1.0f); gl.Vertex(1.0f, -1.0f, 1.0f); gl.Color(0.0f, 1.0f, 0.0f); gl.Vertex(1.0f, -1.0f, -1.0f); gl.Color(1.0f, 0.0f, 0.0f); gl.Vertex(0.0f, 1.0f, 0.0f); gl.Color(0.0f, 1.0f, 0.0f); gl.Vertex(1.0f, -1.0f, -1.0f); gl.Color(0.0f, 0.0f, 1.0f); gl.Vertex(-1.0f, -1.0f, -1.0f); gl.Color(1.0f, 0.0f, 0.0f); gl.Vertex(0.0f, 1.0f, 0.0f); gl.Color(0.0f, 0.0f, 1.0f); gl.Vertex(-1.0f, -1.0f, -1.0f); gl.Color(0.0f, 1.0f, 0.0f); gl.Vertex(-1.0f, -1.0f, 1.0f); gl.End(); // Nudge the rotation. rotation += 3.0f; }
private void openGLControl1_OpenGLDraw(object sender, SharpGL.RenderEventArgs args) { OpenGL gl = openGLControl1.OpenGL; if (isShapesChanged) { gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); if (shapes.Count > 0) { for (int i = 0; i < shapes.Count - 1; i++) { shapes[i].Draw(gl); if (shapes[i].fillColor != Color.Black) shapes[i].Fill(gl); } //calculate time to draw shape Stopwatch watch = Stopwatch.StartNew(); shapes.Last().Draw(gl); watch.Stop(); label2.Text = watch.ElapsedTicks.ToString() + " ticks"; if (shapes.Last().fillColor != Color.Black) shapes.Last().Fill(gl); } gl.Flush(); isShapesChanged = false; // draw control point of shape is selected again if (choosingShape >= 0) { gl.PointSize(5.0f); gl.Begin(OpenGL.GL_POINTS); //Control point gl.Color(230.0, 230.0, 0); for (int i = 0; i < shapes[choosingShape].controlPoints.Count; i++) gl.Vertex(shapes[choosingShape].controlPoints[i].X, gl.RenderContextProvider.Height - shapes[choosingShape].controlPoints[i].Y); //Extrapoint (rotate/scale point) gl.Color(0, 100.0, 100.0); gl.Vertex(shapes[choosingShape].extraPoint.X, gl.RenderContextProvider.Height - shapes[choosingShape].extraPoint.Y); gl.End(); gl.Flush(); } } }
private void openGLWindow_OpenGLDraw(object sender, SharpGL.RenderEventArgs args) { OpenGL gl = this.openGLWindow.OpenGL; gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); gl.Enable(OpenGL.GL_POINT_SMOOTH); gl.MatrixMode(SharpGL.Enumerations.MatrixMode.Projection); gl.LoadIdentity(); gl.Ortho2D(0, openGLWindow.Size.Width, 0, openGLWindow.Size.Height); foreach (Group group in Groups) { if (group.elements.Count > 0) { gl.PointSize(group.groupThickness); gl.Begin(OpenGL.GL_POINTS); gl.Color(group.groupColor.R, group.groupColor.G, group.groupColor.B); gl.Vertex( group.elements[0].x + group.transformation.xTransition, group.elements[0].y + group.transformation.yTransition ); if (group == comboBoxGroups.SelectedItem) { double k = DateTime.Now.Millisecond / 700 == 0 ? 1 : 0; gl.Color(group.groupColor.R * k, group.groupColor.G * k, group.groupColor.B * k); } else { gl.Color(group.groupColor.R, group.groupColor.G, group.groupColor.B); } foreach (MyPoint point in group.rotatedElements()) { gl.Vertex( point.x + group.transformation.xTransition, point.y + group.transformation.yTransition ); } gl.End(); } } }
private void openGLControl1_OpenGLDraw(object sender, SharpGL.RenderEventArgs args) { SharpGL.OpenGL gl = this.openGLControl1.OpenGL; gl.Enable(OpenGL.GL_TEXTURE_2D); if (playerLives != 0) { gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); gl.LoadIdentity(); gl.Translate(0.0f, 0.0f, -20.0f); main.Create(gl, "..\\..\\main.png"); gl.PushMatrix(); gl.Begin(OpenGL.GL_QUADS); gl.TexCoord(1, 1); gl.Vertex(-1, -1); gl.TexCoord(0, 1); gl.Vertex(1, -1); gl.TexCoord(0, 0); gl.Vertex(1, 1); gl.TexCoord(1, 0); gl.Vertex(-1, 1); gl.End(); gl.PopMatrix(); currentFrame = currentFrame + 1; if (currentFrame % 28 == 0) { createEnemy(); currentFrame = 0; } moveEnemy(); if (enemyList != null) { for (int i = 0; i < enemyList.Count; i++) { enemyList[i].drawEnemy(gl); } } gl.Flush(); } else { label2.Text = "Game over"; } }
private void OpenGLControl_OpenGLDraw(object sender, SharpGL.RenderEventArgs args) { OpenGL gl = this.openGLControl.OpenGL; gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); gl.ClearColor(baseColor.R, baseColor.G, baseColor.B, baseColor.A); gl.LoadIdentity(); // a bit magic numbers gl.Translate(-0.3f, -0.3f, -0.3f); if (currentFractal != null) { float[] color = new float[4]; gl.Enable(OpenGL.GL_TEXTURE_2D); gl.GetFloat(OpenGL.GL_COLOR, color); gl.Color(1.0, 1.0, 1.0, 1.0); // set Texture binding texture.Bind(gl); // Paint here gl.Begin(OpenGL.GL_QUADS); double width = 0.3; double height = 0.3; var startX = width / 2; var startY = height / 2; gl.TexCoord(0, 1); gl.Vertex(new[] { startX, startY }); gl.TexCoord(1, 1); gl.Vertex(new[] { startX + width, startY }); gl.TexCoord(1, 0); gl.Vertex(new[] { startX + width, startY + height }); gl.TexCoord(0, 0); gl.Vertex(new[] { startX, startY + height }); gl.End(); gl.Color(color[0], color[1], color[2], color[3]); gl.Disable(OpenGL.GL_TEXTURE_2D); } gl.Flush(); }
private void openGLControl2_OpenGLDraw(object sender, SharpGL.RenderEventArgs args) { // Get the OpenGL object, just to clean up the code. var gl = openGLControlManual.OpenGL; gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); gl.LoadIdentity(); gl.Translate(0f, 0.0f, -6.0f); gl.Rotate(rtri, 0.0f, 1.0f, 0.0f); gl.Begin(OpenGL.GL_TRIANGLES); gl.Color(1.0f, 0.0f, 0.0f); // Red gl.Vertex(0.0f, 1.0f, 0.0f); // Top Of Triangle (Front) gl.Color(0.0f, 1.0f, 0.0f); // Green gl.Vertex(-1.0f, -1.0f, 1.0f); // Left Of Triangle (Front) gl.Color(0.0f, 0.0f, 1.0f); // Blue gl.Vertex(1.0f, -1.0f, 1.0f); // Right Of Triangle (Front) gl.Color(1.0f, 0.0f, 0.0f); // Red gl.Vertex(0.0f, 1.0f, 0.0f); // Top Of Triangle (Right) gl.Color(0.0f, 0.0f, 1.0f); // Blue gl.Vertex(1.0f, -1.0f, 1.0f); // Left Of Triangle (Right) gl.Color(0.0f, 1.0f, 0.0f); // Green gl.Vertex(1.0f, -1.0f, -1.0f); // Right Of Triangle (Right) gl.Color(1.0f, 0.0f, 0.0f); // Red gl.Vertex(0.0f, 1.0f, 0.0f); // Top Of Triangle (Back) gl.Color(0.0f, 1.0f, 0.0f); // Green gl.Vertex(1.0f, -1.0f, -1.0f); // Left Of Triangle (Back) gl.Color(0.0f, 0.0f, 1.0f); // Blue gl.Vertex(-1.0f, -1.0f, -1.0f); // Right Of Triangle (Back) gl.Color(1.0f, 0.0f, 0.0f); // Red gl.Vertex(0.0f, 1.0f, 0.0f); // Top Of Triangle (Left) gl.Color(0.0f, 0.0f, 1.0f); // Blue gl.Vertex(-1.0f, -1.0f, -1.0f); // Left Of Triangle (Left) gl.Color(0.0f, 1.0f, 0.0f); // Green gl.Vertex(-1.0f, -1.0f, 1.0f); // Right Of Triangle (Left) gl.End(); // Done Drawing The Pyramid }
private void openGLControl_OpenGLDraw(object sender, SharpGL.RenderEventArgs args) { // Get the OpenGL object. OpenGL gl = openGLControl.OpenGL; // Clear the color and depth buffer. gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); // Load the identity matrix. gl.LoadIdentity(); // Rotate around the Y axis. gl.Rotate(rotation, 0.0f, 1.0f, 0.0f); //DrawPyramid(gl); // Nudge the rotation. rotation += 3.0f; this.wellElement.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render); }
private void openGLControl1_OpenGLDraw(object sender, SharpGL.RenderEventArgs args) { var gl = openGLControl1.OpenGL; gl.ClearColor(0.4f, 0.6f, 0.9f, 0.5f); // Clear the scene. gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT | OpenGL.GL_STENCIL_BUFFER_BIT); //gl.BindBuffer(OpenGL.GL_ARRAY_BUFFER, m_vertexVBOID[0]); //gl.BindBuffer(OpenGL.GL_ELEMENT_ARRAY_BUFFER, m_indexVBOID[0]); //gl.EnableClientState(OpenGL.GL_VERTEX_ARRAY); //gl.VertexPointer(3, OpenGL.GL_FLOAT, 0, IntPtr.Zero); gl.BindBuffer(OpenGL.GL_ARRAY_BUFFER, m_vertexVBOID[0]); gl.VertexPointer(3, OpenGL.GL_FLOAT, 0, IntPtr.Zero); gl.EnableClientState(OpenGL.GL_VERTEX_ARRAY); gl.BindBuffer(OpenGL.GL_ELEMENT_ARRAY_BUFFER, m_indexVBOID[0]); gl.DrawElements(OpenGL.GL_TRIANGLES, m_numIndices, OpenGL.GL_UNSIGNED_SHORT, IntPtr.Zero); //DrawPyramid(gl); }
/// <summary> /// Handles the OpenGLDraw event of the openGLControl control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RenderEventArgs"/> instance containing the event data.</param> private void openGLControl_OpenGLDraw(object sender, RenderEventArgs e) { // Get the OpenGL object. OpenGL gl = openGLControl.OpenGL; // Clear the color and depth buffer. gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); //gl.ClearColor(0.15f, 0.15f, 0.15f, 1.0f); gl.ClearColor(0.10f, 0.10f, 0.10f, 1.0f); // Load the identity matrix. gl.LoadIdentity(); // using a camera to move into the scene //gl.LookAt(v_position.X, v_position.Y, v_position.Z, v_position.X + v_lookat.X, v_position.Y + v_lookat.Y, v_position.Z + v_lookat.Z, 0.0f, 1.0f, 0.0f); gl.LookAt(cameraPos.X, cameraPos.Y, cameraPos.Z, (cameraPos + cameraFront).X, (cameraPos + cameraFront).Y, (cameraPos + cameraFront).Z, cameraUp.X, cameraUp.Y, cameraUp.Z); //drawing the model gl.PushMatrix(); gl.Rotate(-90, 1, 0, 0); drawModel(gl); gl.PopMatrix(); }
/// <summary> /// Draw cycle /// </summary> /// <param name="sender"></param> /// <param name="args"></param> private void OpenGLControl_OpenGLDraw(object sender, SharpGL.RenderEventArgs args) { OpenGL gl = this.openGLControl.OpenGL; var layoutIndex = layoutsList.CheckedIndices.Cast <int>().ToList(); var layoutsReal = layouts.Where((x, i) => layoutIndex.Contains(i)).ToList(); currentFilter?.DrawFilter(openGLControl, layoutsReal); gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); gl.ClearColor(baseColor.R, baseColor.G, baseColor.B, baseColor.A); gl.LoadIdentity(); gl.LineWidth(1); gl.Translate(0.0f, 0.0f, -2.4f); foreach (var layout in layoutsReal) { layout.Paint(openGLControl); } currentFilter?.PostDrawFilter(openGLControl); }
private void openGLControl_OpenGLDraw(object sender, RenderEventArgs e) { CursorWektor.X =-1 * ((float)Cursor.Position.X - 680) / 50; CursorWektor.Z = -1 * ((float)Cursor.Position.Y - 374) / 50; // double Angle = Math.Atan2(CursorWektor.Z, CursorWektor.X); double Angle = -45; CursorWektorAngled = rotate_wektor(0, 0, (float)Angle, CursorWektor); // CursorWektorAngled.X = CursorWektor.X * (float)Math.Sin(Angle -ConvertToRadians(90)); // CursorWektorAngled.Z = CursorWektor.Z * (float)Math.Cos(Angle -ConvertToRadians(90)); // Get the OpenGL object. OpenGL gl = openGLControl.OpenGL; rysow = new Rysownik(gl); rysowM.SetUpGl(gl); if (!first_time) { rysowM.DrawMazeFloor(tempMazeList, 1.0f, new Wektor(0, 0, 0)); if (rysowM.ListaPointowDoKolizji != null) { // Debug.Write("wwrsdsfsafasfa"); ListaKolizji = rysowM.ListaPointowDoKolizji; // ListaKolizjiX = rysowM.ListaXDoKolizji; // ListaKolizjiZ = rysowM.ListaZDoKolizji; } first_time = true; } Sprawdzacz = new SprawdzaczKolizji(rysow); // rysowM = new RysownikMaze(gl); // Clear the color and depth buffer. gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); // (x > 0 ? x : (2*PI + x)) * 360 / (2*PI) double AngleX; AngleX = CursorWektor.X; // if(CursorWektor.X<0){AngleX = (2*Math.PI + CursorWektor.X) * 360 / (2*Math.PI) ;} double AngleY; AngleY = CursorWektor.Z; // if (CursorWektor.Z < 0) { AngleY = (2 * Math.PI + CursorWektor.Z) * 360 / (2 * Math.PI); } Angle_between_wektor_X_Z(WektorZero, CursorWektor); // Load the identity matrix. gl.MatrixMode(OpenGL.GL_PROJECTION); // Load the identity. gl.LoadIdentity(); gl.Perspective(60.0f, 0, 0, 0); rysow.DrawLive(new Wektor(0.9f, -0.7f, 0), new Wektor(0.05f, 0.03f, 0f), PlayerLive); rysow.DrawLive(new Wektor(-0.9f, -0.7f, 0), new Wektor(0.05f, 0.04f, 0f), Boss.Live); // gl.DepthMask(0); // rysow.DrawCubo(0, 0, 0, 0.33f, 0.33f, 0.33f,0.0f,true,0.6f); // gl.DepthMask(1); gl.Enable(SharpGL.OpenGL.GL_SMOOTH); gl.Enable(SharpGL.OpenGL.GL_FLAT); // gl.Enable(SharpGL.OpenGL.GL_LINE_SMOOTH); // Create a perspective transformation. gl.Perspective(60.0f, (double)Width / (double)Height, 0.01, 100.0); // Use the 'look at' helper function to position and aim the camera. gl.LookAt(cuboPlayer.polozenie.X - 5, YAxisCamera, cuboPlayer.polozenie.Z - 5, cuboPlayer.polozenie.X, cuboPlayer.polozenie.Y, cuboPlayer.polozenie.Z, 0, 1, 0); // Rotate around the Y axis. float samesize= 2.3f; // =new Wektor(1.0, 1.0, 1.0); //Wektor re(1.0,1.0,1.0); /* for (int i = 0; i < listaPociskow.Count; i++) // Loop with for. { rysow.DrawCubo(listaPociskow[i].polozenie.X, listaPociskow[i].polozenie.Y, listaPociskow[i].polozenie.Z, listaPociskow[i].grubosci.X, listaPociskow[i].grubosci.Y, listaPociskow[i].grubosci.Z, (float)listaPociskow[i].angle + rotation, true,1.0f); } */ // list /* for (int i = 0; i < listaPociskowPlayera.Count; i++) // Loop with for. { rysow.DrawCubo(listaPociskowPlayera[i].polozenie.X, listaPociskowPlayera[i].polozenie.Y, listaPociskowPlayera[i].polozenie.Z, listaPociskowPlayera[i].grubosci.X, listaPociskowPlayera[i].grubosci.Y, listaPociskowPlayera[i].grubosci.Z, (float)listaPociskowPlayera[i].angle + rotation, true, 1.0f); } */ // rysow.DrawCubo(Boss.polozenie.X, Boss.polozenie.Y, Boss.polozenie.Z, // Boss.grubosci.X, Boss.grubosci.Y, Boss.grubosci.Z, 20,2); // rysow.draw_floor(); // rysowM.FinalDrawAllMazeByGl(MyMaze, new Wektor(0, 0, 0),(float)cuboPlayer.angle/15); // rysowM.FinalDrawAllMazeByGl(MyMazeTwo, new Wektor(-2, 0, -3), 0.5f); // rysowM.DrawMazyByListToSpeedUp(tempMazeList,new Wektor(2,0,0),0.02f); // rysowM.drawQuadFloor(new Wektor(1, 0, 1), 1f); // rysowM.drawQuadFloor(new Wektor(0,0,0),1.0f); rysowM.DrawMazeFloor(tempMazeList, 1.0f, new Wektor(0, 0, 0)); int Xo; int Yo; Coord tempCo = StraightTrap.in_what_coord(cuboPlayer.polozenie.X, cuboPlayer.polozenie.Z, 1.0f); Debug.Write(tempCo.x); Debug.Write(" y>"); Debug.WriteLine(tempCo.y); if( StraightTrap.is_three_cell_far(MazeCellsIntTab, tempCo.x, tempCo.y)) { Debug.WriteLine("buuummm"); } // + " y>" + cuboPlayer.polozenie.Z-1.0f); // gl.EnableClientState(OpenGL.GL_VERTEX_ARRAY); // gl.VertexPointer(0,3,rysowM.ArrayVertex); // gl.VertexPointer() //glVertexPointer(3, GL_FLOAT, 0, vertices); // draw a cube // gl.DrawArrays(OpenGL.GL_LINES,0,rysowM.count/2); //glDrawArrays(GL_TRIANGLES, 0, 36); // deactivate vertex arrays after drawing //glDisableClientState(GL_VERTEX_ARRAY); // gl.EnableClientState(OpenGL.GL_VERTEX_ARRAY); // gl.DrawArrays() // Debug.WriteLine(ListaKolizji.Count + " <out "); //mapka// rysowM.DrawMazyByListToSpeedUp(tempMazeList, cuboPlayer.polozenie, 0.22f); // Debug.Write(tempMazeList.Count.ToString() + " "); // rysowM.FinalDrawAllMazeByGl(MyMazeTwo, new Wektor(-5, 0, -5),1+(float)Math.Sin(rotation/10)); gl.Enable(SharpGL.OpenGL.GL_BLEND); gl.BlendFunc(SharpGL.OpenGL.GL_SRC_ALPHA,SharpGL.OpenGL.GL_ONE_MINUS_SRC_ALPHA); // glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); CursorWektor += cuboPlayer.polozenie; rysow.DrawCubo_with_alpha(CursorWektor.X, CursorWektor.Y, CursorWektor.Z, cuboPlayer.grubosci.X, cuboPlayer.grubosci.Y, cuboPlayer.grubosci.Z, rotation * 2,0.3f); CursorWektorAngled += cuboPlayer.polozenie; // rysow.DrawCubo_with_alpha(CursorWektorAngled.X, CursorWektorAngled.Y, CursorWektorAngled.Z, //// cuboPlayer.grubosci.X, // cuboPlayer.grubosci.Y * 3, cuboPlayer.grubosci.Z, (float)(1.5 * -1) * rotation, 0.3f); cuboPlayer.angle = -1f * Angle_between_wektor_X_Z(cuboPlayer.polozenie, CursorWektor); rysow.DrawPlayer(cuboPlayer.polozenie, cuboPlayer.grubosci, cuboPlayer.angle); // rysow.DrawCubo_with_alpha(CursorWektorAngled.X,CursorWektorAngled.Y,CursorWektorAngled.Z, // cuboPlayer.grubosci.X, // cuboPlayer.grubosci.Y*3, cuboPlayer.grubosci.Z, (float)(1.5 * -1) * rotation ,0.3f); Wektor AngleZeto; AngleZeto = new Wektor(120, 31200, 2130); // // trete //player config int hour_0_to_7; hour_0_to_7 = 900000; if (KeyW && !KeyA && !KeyD && !KeyS) { hour_0_to_7 = -1; } if (!KeyW && !KeyA && !KeyD && KeyS) { hour_0_to_7 = 4; } if (!KeyW && KeyA && !KeyD && !KeyS) { hour_0_to_7 = 6; } if (!KeyW && !KeyA && KeyD && !KeyS) { hour_0_to_7 = 2; } if (KeyA && KeyS && !KeyW) { hour_0_to_7 = 5; } if (KeyS && KeyD && !KeyW) { hour_0_to_7 = 3; } if (KeyD && KeyW) { hour_0_to_7 = 1; } if (KeyW && KeyA) { hour_0_to_7 = 7; } Wektor temp; temp = new Wektor(0.0f, 0.0f, 0.2f); if (Math.Abs(cuboPlayer.predkosc.X) < 0.2f && Math.Abs(cuboPlayer.predkosc.Z) < 0.2f) { switch (hour_0_to_7) { case -1: cuboPlayer.predkosc = RotateWektorOnZero(temp, 315); break; case 1: cuboPlayer.predkosc = temp; // cuboPlayer.predkosc.Z += 0.21f; // Debug.WriteLine(RotateWektorOnZero(temp, 45).X + " " + RotateWektorOnZero(temp, 45).Z); break; case 2: cuboPlayer.predkosc = RotateWektorOnZero(temp, 45); //cuboPlayer.predkosc.Z += RotateWektorOnZero(temp, 90).Z; // Debug.WriteLine(RotateWektorOnZero(temp, 90).X + " " + RotateWektorOnZero(temp, 90).Z); break; case 3: cuboPlayer.predkosc = RotateWektorOnZero(temp, 90); break; case 4: cuboPlayer.predkosc = RotateWektorOnZero(temp, 135); break; case 5: cuboPlayer.predkosc = RotateWektorOnZero(temp, 180); break; case 6: cuboPlayer.predkosc = RotateWektorOnZero(temp, 225); break; case 7: cuboPlayer.predkosc = RotateWektorOnZero(temp, 270); break; // default: // cuboPlayer.wycisz_predkosc_only_XZ_o(0.1f); } } cuboPlayer.wycisz_predkosc_only_XZ_o(0.01f); // if(Sprawdzacz.CzyNieKoliduje(ListaKolizji,1.0f,cuboPlayer.polozenie + cuboPlayer.predkosc)){ if (ListaKolizji != null) { // Debug.Write(ListaKolizji.Count); // Debug.Write("nie pusty"); if(Sprawdzacz.CzyNieKoliduje(ListaKolizji,0.5f,cuboPlayer.polozenie+cuboPlayer.predkosc)) { cuboPlayer.krok_naprzod(); } } //esle if (bulletOne != null) { bulletOne.krok_naprzod(); } Boss.krok_naprzod(); // foreach (KwadratMaterialnyPocisk prime in listaPociskow) // Loop through List with foreach. // { // prime.krok_naprzod(); // } for (int i = 0; i < listaPociskow.Count; i++) // Loop with for. { if (listaPociskow[i].vitality < 1) { listaPociskow.RemoveAt(i); } else { listaPociskow[i].krok_naprzod(); } } //foreach (KwadratMaterialnyPocisk prime in listaPociskowPlayera) // Loop through List with foreach. //{ // if (prime.vitality < 3) // { // listaPociskowPlayera.Remove(prime); // } // else // { // prime.krok_naprzod(); // } //} for (int i = 0; i < listaPociskowPlayera.Count; i++) // Loop with for. { if(czy_nachodza(listaPociskowPlayera[i].polozenie,Boss.polozenie,Boss.grubosci.X)) { Boss.Live--; // Debug.WriteLine("nachodza"); } if (listaPociskowPlayera[i].vitality < 3) { listaPociskowPlayera.RemoveAt(i); } else { listaPociskowPlayera[i].krok_naprzod(); } } if (cuboPlayer.polozenie.X < 2.0f * 16 * 3 && -5.5f + (2.0f * 16 * 3) < cuboPlayer.polozenie.Z && -5.5f + (2.0f * 16 * 3) < cuboPlayer.polozenie.X ) { ListaKolizji = new List<Wektor>(); ListaKolizjiX = new List<float>(); ListaKolizjiZ = new List<float>(); MazeCellType = new List<int>(); rysowM = new RysownikMaze(); // Sprawdzacz = new SprawdzaczKolizji(); MyMaze = rysowM.DrawMazeSkelethOfSize(25, true); MyMazeTwo = rysowM.DrawMazeSkelethOfSize(16, false); // tempMazeList = rysowM.ConvertMazeStructToListOfTypes(MyMazeTwo); cuboPlayer.polozenie = new Wektor(0, 0, 0); } if( cuboPlayer.polozenie.X > 2.0f * 16) { } if(Boss.counter%100 == 0) { Boss.Live--; if(Boss.Live==0) { cuboPlayer.polozenie = new Wektor(0, 0, 0); } listaPociskow = new List<KwadratMaterialnyPocisk>(); for (int i = 0; i < 13; i++) { listaPociskow.Add(new KwadratMaterialnyPocisk(Boss.polozenie, losowyWektorPredkosci(), 20)); } } // cuboOne.daj_kat_kwadrata(); // Nudge the rotation. rotation += 3.0f; Wektor inc; inc = new Wektor(0.01f, 0.0f, 0.0f); da += inc; re= re * 1.01f; if (bulletOne != null) { if (bulletOne.vitality < 0) { bulletOne = null; } } }
private void overlayControl_Draw(object sender, RenderEventArgs args) { if (Form.ActiveForm != null) { if (Keyboard.IsKeyDown(Key.Escape)) { Application.Exit(); } } var gl = overlayControl.OpenGL; gl.ClearColor(0.0f, 0.0f, 0.0f, 0.0f); gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT | OpenGL.GL_STENCIL_BUFFER_BIT); if (shaderProgram == null) { return; } var curTime = DateTime.UtcNow; float delta = (curTime - lastTime).Ticks / 50000.0f; lastTime = curTime; var userOffsetModel = glm.translate(mat4.identity(), new vec3(offsetX, offsetY, 0)); var scaledModel = glm.scale(userOffsetModel, new vec3(scale, scale, 1.0f)); modelMatrix = scaledModel; shaderProgram.Bind(gl); shaderProgram.SetUniformMatrix4(gl, "projectionMatrix", projectionMatrix.to_array()); shaderProgram.SetUniformMatrix4(gl, "modelMatrix", modelMatrix.to_array()); Renderable readyRenderable = null; if( this.ready_renderables.TryTake(out readyRenderable)){ Debug.WriteLine("setting up : " + readyRenderable.description); readyRenderable.Setup(gl); this.active_renderables.Add(readyRenderable); } Renderable unloadRenderable = null; if (this.unload_renderables.TryTake(out unloadRenderable)) { Debug.WriteLine("tearing down : " + unloadRenderable.description); unloadRenderable.Teardown(gl); } var sortedRenderables = this.active_renderables.OrderByDescending(x => x is RadarScan); foreach (var renderable in sortedRenderables) { renderable.Draw(gl); } shaderProgram.Unbind(gl); var now = DateTime.UtcNow; frameCount++; if ((now - startTime).TotalSeconds > 1) { // 1 second has passed. print out frames. //Debug.WriteLine(frameCount + " frames per second"); startTime = now; frameCount = 0; } }
private void openGLControlNativeWindow_OpenGLDraw(object sender, RenderEventArgs e) { SampleRendering(openGLControlNativeWindow.OpenGL, 0.0f, 0.0f, 1.0f); }
private void glcScene_GDIDraw(object sender, RenderEventArgs args) { Graphics g = args.Graphics; switch (state) { case 0: #region 0 : 타이틀 int s = Math.Min(glcScene.Width, glcScene.Height); g.DrawImage(logo, new Rectangle((glcScene.Width - s) / 2, (glcScene.Height - s) / 2, s, s)); g.DrawString("Press [Enter] to start!", new Font("Arial", 12), Brushes.White, new PointF(glcScene.Width / 2, glcScene.Height - 21), middle); #endregion break; case 1: #region 1 : 게임 g.FillRectangle(Brushes.Black, new Rectangle(0, 0, Width, Height / 10)); g.DrawString((int)player.y + "m", font, Brushes.White, new PointF(size, size)); g.DrawString(player.speed.ToString("0.0") + "m/s", font, Brushes.White, new PointF(glcScene.Width - size, size), right); g.FillRectangle(Brushes.Orange, new Rectangle(glcScene.Width * 2 / 5, glcScene.Height / 32, (int)(glcScene.Width * player.sprint / 500), glcScene.Height / 70)); g.DrawString(((int)player.sprint).ToString(), smallfont, Brushes.White, new PointF(glcScene.Width / 2, glcScene.Height / 32 - size * 0.35f), middle); g.FillRectangle(Brushes.Red, new Rectangle(glcScene.Width * 2 / 5, glcScene.Height / 16, (int)(glcScene.Width * chul / 500), glcScene.Height / 70)); g.DrawString(((int)chul).ToString(), smallfont, Brushes.Gray, new PointF(glcScene.Width / 2, glcScene.Height / 16 - size * 0.35f), middle); if (police > 0) { float he = glcScene.Height * 0.2f * police / 10000; if (police < 2500) he = glcScene.Height * 0.05f; g.DrawImage(bpolice, new RectangleF(0, glcScene.Height - he, he * bpolice.Width / bpolice.Height, he)); } if (timer) { float he = glcScene.Width * 0.25f; g.DrawImage(bcheckpoint, new RectangleF(glcScene.Width - he, 0, he, he)); g.DrawImage(bgreen, new RectangleF(glcScene.Width - he * 0.45f, he * 0.05f, he * 0.4f, he * 0.4f)); for(int i = 0; i < (targettime - curtime) / targettime * 7; i++) g.DrawImage(bmark, new RectangleF(glcScene.Width - he * 0.12f, he * (0.4f - 0.06f * i), he * 0.06f, he * 0.06f)); } #endregion break; case 2: #region 2 : 철컹철컹 게임 오버 g.FillRectangle(new SolidBrush(Color.FromArgb(128, 0, 0, 0)), new Rectangle(0, 0, Width, Height)); g.FillRectangle(Brushes.White, new Rectangle(glcScene.Width / 4, glcScene.Height / 4, glcScene.Width / 2, glcScene.Height / 2)); g.DrawString("출근을 하지 못하고\r\n\r\n철컹철컹 당했다.\r\n\r\n움직인 거리 : " + player.y, font, Brushes.Black, new PointF(glcScene.Width / 2, glcScene.Height * 0.37f), middle); #endregion break; case 3: #region 3 : 시간 초과 게임 오버 float heaa = glcScene.Width * 0.25f; g.DrawImage(bcheckpoint, new RectangleF(glcScene.Width - heaa, 0, heaa, heaa)); g.DrawImage(bred, new RectangleF(glcScene.Width - heaa * 0.45f, heaa * 0.05f, heaa * 0.4f, heaa * 0.4f)); g.FillRectangle(new SolidBrush(Color.FromArgb(128, 0, 0, 0)), new Rectangle(0, 0, Width, Height)); g.FillRectangle(Brushes.White, new Rectangle(glcScene.Width / 4, glcScene.Height / 4, glcScene.Width / 2, glcScene.Height / 2)); g.DrawString("신호등을 건너지 못해\r\n\r\n회사를 가지 못했다.\r\n\r\n움직인 거리 : " + player.y, font, Brushes.Black, new PointF(glcScene.Width / 2, glcScene.Height * 0.37f), middle); #endregion break; } if (paused) g.DrawString("PAUSED", font, Brushes.Blue, new PointF(glcScene.Width / 2, glcScene.Height * 0.45f), middle); }
private void glcScene_OpenGLDraw(object sender, RenderEventArgs args) { switch (state) { case 0: #region 0 : 타이틀 #endregion break; case 1: case 2: case 3: #region 1 : 게임 / 2,3 : 게임 오버 OpenGL gl = glcScene.OpenGL; gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); gl.ClearColor(0.8f, 0.8f, 0.8f, 1.0f); gl.BlendFunc(BlendingSourceFactor.SourceAlpha, BlendingDestinationFactor.OneMinusSourceAlpha); gl.LoadIdentity(); gl.MatrixMode(MatrixMode.Projection); gl.Perspective(60.0, (double)this.Width / this.Height, 0.01, 1000.0); gl.LookAt(0, player.y - 4, 5, 0, player.y + 3, 0, 0, 0, 1); gl.Enable(OpenGL.GL_TEXTURE_2D); for (int i = -3; i < 3; i++) for (int j = (int)player.y - 10; j < (int)player.y + 50; j++) { if ((i + 2 * j) % 4 == 0) texFloor2.Bind(gl); else texFloor1.Bind(gl); gl.Begin(BeginMode.Quads); { gl.TexCoord(0, 0); gl.Vertex(i, j, 0); gl.TexCoord(0, 1); gl.Vertex(i, j + 1, 0); gl.TexCoord(1, 1); gl.Vertex(i + 1, j + 1, 0); gl.TexCoord(1, 0); gl.Vertex(i + 1, j, 0); } gl.End(); } if (player.y < 20) { texStart.Bind(gl); gl.Begin(BeginMode.Quads); { gl.TexCoord(0, 1); gl.Vertex(-2, 3, 3); gl.TexCoord(0, 0); gl.Vertex(-2, 3, 4); gl.TexCoord(1, 0); gl.Vertex(2, 3, 4); gl.TexCoord(1, 1); gl.Vertex(2, 3, 3); } gl.End(); } else if(player.y % 500 > 450 || player.y % 500 < 50) { int yy = (int)((player.y + 250) / 500) * 500; texCheck.Bind(gl); gl.Begin(BeginMode.Quads); { gl.TexCoord(0, 1); gl.Vertex(-2, yy, 3); gl.TexCoord(0, 0); gl.Vertex(-2, yy, 4); gl.TexCoord(1, 0); gl.Vertex(2, yy, 4); gl.TexCoord(1, 1); gl.Vertex(2, yy, 3); } gl.End(); } gl.Disable(OpenGL.GL_TEXTURE_2D); /* gl.Color(0.0f, 0.0f, 0.0f, 0.5f); gl.Enable(OpenGL.GL_BLEND); foreach (Walker w in walkers) { gl.Begin(BeginMode.Polygon); { for (int i = 0; i < 16; i++) { gl.Vertex(w.xpos * 0.5f + w.flying + 0.35 * Math.Cos(i * Math.PI / 8), w.y + 0.35 * Math.Sin(i * Math.PI / 8), 0.1); } } gl.End(); } gl.Disable(OpenGL.GL_BLEND); */ gl.Enable(OpenGL.GL_TEXTURE_2D); int wi = 18, hi = 4; for (int j = (int)((player.y - 40) / wi) * wi; j <= (int)((player.y + 20) / wi) * wi; j += wi) { texBuilding[(j / wi + 100) % 4].Bind(gl); if ((j / wi - 3) % 11 == 10) gl.Color(0.5f, 0.5f, 0.5f, 1.0f); else gl.Color(1.0f, 1.0f, 1.0f, 1.0f); gl.Begin(BeginMode.Quads); { gl.TexCoord(0, 1); gl.Vertex(-3, j, 0); gl.TexCoord(1, 1); gl.Vertex(-3, j + wi, 0); gl.TexCoord(1, 0); gl.Vertex(-3, j + wi, hi); gl.TexCoord(0, 0); gl.Vertex(-3, j, hi); } gl.End(); texBuilding[(j / wi + 102) % 4].Bind(gl); gl.Begin(BeginMode.Quads); { gl.TexCoord(1, 1); gl.Vertex(3, j, 0); gl.TexCoord(0, 1); gl.Vertex(3, j + wi, 0); gl.TexCoord(0, 0); gl.Vertex(3, j + wi, hi); gl.TexCoord(1, 0); gl.Vertex(3, j, hi); } gl.End(); } gl.Color(1.0f, 1.0f, 1.0f, 1.0f); gl.Enable(OpenGL.GL_BLEND); gl.Enable(OpenGL.GL_ALPHA_TEST); gl.AlphaFunc(AlphaTestFunction.Great, 0.1f); texF.Bind(gl); foreach (Walker w in walkers) if (w.type == WalkerType.Female && w.flying == 0) w.Draw3D(gl); texM.Bind(gl); foreach (Walker w in walkers) if (w.type == WalkerType.Male && w.flying == 0) w.Draw3D(gl); texFFly.Bind(gl); foreach (Walker w in walkers) if (w.type == WalkerType.Female && w.flying != 0) w.Draw3DFlying(gl); texMFly.Bind(gl); foreach (Walker w in walkers) if (w.type == WalkerType.Male && w.flying != 0) w.Draw3DFlying(gl); texrun.Bind(gl); player.Draw3D(gl); gl.Disable(OpenGL.GL_TEXTURE_2D); gl.LoadIdentity(); gl.Disable(OpenGL.GL_ALPHA_TEST); gl.Disable(OpenGL.GL_BLEND); gl.Flush(); #endregion break; } }
/// <summary> /// Standaard game update /// </summary> /// <param name="sender"></param> /// <param name="args"></param> private void GameFrame_Renderer(object sender, RenderEventArgs args) { //haalt de opengl renderer op en cleart het schermhoi var renderer = GameFrame.OpenGL; renderer.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); //renderer.frame //loopt door de game objecten heen en drawt deze for (int i = 0; i < GameObjects.Count; i++) { var gameObject = GameObjects[i]; if (gameObject.Gui == null) { gameObject.Gui = Gui.Gui.NewInstance(GameFrame.OpenGL); } //gameObject.Gui.DrawLabel(new Vector2(10, 10), "Courier New", 12, "test"); if (gameObject.IsDestroyed) { DestroyGameObject(gameObject); continue; } gameObject.OnGui(); renderer.LoadIdentity(); gameObject.Update(); Camera.Draw(renderer); gameObject.Draw(renderer); //renderer.End(); renderer.Flush(); } }
/// <summary> /// Handles the OpenGLDraw event of the openGLControl control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Windows.Forms.PaintEventArgs"/> instance containing the event data.</param> private void openGLControl_OpenGLDraw(object sender, RenderEventArgs e) { try { // Get the OpenGL object. OpenGL gl = openGLControl.OpenGL; if (m_bDarkMode) { gl.ClearColor(0f, 0f, 0f, 1f); } else { gl.ClearColor(1f, 1f, 0.95f, 1f); } // Clear the color and depth buffer. gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); // Load the identity matrix. gl.LoadIdentity(); // Rotate around the Y axis. gl.Rotate(rotation, 0.0f, 1.0f, 0.0f); // draw axles float[] AxleTextColor = new float[4]; float[] grey = new float[4]; if (m_bDarkMode) { AxleTextColor[0] = 1.0f; AxleTextColor[1] = 1.0f; AxleTextColor[2] = 1.0f; AxleTextColor[3] = 1.0f; grey[0] = 0.4f; grey[1] = 0.4f; grey[2] = 0.4f; grey[3] = 1.0f; } else { AxleTextColor[0] = 0.0f; AxleTextColor[1] = 0.0f; AxleTextColor[2] = 0.0f; AxleTextColor[3] = 1.0f; grey[0] = 0.7f; grey[1] = 0.7f; grey[2] = 0.7f; grey[3] = 1.0f; } // Calculate steps for X axis double fStart = m_fMinFrecuency; double fEnd = m_fMaxFrecuency; double fMajorStep = 1.0; double fSpan = (fEnd - fStart); if (fSpan <= 1.0) { fMajorStep = 0.1; } else if (fSpan <= 10) { fMajorStep = 1.0; } else if (fSpan <= 100) { fMajorStep = 10; } else if (fSpan <= 500) { fMajorStep = 50; } else if (fSpan <= 1000) { fMajorStep = 100; } double XMajorStep = fMajorStep; double XMinorStep = fMajorStep / 10.0; double XOffset = (((int)((fStart + XMajorStep) / XMajorStep)) * XMajorStep) - fStart; if (XOffset > (XMajorStep * 1.0001)) throw new ArgumentOutOfRangeException("Offset bigger than step, not possible"); if (XOffset == XMajorStep) XOffset = 0;// if no rounding that means we are spot on, so no offset needed // Calculate steps for Y axis double YMajorStep = 10.0; double YMinorStep = 1.0; if ((m_fMaxAmplitude - m_fMinAmplitude) > 30) { YMinorStep = 5.0; } //Draw floor and axis lines double xd; double minor = YMinorStep / (m_fMaxAmplitude - m_fMinAmplitude); double major = YMajorStep / (m_fMaxAmplitude - m_fMinAmplitude); double dXMajorAdjustedSteps = fSpan / XMajorStep; if (m_bDrawFloor) { { gl.Begin(OpenGL.GL_TRIANGLES); gl.Material(OpenGL.GL_FRONT, OpenGL.GL_AMBIENT_AND_DIFFUSE, grey); gl.Vertex(0f, 0f, 0f); gl.Material(OpenGL.GL_FRONT, OpenGL.GL_AMBIENT_AND_DIFFUSE, grey); gl.Vertex(m_fX_max, 0f, 0f); gl.Material(OpenGL.GL_FRONT, OpenGL.GL_AMBIENT_AND_DIFFUSE, grey); gl.Vertex(m_fX_max, 0f, m_fZ_max); gl.Material(OpenGL.GL_FRONT, OpenGL.GL_AMBIENT_AND_DIFFUSE, grey); gl.Vertex(0f, 0f, 0f); gl.Material(OpenGL.GL_FRONT, OpenGL.GL_AMBIENT_AND_DIFFUSE, grey); gl.Vertex(0f, 0f, m_fZ_max); gl.Material(OpenGL.GL_FRONT, OpenGL.GL_AMBIENT_AND_DIFFUSE, grey); gl.Vertex(m_fX_max, 0f, m_fZ_max); gl.End(); } } gl.Begin(OpenGL.GL_LINES); { if (CurrentPerspective != WaterfallPerspectives.Pers_2D) { //Y axis lines gl.Material(OpenGL.GL_FRONT, OpenGL.GL_AMBIENT_AND_DIFFUSE, AxleTextColor); gl.Vertex(0f, 0f, 0f); gl.Material(OpenGL.GL_FRONT, OpenGL.GL_AMBIENT_AND_DIFFUSE, AxleTextColor); gl.Vertex(0f, 1f, 0f); //Draw Y axis steps minor = YMinorStep / (m_fMaxAmplitude - m_fMinAmplitude); major = YMajorStep / (m_fMaxAmplitude - m_fMinAmplitude); for (xd = 0; xd <= 1.0f; xd += minor) { gl.Material(OpenGL.GL_FRONT, OpenGL.GL_AMBIENT_AND_DIFFUSE, AxleTextColor); gl.Vertex(0f, xd, -0.005f); gl.Material(OpenGL.GL_FRONT, OpenGL.GL_AMBIENT_AND_DIFFUSE, AxleTextColor); gl.Vertex(0f, xd, 0.005f); } for (xd = 0; xd <= 1.0f; xd += major) { gl.Material(OpenGL.GL_FRONT, OpenGL.GL_AMBIENT_AND_DIFFUSE, AxleTextColor); gl.Vertex(0f, xd, -0.01f); gl.Material(OpenGL.GL_FRONT, OpenGL.GL_AMBIENT_AND_DIFFUSE, AxleTextColor); gl.Vertex(0f, xd, 0.01f); } } //X axis grid for (xd = -(XOffset / fSpan); xd >= m_fX_max; xd += (m_fX_max / dXMajorAdjustedSteps)) { gl.Material(OpenGL.GL_FRONT, OpenGL.GL_AMBIENT_AND_DIFFUSE, AxleTextColor); gl.Vertex(xd, 0f, 0f); gl.Material(OpenGL.GL_FRONT, OpenGL.GL_AMBIENT_AND_DIFFUSE, AxleTextColor); gl.Vertex(xd, 0f, m_fZ_max); } gl.Material(OpenGL.GL_FRONT, OpenGL.GL_AMBIENT_AND_DIFFUSE, AxleTextColor); gl.Vertex(m_fX_max, 0f, 0f); gl.Material(OpenGL.GL_FRONT, OpenGL.GL_AMBIENT_AND_DIFFUSE, AxleTextColor); gl.Vertex(m_fX_max, 0f, m_fZ_max); gl.Material(OpenGL.GL_FRONT, OpenGL.GL_AMBIENT_AND_DIFFUSE, AxleTextColor); gl.Vertex(0f, 0f, 0f); gl.Material(OpenGL.GL_FRONT, OpenGL.GL_AMBIENT_AND_DIFFUSE, AxleTextColor); gl.Vertex(0f, 0f, m_fZ_max); //Z axis grid for (xd = 0; xd <= m_fZ_max; xd += (m_fZ_max / 10.0f)) { gl.Material(OpenGL.GL_FRONT, OpenGL.GL_AMBIENT_AND_DIFFUSE, AxleTextColor); gl.Vertex(0f, 0f, xd); gl.Material(OpenGL.GL_FRONT, OpenGL.GL_AMBIENT_AND_DIFFUSE, AxleTextColor); gl.Vertex(m_fX_max, 0f, xd); } gl.Material(OpenGL.GL_FRONT, OpenGL.GL_AMBIENT_AND_DIFFUSE, AxleTextColor); gl.Vertex(0f, 0f, m_fZ_max); gl.Material(OpenGL.GL_FRONT, OpenGL.GL_AMBIENT_AND_DIFFUSE, AxleTextColor); gl.Vertex(m_fX_max, 0f, m_fZ_max); } gl.End(); //labels for axles // amplitude axle float ratio = (float)Height / 60.0f; float FontSize = (float)Width / 120.0f;// this is kind of an aproximation to size of font based on size of screen if (ratio > FontSize) FontSize = ratio; if (CurrentPerspective != WaterfallPerspectives.Pers_2D) { float xsLabelPos, startXd; if (CurrentPerspective == WaterfallPerspectives.Perspective1) { xsLabelPos = 0.15f; startXd = 0f; } else if (CurrentPerspective == WaterfallPerspectives.Perspective2) { xsLabelPos = 0.07f; startXd = -0.02f; } else { xsLabelPos = 0.12f; startXd = -0.08f; } minor = YMinorStep / (m_fMaxAmplitude - m_fMinAmplitude); major = YMajorStep / (m_fMaxAmplitude - m_fMinAmplitude); double AmpScale = Math.Round(m_fMinAmplitude / YMajorStep) * (int)YMajorStep; double AmpStep = YMajorStep; for (xd = startXd; xd <= 1.0f; xd += major) { double[] modelview = new double[16]; double[] projection = new double[16]; int[] viewport = new int[4]; gl.GetDouble(OpenGL.GL_MODELVIEW_MATRIX, modelview); gl.GetDouble(OpenGL.GL_PROJECTION_MATRIX, projection); gl.GetInteger(OpenGL.GL_VIEWPORT, viewport); double[] xs = new double[1]; double[] ys = new double[1]; double[] zs = new double[1]; gl.Project(xsLabelPos, xd, -0.01f, modelview, projection, viewport, xs, ys, zs); string text; text = AmpScale.ToString() + " dBm"; gl.DrawText((int)xs[0], (int)ys[0], AxleTextColor[0], AxleTextColor[1], AxleTextColor[2], m_sFontName, FontSize, text); AmpScale += AmpStep; } } // frecuency axle minor = XMinorStep / (m_fMaxFrecuency - m_fMinFrecuency); major = XMajorStep / (m_fMaxFrecuency - m_fMinFrecuency); double FrecScale = m_fMinFrecuency + XOffset; double FrecStep = XMajorStep; float fScale = 0.7f; if ((CurrentPerspective != WaterfallPerspectives.Perspective1)) { fScale = 1.0f;// only scale in perspective } for (xd = -(XOffset / fSpan); xd >= m_fX_max; xd += (m_fX_max / dXMajorAdjustedSteps)) { double[] modelview = new double[16]; double[] projection = new double[16]; int[] viewport = new int[4]; gl.GetDouble(OpenGL.GL_MODELVIEW_MATRIX, modelview); gl.GetDouble(OpenGL.GL_PROJECTION_MATRIX, projection); gl.GetInteger(OpenGL.GL_VIEWPORT, viewport); double[] xs = new double[1]; double[] ys = new double[1]; double[] zs = new double[1]; if (CurrentPerspective == WaterfallPerspectives.ISO) gl.Project(xd + 0.01, -0.05f, -0.07f, modelview, projection, viewport, xs, ys, zs); else if (CurrentPerspective == WaterfallPerspectives.Pers_2D) gl.Project(xd + 0.01, -0.05f, -0.05, modelview, projection, viewport, xs, ys, zs); else gl.Project(xd + 0.01, -0.05f, -0.02, modelview, projection, viewport, xs, ys, zs); string text; FrecScale = Math.Round(FrecScale, 1); text = FrecScale.ToString() + " MHz"; gl.DrawText((int)xs[0], (int)ys[0], AxleTextColor[0], AxleTextColor[1], AxleTextColor[2], m_sFontName, FontSize * fScale, text); FrecScale += FrecStep; if ((CurrentPerspective == WaterfallPerspectives.Perspective1)) { fScale += 0.3f * (float)major; //for perspective, use increasing scale, smallest around the axis } } // time stamps fScale = 1.0f; for (xd = 0; xd <= 1.0f; xd += 0.1f) { double[] modelview = new double[16]; double[] projection = new double[16]; int[] viewport = new int[4]; gl.GetDouble(OpenGL.GL_MODELVIEW_MATRIX, modelview); gl.GetDouble(OpenGL.GL_PROJECTION_MATRIX, projection); gl.GetInteger(OpenGL.GL_VIEWPORT, viewport); double[] xs = new double[1]; double[] ys = new double[1]; double[] zs = new double[1]; if (CurrentPerspective == WaterfallPerspectives.Pers_2D) gl.Project(-1.0f, 0f, xd, modelview, projection, viewport, xs, ys, zs); else gl.Project(-1.03f, 0f, xd, modelview, projection, viewport, xs, ys, zs); string text; int index = (int)(xd * 100); text = m_arrTimeData[index].ToString("HH:mm:ss\\.fff"); gl.DrawText((int)xs[0], (int)ys[0], AxleTextColor[0], AxleTextColor[1], AxleTextColor[2], m_sFontName, FontSize * fScale, text); FrecScale += FrecStep; if ((CurrentPerspective == WaterfallPerspectives.Perspective1) || (CurrentPerspective == WaterfallPerspectives.Perspective2)) { fScale -= 0.04f; //for non-parallel perspectives, use a decreasing scale for far horizon text } } DrawDataTriangles(gl); // Nudge the rotation. //rotation += 0.3f; #if KEYCAPTURE double delta = 0.01; bool shift = GetAsyncKeyState(Keys.ShiftKey)<0; bool reset = false; if (GetAsyncKeyState(Keys.X)<0) { if (shift) eyex -= delta; else eyex += delta; reset = true; } else if (GetAsyncKeyState(Keys.Y)<0) { if (shift) eyey -= delta; else eyey += delta; reset = true; } else if (GetAsyncKeyState(Keys.Z)<0) { if (shift) eyez -= delta; else eyez += delta; reset = true; } else if (GetAsyncKeyState(Keys.Q)<0) { if (shift) centerx -= delta; else centerx += delta; reset = true; } else if (GetAsyncKeyState(Keys.W)<0) { if (shift) centery -= delta; else centery += delta; reset = true; } else if (GetAsyncKeyState(Keys.E)<0) { if (shift) centerz -= delta; else centerz += delta; reset = true; } if (reset) SetPerspective(); #endif } catch (Exception objEx) { Console.WriteLine(objEx.ToString()); } }
private void openGLControl_OpenGLDraw(object sender, RenderEventArgs e) { OpenGL gl = openGLControl.OpenGL; gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); gl.LoadIdentity(); // Auto-correct rotation values to keep them sane. if (rotationY > 360f) rotationY -= 360f; else if (rotationY < -360f) rotationY += 360f; gl.Rotate(rotationY, 0.0f, 1.0f, 0.0f); // Rotate Y gl.Enable(OpenGL.GL_TEXTURE_2D); foreach (Mesh mesh in meshes) if (mesh.ShouldRender) mesh.Draw(gl); gl.Disable(OpenGL.GL_TEXTURE_2D); if (autoRotate) rotationY += 3.0f; }
private void openGLControl1_OpenGLDraw(object sender, RenderEventArgs e) { OpenGL gl = openGLControl1.OpenGL; gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer gl.LoadIdentity(); // Reset The ModelView Matrix for (loop=0;loop<particles.Length;loop++) // Loop Through All The Particles { if (particles[loop].active) // If The Particle Is Active { float x = particles[loop].x; // Grab Our Particle X Position float y = particles[loop].y; // Grab Our Particle Y Position float z = particles[loop].z +zoom; // Particle Z Pos + Zoom // Draw The Particle Using Our RGB Values, Fade The Particle Based On It's Life gl.Color(particles[loop].r, particles[loop].g, particles[loop].b, particles[loop].life); gl.Begin(OpenGL.GL_TRIANGLE_STRIP); // Build Quad From A Triangle Strip gl.TexCoord(1,1); gl.Vertex(x+0.5f,y+0.5f,z); // Top Right gl.TexCoord(0,1); gl.Vertex(x-0.5f,y+0.5f,z); // Top Left gl.TexCoord(1,0); gl.Vertex(x+0.5f,y-0.5f,z); // Bottom Right gl.TexCoord(0,0); gl.Vertex(x-0.5f,y-0.5f,z); // Bottom Left gl.End(); // Done Building Triangle Strip particles[loop].x += particles[loop].xi / (slowdown * 1000); // Move On The X Axis By X Speed particles[loop].y += particles[loop].yi / (slowdown * 1000); // Move On The Y Axis By Y Speed particles[loop].z += particles[loop].zi / (slowdown * 1000); // Move On The Z Axis By Z Speed particles[loop].xi += particles[loop].xg; // Take Pull On X Axis Into Account particles[loop].yi += particles[loop].yg; // Take Pull On Y Axis Into Account particles[loop].zi += particles[loop].zg; // Take Pull On Z Axis Into Account particles[loop].life -= particles[loop].fade; // Reduce Particles Life By 'Fade' if (particles[loop].life < 0.0f) // If Particle Is Burned Out { particles[loop].life = 1.0f; // Give It New Life particles[loop].fade = (float)(random.Next(100)) / 1000.0f + 0.003f; // Random Fade Speed particles[loop].x = 0.0f; // Center On X Axis particles[loop].y = 0.0f; // Center On Y Axis particles[loop].z = 0.0f; // Center On Z Axis particles[loop].xi = (float)((random.Next(50) - 26.0f) * 10.0f); // Random Speed On X Axis particles[loop].yi = (float)((random.Next(50) - 25.0f) * 10.0f); // Random Speed On Y Axis particles[loop].zi = (float)((random.Next(50) - 25.0f) * 10.0f); // Random Speed On Y Axis int colour = random.Next(12); particles[loop].r = colors[colour, 0]; // Select Red From Color Table particles[loop].g = colors[colour, 1]; // Select Green From Color Table particles[loop].b = colors[colour, 2]; // Select Blue From Color Table } } } }
/// <summary> /// Handles the OpenGLDraw event of the openGLControl control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RenderEventArgs"/> instance containing the event data.</param> private void openGLControl_OpenGLDraw(object sender, RenderEventArgs e) { OpenGL gl = openGLControl.OpenGL; gl.MatrixMode(OpenGL.GL_PROJECTION); // Clear the color and depth buffer. gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); // Load the identity matrix. gl.LoadIdentity(); gl.Ortho2D(0, this.openGLControl.Size.Width, 0, this.openGLControl.Size.Height * 2); gl.Color(1.0f,1.0f,1.0f); gl.Begin(OpenGL.GL_LINE_STRIP); gl.Vertex(1.0d,0.0d); gl.Vertex(1.0d, this.openGLControl.Size.Height*3); for (int i = 0; i < 3;i++ ) { for(int j=0;j<openGLControl.Size.Height;j+=5) { gl.Vertex(0.0d, i * openGLControl.Size.Height + j); gl.Vertex(1.0d, i * openGLControl.Size.Height + j); } } gl.End(); gl.Color(0.0f, 1.0f, 0.0f); //gl.Vertex(0, 0); //gl.Vertex(50, 100); gl.Begin(OpenGL.GL_LINE_STRIP);//| gl.Vertex(this.openGLControl.Width - 200, 0); gl.Vertex(this.openGLControl.Width - 200, this.openGLControl.Size.Height*3 - 1); gl.End(); int Height = this.openGLControl.Size.Height; for (int i = 0; i < 24; i ++) { gl.Begin(OpenGL.GL_LINE_STRIP); gl.Vertex(0, i*Height/12); gl.Vertex(5, i*Height/12); gl.End(); } /* gl.Color(1.0, 0.0f, 0.0f); gl.Begin(OpenGL.GL_LINE_STRIP); for (int i = 10; i < this.openGLControl.Width - 200; i++) { if (receivedValue.getValue(i) < 60) continue; gl.Vertex(i, receivedValue.getValue(i)); } gl.End();*/ gl.Color(0.0f, 1.0f, 0.0f); gl.Begin(OpenGL.GL_LINE_STRIP); gl.Vertex(1, this.openGLControl.Size.Height); gl.Vertex(openGLControl.Size.Width - 200, this.openGLControl.Size.Height); gl.End(); gl.Color(1.0f, 0.0f, 0.0f); gl.Begin(OpenGL.GL_LINE_STRIP); for (int i = 10; i < this.openGLControl.Width - 200; i++) { if (Svalue.getValue(i) < 60||Svalue.getValue(i)>650) continue; gl.Vertex(i, Svalue.getValue(i)+0); } gl.End(); gl.Color(1.0f, 1.0f, 0.0f); gl.Begin(OpenGL.GL_LINE_STRIP); for (int i = 10; i < this.openGLControl.Width - 200; i++) { if (Evalue.getValue(i) < 60||Evalue.getValue(i)>200) continue; gl.Vertex(i, Evalue.getValue(i) + this.openGLControl.Size.Height); } gl.End(); //for (int i=10;) gl.Flush(); label1.Text="GSR "+Svalue.newest.ToString(); label2.Text="EMG "+Evalue.newest.ToString(); label3.Text="HB "+receivedValue.newest.ToString(); }
private void openGLControl1_OpenGLDraw(object sender, RenderEventArgs e) { // Get the OpenGL object, just to clean up the code. OpenGL gl = this.openGLControl1.OpenGL; gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer gl.LoadIdentity(); // Reset The View // gl.Color(1.0f, 1.0f, 1.0f); // gl.FontBitmaps.DrawText(gl, 0, 0, "Arial", "Argh"); gl.Translate(-1.5f, 0.0f, -6.0f); // Move Left And Into The Screen gl.Rotate(rtri, 0.0f, 1.0f, 0.0f); // Rotate The Pyramid On It's Y Axis gl.Begin(OpenGL.GL_TRIANGLES); // Start Drawing The Pyramid gl.Color(1.0f, 0.0f, 0.0f); // Red gl.Vertex(0.0f, 1.0f, 0.0f); // Top Of Triangle (Front) gl.Color(0.0f, 1.0f, 0.0f); // Green gl.Vertex(-1.0f, -1.0f, 1.0f); // Left Of Triangle (Front) gl.Color(0.0f, 0.0f, 1.0f); // Blue gl.Vertex(1.0f, -1.0f, 1.0f); // Right Of Triangle (Front) gl.Color(1.0f, 0.0f, 0.0f); // Red gl.Vertex(0.0f, 1.0f, 0.0f); // Top Of Triangle (Right) gl.Color(0.0f, 0.0f, 1.0f); // Blue gl.Vertex(1.0f, -1.0f, 1.0f); // Left Of Triangle (Right) gl.Color(0.0f, 1.0f, 0.0f); // Green gl.Vertex(1.0f, -1.0f, -1.0f); // Right Of Triangle (Right) gl.Color(1.0f, 0.0f, 0.0f); // Red gl.Vertex(0.0f, 1.0f, 0.0f); // Top Of Triangle (Back) gl.Color(0.0f, 1.0f, 0.0f); // Green gl.Vertex(1.0f, -1.0f, -1.0f); // Left Of Triangle (Back) gl.Color(0.0f, 0.0f, 1.0f); // Blue gl.Vertex(-1.0f, -1.0f, -1.0f); // Right Of Triangle (Back) gl.Color(1.0f, 0.0f, 0.0f); // Red gl.Vertex(0.0f, 1.0f, 0.0f); // Top Of Triangle (Left) gl.Color(0.0f, 0.0f, 1.0f); // Blue gl.Vertex(-1.0f, -1.0f, -1.0f); // Left Of Triangle (Left) gl.Color(0.0f, 1.0f, 0.0f); // Green gl.Vertex(-1.0f, -1.0f, 1.0f); // Right Of Triangle (Left) gl.End(); // Done Drawing The Pyramid gl.LoadIdentity(); gl.Translate(1.5f, 0.0f, -7.0f); // Move Right And Into The Screen gl.Rotate(rquad, 1.0f, 1.0f, 1.0f); // Rotate The Cube On X, Y & Z gl.Begin(OpenGL.GL_QUADS); // Start Drawing The Cube gl.Color(0.0f, 1.0f, 0.0f); // Set The Color To Green gl.Vertex(1.0f, 1.0f, -1.0f); // Top Right Of The Quad (Top) gl.Vertex(-1.0f, 1.0f, -1.0f); // Top Left Of The Quad (Top) gl.Vertex(-1.0f, 1.0f, 1.0f); // Bottom Left Of The Quad (Top) gl.Vertex(1.0f, 1.0f, 1.0f); // Bottom Right Of The Quad (Top) gl.Color(1.0f, 0.5f, 0.0f); // Set The Color To Orange gl.Vertex(1.0f, -1.0f, 1.0f); // Top Right Of The Quad (Bottom) gl.Vertex(-1.0f, -1.0f, 1.0f); // Top Left Of The Quad (Bottom) gl.Vertex(-1.0f, -1.0f, -1.0f); // Bottom Left Of The Quad (Bottom) gl.Vertex(1.0f, -1.0f, -1.0f); // Bottom Right Of The Quad (Bottom) gl.Color(1.0f, 0.0f, 0.0f); // Set The Color To Red gl.Vertex(1.0f, 1.0f, 1.0f); // Top Right Of The Quad (Front) gl.Vertex(-1.0f, 1.0f, 1.0f); // Top Left Of The Quad (Front) gl.Vertex(-1.0f, -1.0f, 1.0f); // Bottom Left Of The Quad (Front) gl.Vertex(1.0f, -1.0f, 1.0f); // Bottom Right Of The Quad (Front) gl.Color(1.0f, 1.0f, 0.0f); // Set The Color To Yellow gl.Vertex(1.0f, -1.0f, -1.0f); // Bottom Left Of The Quad (Back) gl.Vertex(-1.0f, -1.0f, -1.0f); // Bottom Right Of The Quad (Back) gl.Vertex(-1.0f, 1.0f, -1.0f); // Top Right Of The Quad (Back) gl.Vertex(1.0f, 1.0f, -1.0f); // Top Left Of The Quad (Back) gl.Color(0.0f, 0.0f, 1.0f); // Set The Color To Blue gl.Vertex(-1.0f, 1.0f, 1.0f); // Top Right Of The Quad (Left) gl.Vertex(-1.0f, 1.0f, -1.0f); // Top Left Of The Quad (Left) gl.Vertex(-1.0f, -1.0f, -1.0f); // Bottom Left Of The Quad (Left) gl.Vertex(-1.0f, -1.0f, 1.0f); // Bottom Right Of The Quad (Left) gl.Color(1.0f, 0.0f, 1.0f); // Set The Color To Violet gl.Vertex(1.0f, 1.0f, -1.0f); // Top Right Of The Quad (Right) gl.Vertex(1.0f, 1.0f, 1.0f); // Top Left Of The Quad (Right) gl.Vertex(1.0f, -1.0f, 1.0f); // Bottom Left Of The Quad (Right) gl.Vertex(1.0f, -1.0f, -1.0f); // Bottom Right Of The Quad (Right) gl.End(); // Done Drawing The Q gl.Flush(); rtri += 3.0f;// 0.2f; // Increase The Rotation Variable For The Triangle rquad -= 3.0f;// 0.15f; // Decrease The Rotation Variable For The Quad }
/// <summary> /// Handles the OpenGLDraw event of the openGLControl1 control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RenderEventArgs"/> instance containing the event data.</param> private void openGLControl1_OpenGLDraw(object sender, RenderEventArgs e) { // Get OpenGL. var gl = openGLControl1.OpenGL; // Clear and load identity. gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); gl.LoadIdentity(); // Use gluLookAt to look at torus. gl.LookAt(0.0f,10.0f,10.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f); // Rotate torus. angle += .5f; gl.Rotate(angle, 0.0f, 1.0f, 0.0f); // Push all attribute bits. gl.PushAttrib(OpenGL.GL_ALL_ATTRIB_BITS); // Get the inverse model matrix gl.PushMatrix(); gl.LoadIdentity(); gl.Rotate(-angle, 0.0f, 1.0f, 0.0f); var inverseModelMatrix = gl.GetModelViewMatrix(); gl.PopMatrix(); // Get the object space light vector. Vertex objectLightPosition = inverseModelMatrix * worldLightPosition; // Loop through vertices for(int i=0; i<torus.NumVertices; ++i) { Vertex lightVector = objectLightPosition - torus.Vertices[i].position; //Calculate tangent space light vector torus.Vertices[i].tangentSpaceLight.X = torus.Vertices[i].sTangent.ScalarProduct(lightVector); torus.Vertices[i].tangentSpaceLight.Y = torus.Vertices[i].tTangent.ScalarProduct(lightVector); torus.Vertices[i].tangentSpaceLight.Z = torus.Vertices[i].normal.ScalarProduct(lightVector); } // Draw bump pass if(drawBumps) { // Bind normal map to texture unit 0 normalMap.Bind(gl); gl.Enable(OpenGL.GL_TEXTURE_2D); // Bind normalisation cube map to texture unit 1 // Extensions: We can use the Extension format, such as below. However in this // case we'll get a warning saying that this particular extension is deprecated // in OpenGL 3.0. However... gl.ActiveTextureARB(OpenGL.GL_TEXTURE1_ARB); gl.BindTexture(OpenGL.GL_TEXTURE_CUBE_MAP_EXT, normalisationCubeMap); gl.Enable(OpenGL.GL_TEXTURE_CUBE_MAP_EXT); // Extensions: ...it's deprecated because it's actually core functionality // in OpenGL 3.0. gl.ActiveTexture(OpenGL.GL_TEXTURE0_ARB); //Set vertex arrays for torus var vertexHandle = GCHandle.Alloc(torus.Vertices, GCHandleType.Pinned); // Address of TorusVertex.Position gl.VertexPointer(3, OpenGL.GL_FLOAT, Marshal.SizeOf(typeof(TorusVertex)), IntPtr.Add(vertexHandle.AddrOfPinnedObject(), 0)); gl.EnableClientState(OpenGL.GL_VERTEX_ARRAY); //Send texture coords for normal map to unit 0 // Address of TorusVertex.S gl.TexCoordPointer(2, OpenGL.GL_FLOAT, Marshal.SizeOf(typeof(TorusVertex)), IntPtr.Add(vertexHandle.AddrOfPinnedObject(), 12)); gl.EnableClientState(OpenGL.GL_TEXTURE_COORD_ARRAY); //Send tangent space light vectors for normalisation to unit 1 gl.ClientActiveTexture(OpenGL.GL_TEXTURE1_ARB); // Address of TorusVertex.TangentSpaceLight gl.TexCoordPointer(3, OpenGL.GL_FLOAT, Marshal.SizeOf(typeof(TorusVertex)), IntPtr.Add(vertexHandle.AddrOfPinnedObject(), 56)); gl.EnableClientState(OpenGL.GL_TEXTURE_COORD_ARRAY); gl.ClientActiveTexture(OpenGL.GL_TEXTURE0_ARB); vertexHandle.Free(); //Set up texture environment to do (tex0 dot tex1)*color gl.TexEnv(OpenGL.GL_TEXTURE_ENV, OpenGL.GL_TEXTURE_ENV_MODE, OpenGL.GL_COMBINE_ARB); gl.TexEnv(OpenGL.GL_TEXTURE_ENV, OpenGL.GL_SOURCE0_RGB_ARB, OpenGL.GL_TEXTURE); gl.TexEnv(OpenGL.GL_TEXTURE_ENV, OpenGL.GL_COMBINE_RGB_ARB, OpenGL.GL_REPLACE); gl.ActiveTexture(OpenGL.GL_TEXTURE1_ARB); gl.TexEnv(OpenGL.GL_TEXTURE_ENV, OpenGL.GL_TEXTURE_ENV_MODE, OpenGL.GL_COMBINE_ARB); gl.TexEnv(OpenGL.GL_TEXTURE_ENV, OpenGL.GL_SOURCE0_RGB_ARB, OpenGL.GL_TEXTURE); gl.TexEnv(OpenGL.GL_TEXTURE_ENV, OpenGL.GL_COMBINE_RGB_ARB, OpenGL.GL_DOT3_RGB_ARB); gl.TexEnv(OpenGL.GL_TEXTURE_ENV, OpenGL.GL_SOURCE1_RGB_ARB, OpenGL.GL_PREVIOUS_ARB); gl.ActiveTexture(OpenGL.GL_TEXTURE0_ARB); // Draw torus gl.DrawElements(OpenGL.GL_TRIANGLES, (int)torus.NumIndices, torus.Indices); // Disable textures gl.Disable(OpenGL.GL_TEXTURE_2D); gl.ActiveTexture(OpenGL.GL_TEXTURE1_ARB); gl.Disable(OpenGL.GL_TEXTURE_CUBE_MAP); gl.ActiveTexture(OpenGL.GL_TEXTURE0_ARB); // Disable vertex arrays gl.DisableClientState(OpenGL.GL_VERTEX_ARRAY); gl.DisableClientState(OpenGL.GL_TEXTURE_COORD_ARRAY); gl.ClientActiveTexture(OpenGL.GL_TEXTURE1_ARB); gl.DisableClientState(OpenGL.GL_TEXTURE_COORD_ARRAY); gl.ClientActiveTexture(OpenGL.GL_TEXTURE0_ARB); // Return to standard modulate texenv gl.TexEnv(OpenGL.GL_TEXTURE_ENV, OpenGL.GL_TEXTURE_ENV_MODE, OpenGL.GL_MODULATE); } // If we are drawing both passes, enable blending to multiply them together if(drawBumps && drawColor) { // Enable multiplicative blending gl.BlendFunc(OpenGL.GL_DST_COLOR, OpenGL.GL_ZERO); gl.Enable(OpenGL.GL_BLEND); } // Perform a second pass to color the torus if(drawColor) { if(!drawBumps) { gl.Light(OpenGL.GL_LIGHT1, OpenGL.GL_POSITION, objectLightPosition); gl.Light(OpenGL.GL_LIGHT1, OpenGL.GL_DIFFUSE, white); gl.Light(OpenGL.GL_LIGHT1, OpenGL.GL_AMBIENT, black); gl.LightModel(OpenGL.GL_LIGHT_MODEL_AMBIENT, black); gl.Enable(OpenGL.GL_LIGHT1); gl.Enable(OpenGL.GL_LIGHTING); gl.Material(OpenGL.GL_FRONT, OpenGL.GL_DIFFUSE, white); } // Bind decal texture decalImage.Bind(gl); gl.Enable(OpenGL.GL_TEXTURE_2D); // Set vertex arrays for torus var torusVertices = GCHandle.Alloc(torus.Vertices, GCHandleType.Pinned); // Address of TorusVertex.Position gl.VertexPointer(3, OpenGL.GL_FLOAT, Marshal.SizeOf(typeof(TorusVertex)), IntPtr.Add(torusVertices.AddrOfPinnedObject(), 0)); gl.EnableClientState(OpenGL.GL_VERTEX_ARRAY); // Address of TorusVertex.Normal gl.NormalPointer(OpenGL.GL_FLOAT, Marshal.SizeOf(typeof(TorusVertex)), IntPtr.Add(torusVertices.AddrOfPinnedObject(), 44 )); gl.EnableClientState(OpenGL.GL_NORMAL_ARRAY); // Address of TorusVertex.S gl.TexCoordPointer(2, OpenGL.GL_FLOAT, Marshal.SizeOf(typeof(TorusVertex)), IntPtr.Add(torusVertices.AddrOfPinnedObject(), 12)); gl.EnableClientState(OpenGL.GL_TEXTURE_COORD_ARRAY); torusVertices.Free(); // Draw torus gl.DrawElements(OpenGL.GL_TRIANGLES, (int)torus.NumIndices, torus.Indices); if(!drawBumps) gl.Disable(OpenGL.GL_LIGHTING); // Disable texture gl.Disable(OpenGL.GL_TEXTURE_2D); // Disable vertex arrays gl.DisableClientState(OpenGL.GL_VERTEX_ARRAY); gl.DisableClientState(OpenGL.GL_NORMAL_ARRAY); gl.DisableClientState(OpenGL.GL_TEXTURE_COORD_ARRAY); } // Disable blending if it is enabled if(drawBumps && drawColor) gl.Disable(OpenGL.GL_BLEND); gl.PopAttrib(); gl.Finish(); }
/// <summary> /// Call this function in derived classes to do the GDI Draw event. /// </summary> protected virtual void DoGDIDraw(RenderEventArgs e) { var handler = GDIDraw; if (handler != null) handler(this, e); }
/// <summary> /// Handles the OpenGLDraw event of the openGLControl control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RenderEventArgs"/> instance containing the event data.</param> private void openGLControl_OpenGLDraw(object sender, RenderEventArgs e) { OpenGL gl = openGLControl.OpenGL; gl.MatrixMode(OpenGL.GL_PROJECTION); // Clear the color and depth buffer. gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); // Load the identity matrix. gl.LoadIdentity(); gl.Ortho2D(0, this.openGLControl.Size.Width, 0, this.openGLControl.Size.Height); gl.Color(0.0f, 1.0f, 0.0f); //gl.Vertex(0, 0); //gl.Vertex(50, 100); gl.Begin(OpenGL.GL_LINE_STRIP); for (int i = 0; i < this.openGLControl.Width - 1; i++) { if (receivedValue.getValue(i) <= 70) continue; gl.Vertex(i,receivedValue.getValue(i)); } gl.End(); gl.Flush(); }
public void openGLCtrl1_OpenGLDraw(object sender, RenderEventArgs e) { if (doRender) { gl.ClearColor(.25f, .2f, .2f, 1); gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); gl.LoadIdentity(); gl.Translate(-.2f, -.2f, -3.25f + delta); gl.Rotate(deltaY, .5f, 0, 0); gl.Rotate(deltaX, 0f, .5f, 0); try { gl.Color(1f, 1f, 1f); gl.Enable(OpenGL.GL_LINE_SMOOTH); gl.Enable(OpenGL.GL_BLEND); gl.BlendFunc(OpenGL.GL_SRC_ALPHA, OpenGL.GL_ONE_MINUS_SRC_ALPHA); gl.Hint(OpenGL.GL_LINE_SMOOTH_HINT, OpenGL.GL_DONT_CARE); gl.LineWidth(.25f); //draw the containing box gl.Begin(OpenGL.GL_LINES); gl.Vertex(0, 0, 0); gl.Vertex(0, 0, 1); gl.Vertex(0, 0, 0); gl.Vertex(1, 0, 0); gl.Vertex(0, 0, 0); gl.Vertex(0, 1, 0); gl.Vertex(0, 1, 1); gl.Vertex(0, 0, 1); gl.Vertex(0, 1, 1); gl.Vertex(0, 1, 0); gl.Vertex(0, 1, 1); gl.Vertex(1, 1, 1); gl.Vertex(1, 1, 0); gl.Vertex(1, 0, 0); gl.Vertex(1, 1, 0); gl.Vertex(0, 1, 0); gl.Vertex(1, 1, 0); gl.Vertex(1, 1, 1); gl.Vertex(1, 0, 1); gl.Vertex(0, 0, 1); gl.Vertex(1, 0, 1); gl.Vertex(1, 0, 0); gl.Vertex(1, 0, 1); gl.Vertex(1, 1, 1); gl.End(); gl.Color(0f, .9f, (float)1); gl.Begin(OpenGL.GL_LINES); gl.Vertex(0, 0, 0); gl.Vertex(0, 0, 100); gl.Vertex(0, 0, 0); gl.Vertex(0, 100, 0); gl.Vertex(0, 0, 0); gl.Vertex(100, 0, 0); gl.End(); gl.LineWidth(.15f); gl.Begin(OpenGL.GL_LINES); int renderCounterL = 0; //draw the lines for each firing path RenderLine cq; using (var locked = lineQueue.Lock()) { while (locked.Count > 0) { cq = locked.Dequeue(); if (cq != null) { bx0 = cq.xS; bx1 = cq.xV; by0 = cq.yS; by1 = cq.yV; bz0 = cq.zS; bz1 = cq.zV; gl.Color(cq.actionR, cq.actionG, cq.actionB); gl.Vertex(bx0, by0, bz0); gl.Vertex(bx1, by1, bz1); } renderCounterL++; } lineQueue.Clear(); } gl.End(); } catch { } doRender = false; } }
private void openGLControl2_OpenGLDraw(object sender, RenderEventArgs e) { SampleRendering(openGLControl2.OpenGL, 1.0f, 0.0f, 0.0f); }
/// <summary> /// Handles the OpenGLDraw event of the openGLControl1 control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="args">The <see cref="RenderEventArgs"/> instance containing the event data.</param> private void openGLControl1_OpenGLDraw(object sender, RenderEventArgs args) { // Draw the scene. scene.Draw(openGLControl1.OpenGL); }
private void openGLControl1_OpenGLDraw(object sender, SharpGL.RenderEventArgs args) { gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT | OpenGL.GL_STENCIL_BUFFER_BIT); drawCoorAxis(); drawPoints(); }
private void openGLControl1_OpenGLDraw(object sender, SharpGL.RenderEventArgs args) { OpenGL glWind = this.openGLControl1.OpenGL; // для удобства работы с окном вывода //надо накладывать 3д текстуру! //glWind.Enable(OpenGL.GL_TEXTURE_2D); //texture.Create(glWind, "testFoto2.jpg"); glWind.Enable(OpenGL.GL_TEXTURE_2D); texture.Create(glWind, _fileName /*"testFoto10.jpg"*/); // задаём текстуру glWind.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); // чистим цвета и глубины glWind.LoadIdentity(); // сброс системы координат к начальной позиции glWind.Translate(0.0f, -0.5f, -3.0f); // по сути двигаем перо, которым рисуем (f - float) glWind.Rotate(rtri, 0, 1, 0); // вращение системы координат (угол поворота, координаты вектора вращения) // texture.Bind(glWind); //int[] textures = new int[1000]; // glTexCoord2f(x1 / 383.0, y1 / 383.0); // glTexCoord2f(x2 / 383.0, y1 / 383.0); // glTexCoord2f(x2 / 383.0, y2 / 383.0); // glTexCoord2f(x1 / 383.0, y2 / 383.0); // либо GUAD_STRIP попробовать // glWind.Begin(OpenGL.GL_POLYGON); // начинаем отрисовывать // // // glWind.TexSubImage2D(OpenGL.GL_TEXTURE_2D, 0, 300, 197, 100, 100, OpenGL.GL_RGB, OpenGL.GL_UNSIGNED_BYTE, textures); // // // glWind.Color(1.0f, 1.0f, 1.0f); // задаём цвет в RGB // // glWind.TexCoord(0.0f, 1.0f); // glWind.TexCoord(1.0 / _photo.Height * 10.0, 1.0 / _photo.Width * 50.0); // glWind.DrawingVertex(-2.0f, 2.0f, -0.5f); // задаём вершину // //glWind.Color(0.0f, 0.0f, 1.0f); // задаём цвет в RGB // // //glWind.TexCoord(1.0f, 1.0f); // glWind.TexCoord(1.0 / 1920 * 500.0, 1.0 / 1200 * 50.0); // glWind.DrawingVertex(2.0f, 2.0f, -0.5f); // задаём вершину // // //glWind.TexCoord(1.0f, 0.0f); // glWind.TexCoord(1.0 / 1920 * 745.0, 1.0 / 1200 * 125.0); // glWind.DrawingVertex(4.0f, 1.0f, -0.5f); // задаём вершину // // //glWind.TexCoord(0.0f, 0.0f); // glWind.TexCoord(1.0 / 1920 * 500.0, 1.0 / 1200 * 350.0); // glWind.DrawingVertex(2.0f, -2.0f, -0.5f); // задаём вершину // // glWind.TexCoord(1.0 / 1920 * 10.0, 1.0 / 1200 * 350.0); // glWind.DrawingVertex(-2.0f, -2.0f, -0.5f); // задаём вершину //glWind.DrawingVertex(0.0f, 0.0f, -1.0f); // задаём вершину //glWind.Color(1.0f, 0.0f, 1.0f); // задаём цвет в RGB //glWind.DrawingVertex(-0.3f, 0.2f, -1.0f); // задаём вершину //glWind.DrawingVertex(-0.4f, 0.3f, -1.0f); // задаём вершину //glWind.DrawingVertex(-0.2f, 0.2f, -1.0f); // задаём вершину //glWind.DrawingVertex(0.2f, 0.1f, -1.0f); // задаём вершину Set3DModel(glWind); glWind.Flush(); rtri += 5; }
private void view_OpenGLDraw(object sender, RenderEventArgs args) { var gl = view.OpenGL; gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); gl.MatrixMode(OpenGL.GL_MODELVIEW); gl.LoadIdentity(); gl.LookAt(_eye.X, _eye.Y, _eye.Z, 0, 0, 0, 0, 0, 1); if (_showCoordinateAxes) { drawCoordinateAxes(gl); } if (_polygons == null) { return; } foreach (var polygon in _polygons) { gl.Color(OpenGlUtility.GetOpenGlColor(polygon.Color)); gl.Begin(OpenGL.GL_POLYGON); foreach (var vertex in polygon.Vertexes) { gl.Vertex(vertex.X, vertex.Y, vertex.Z); } gl.End(); } gl.Flush(); }
/// <summary> /// Handles the OpenGLDraw event of the openGLControl control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RenderEventArgs"/> instance containing the event data.</param> private void openGLControl_OpenGLDraw(object sender, RenderEventArgs e) { OpenGL gl = openGLControl.OpenGL; //engine.Update(); engine.Draw(gl); }
private void openGLControl_OpenGLDraw(object sender, RenderEventArgs e) { // Get the OpenGL object. OpenGL gl = Graf.OpenGL; // Clear the color and depth buffer. gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); // Load the identity matrix. gl.LoadIdentity(); gl.PushMatrix(); //Отрисовка космоса. Сначала переносим цент и поворачиваем на нужный угол пространство. Подгружаем текстуры и совершаем обратные действия //gl.Color(1, 1, 1, 1); //gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT); gl.Rotate(90, 1, 0, 0); gl.Rotate(-45, 0, 0, 1); gl.Rotate(-x_r / 15, 0, 0, 1); gl.Translate(0, 0, -4000); sTex.Bind(gl); gl.Enable(OpenGL.GL_TEXTURE_2D); gl.Cylinder(tex, ATMOSPHERE_HEIGHT_Z * 0.0025 / ZOOMER, ATMOSPHERE_HEIGHT_Z * 0.0025 / ZOOMER, 8000, 64, 64); gl.Disable(OpenGL.GL_TEXTURE_2D); gl.Translate(0, 0, 4000); gl.Rotate(x_r / 15, 0, 0, 1); gl.Rotate(45, 0, 0, 1); gl.Rotate(-90, 1, 0, 0); int I_DONT_NOW_WHAT_IS_IT = 300; if (Math.Abs(x_r) > I_DONT_NOW_WHAT_IS_IT) x_r = Math.Sign(x_r) * I_DONT_NOW_WHAT_IS_IT; if (Math.Abs(y_r) > I_DONT_NOW_WHAT_IS_IT) y_r = Math.Sign(y_r) * I_DONT_NOW_WHAT_IS_IT; float angle_cam = (float)Math.Atan(y_r / (x_r - D_NUM)); float circ_abroad = (float)Math.Sqrt(EARTH_RADIUS_Z * EARTH_RADIUS_Z * (1 - 5 * 5 * zoom * zoom / max_zoom / max_zoom)) / 2 + 5; //Ограничение на движение экрана к центру Земли - для того, чтобы нельзя было посмотреть "внутренности" Земли //Все коэффициенты определены практическим путем if (zoom < 1.83) { if (Math.Abs(x_r) < Math.Abs(Math.Cos(angle_cam) * circ_abroad) + D_NUM) x_r = Math.Sign(x_r + D_NUM) * Math.Cos(angle_cam) * circ_abroad; if (Math.Abs(y_r) < Math.Abs(Math.Sin(angle_cam) * circ_abroad)) y_r = Math.Sign(x_r) * Math.Sin(angle_cam) * circ_abroad; } ////Преобразование изображение в соответствии с действиями пользователя. То есть сдвиг. gl.Translate(x_r * 2, -y_r * 2, -EARTH_RADIUS_Z * 5 * zoom / (max_zoom - 3)); gl.Rotate(180, 1, 0, 0); float ang = +(90 - angle) - (90 - angle) * (min_zoom / zoom); gl.Rotate(90, 1, 0, 0); gl.Rotate(180, 0, 1, 0); eTex.Bind(gl); gl.Enable(OpenGL.GL_TEXTURE_2D); gl.Sphere(tex, EARTH_RADIUS_Z, 64, 64); gl.Disable(OpenGL.GL_TEXTURE_2D); gl.Rotate(-180, 0, 1, 0); gl.Rotate(-90, 1, 0, 0); //Завершение отрисоовки Земли gl.Translate(0, -start_height * ZOOMER - EARTH_RADIUS_Z, 0); //Определение временного промежутка, вплоть до которого дошел метеорит int last_index = (int)(time / dt); if (count_render_points < last_index) { last_index = count_render_points; } last_graph = last_index; //Отрисовка траектории if (state != 0) { gl.Color(0.9, 1, 0); gl.LineWidth(3); int i = 0; gl.Begin(OpenGL.GL_LINE_STRIP); for (; i <= last_index; i++) { gl.Vertex(trajectory[i, 0], trajectory[i, 1], 0); } gl.End(); // Gl.glTranslated(trajectory[last_index, 0], trajectory[last_index, 1], 0); gl.Translate(trajectory[last_index, 0], trajectory[last_index, 1], 0); //Gl.glLineWidth(1); gl.LineWidth(1); if (last_index + 5 > MAX_ARRAY_SIZE && !err_message) { err_message = true; MessageBox.Show("Памяти, выделяемой компьютером, не хватает для того, чтобы отобразить всю траекторию"); } } float x = trajectory[last_index, 0]; float y = trajectory[last_index, 1]; gl.LineWidth(1); gl.Color(0.1, 1, 0); gl.Begin(OpenGL.GL_LINES); gl.Vertex( - zoom * 60000 * ZOOMER / 2, - zoom * 60000 * ZOOMER / 2, -zoom * 60000 * ZOOMER / 2); gl.Vertex( - zoom * 60000 * ZOOMER / 2, + zoom * 60000 * ZOOMER / 2, -zoom * 60000 * ZOOMER / 2); gl.Vertex( - zoom * 60000 * ZOOMER / 2, + zoom * 60000 * ZOOMER / 2, -zoom * 60000 * ZOOMER / 2); gl.Vertex( + zoom * 60000 * ZOOMER / 2, + zoom * 60000 * ZOOMER / 2, -zoom * 60000 * ZOOMER / 2); gl.Vertex( + zoom * 60000 * ZOOMER / 2, + zoom * 60000 * ZOOMER / 2, -zoom * 60000 * ZOOMER / 2); gl.Vertex( + zoom * 60000 * ZOOMER / 2, - zoom * 60000 * ZOOMER / 2, -zoom * 60000 * ZOOMER / 2); gl.Vertex( + zoom * 60000 * ZOOMER / 2, - zoom * 60000 * ZOOMER / 2, -zoom * 60000 * ZOOMER / 2); gl.Vertex( - zoom * 60000 * ZOOMER / 2, - zoom * 60000 * ZOOMER / 2, -zoom * 60000 * ZOOMER / 2); gl.Vertex( - zoom * 60000 * ZOOMER / 2, - zoom * 60000 * ZOOMER / 2, -zoom * 60000 * ZOOMER / 2); gl.Vertex( - zoom * 60000 * ZOOMER / 2, - zoom * 60000 * ZOOMER / 2, zoom * 60000 * ZOOMER / 2); gl.Vertex( - zoom * 60000 * ZOOMER / 2, - zoom * 60000 * ZOOMER / 2, zoom * 60000 * ZOOMER / 2); gl.Vertex( - zoom * 60000 * ZOOMER / 2, + zoom * 60000 * ZOOMER / 2, zoom * 60000 * ZOOMER / 2); gl.Vertex( - zoom * 60000 * ZOOMER / 2, + zoom * 60000 * ZOOMER / 2, zoom * 60000 * ZOOMER / 2); gl.Vertex( - zoom * 60000 * ZOOMER / 2, + zoom * 60000 * ZOOMER / 2, -zoom * 60000 * ZOOMER / 2); gl.Vertex( - zoom * 60000 * ZOOMER / 2, + zoom * 60000 * ZOOMER / 2, zoom * 60000 * ZOOMER / 2); gl.Vertex( + zoom * 60000 * ZOOMER / 2, + zoom * 60000 * ZOOMER / 2, zoom * 60000 * ZOOMER / 2); gl.Vertex( + zoom * 60000 * ZOOMER / 2, + zoom * 60000 * ZOOMER / 2, zoom * 60000 * ZOOMER / 2); gl.Vertex( + zoom * 60000 * ZOOMER / 2, + zoom * 60000 * ZOOMER / 2, -zoom * 60000 * ZOOMER / 2); gl.Vertex( + zoom * 60000 * ZOOMER / 2, + zoom * 60000 * ZOOMER / 2, zoom * 60000 * ZOOMER / 2); gl.Vertex( + zoom * 60000 * ZOOMER / 2, - zoom * 60000 * ZOOMER / 2, zoom * 60000 * ZOOMER / 2); gl.Vertex( + zoom * 60000 * ZOOMER / 2, - zoom * 60000 * ZOOMER / 2, zoom * 60000 * ZOOMER / 2); gl.Vertex( + zoom * 60000 * ZOOMER / 2, - zoom * 60000 * ZOOMER / 2, -zoom * 60000 * ZOOMER / 2); gl.Vertex( + zoom * 60000 * ZOOMER / 2, - zoom * 60000 * ZOOMER / 2, zoom * 60000 * ZOOMER / 2); gl.Vertex( - zoom * 60000 * ZOOMER / 2, - zoom * 60000 * ZOOMER / 2, zoom * 60000 * ZOOMER / 2); mTex.Bind(gl); gl.Enable(OpenGL.GL_TEXTURE_2D); gl.Sphere(tex, radius * ZOOMER, 32, 32); gl.Disable(OpenGL.GL_TEXTURE_2D); if (last_index == 0) last_index = 1; //Изменеие данных на панели инструментов labelTime.Text = "Время полета: " + ((int)time_m[last_index]).ToString() + " c"; labelHeight.Text = "Высота над уровнем моря в данный момент: " + height[last_index].ToString() + " км"; if (last_index == count_render_points && rend) { but.Text = "Начать новый эксперимент"; rend = false; state = 2; } gl.PopMatrix(); if (rend) { time += tr; } }
private void openGLControl_OpenGLDraw(object sender, RenderEventArgs e) { //If animating, increment current time if (IsPlaying) { float between = 1000 / FrameRate; Scene.Model.CurrentTime += between / 1000; } Scene.Render(); }
private void openGLControl1_OpenGLDraw(object sender, SharpGL.RenderEventArgs args) { SharpGL.OpenGL gl = this.openGLControl1.OpenGL; //清除深度缓存 gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); gl.MatrixMode(OpenGL.GL_PROJECTION); //重置当前指定的矩阵为单位矩阵,将当前的用户坐标系的原点移到了屏幕中心 gl.LoadIdentity(); //显示视频画面 Monitor.Enter(MainForm._MyLock); try { if (this.buffer != IntPtr.Zero) { var xz = (float)this.openGLControl1.Width / (float)this.videoWidth; var yz = (float)this.openGLControl1.Height / (float)this.videoHeight; var xyz = 1f; xyz = Math.Min(xz, yz); if (xz < yz) { gl.RasterPos(-1f, (xyz / yz)); } else { gl.RasterPos((xyz / xz), -1f); } gl.PixelZoom(xyz, -xyz); gl.DrawPixels((int)this.videoWidth, (int)this.videoHeight, OpenGL.GL_RGB, OpenGL.GL_UNSIGNED_BYTE, this.buffer); } } catch (Exception ex) { Console.WriteLine(ex); } finally { Monitor.Exit(MainForm._MyLock); } lock (this.osdLock) { if (this.osdMessage != null) { var textData = this.osdMessage.LockBits(new Rectangle(0, 0, this.osdMessage.Width, this.osdMessage.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); //显示OSD var x = (2f / this.openGLControl1.Width) * 50f - 1f; var y = (2f / this.openGLControl1.Height) * (this.openGLControl1.Height - 50f) - 1f; gl.RasterPos(x, y); gl.PixelZoom(1, -1); gl.DrawPixels(this.osdMessage.Width, this.osdMessage.Height, OpenGL.GL_BGRA, OpenGL.GL_UNSIGNED_BYTE, textData.Scan0); this.osdMessage.UnlockBits(textData); //gl.DrawText(50, this.openGLControl1.Height - 18, 1, 1, 0, "Microsoft YaHei UI", 24, this.osdMessage); } } gl.Flush(); //强制刷新 }
private void openGLControl_OpenGLDraw(object sender, RenderEventArgs e) { _gl = openGLControl.OpenGL; _gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); _gl.LoadIdentity(); _gl.LookAt(0, 0, _w, 0, 0, 0, 0, 1, 0); //-10, 10, _w, 0, 0, 0, 0, 1, 0 _gl.Rotate((float)_rotX, (float)_rotY, (float)_rotZ); _gl.Translate(_transX, _transY, _transZ); foreach (Polygon polygon in _polygons) { if (!polygon.IsEnabled) continue; polygon.PushObjectSpace(_gl); polygon.Render(_gl, SharpGL.SceneGraph.Core.RenderMode.Render); polygon.PopObjectSpace(_gl); } }
private void openGlControl_OpenGLDraw(object sender, RenderEventArgs args) { var gl = openGlControl.OpenGL; graphicsBuffer.Clear(); GameState.Current.Render(graphicsBuffer); RenderPointer(); gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); gl.RasterPos(0, 0); gl.PixelZoom(scaleFactor, scaleFactor); gl.DrawPixels( GraphicsBuffer.GameWidth, GraphicsBuffer.GameHeight, OpenGL.GL_RGB, graphicsBuffer.Buffer); gl.Flush(); }
private void openGLControl_OpenGLDraw(object sender, RenderEventArgs e) { CursorWektor.X =-1 * ((float)Cursor.Position.X - 680) / 50; CursorWektor.Z = -1 * ((float)Cursor.Position.Y - 374) / 50; // double Angle = Math.Atan2(CursorWektor.Z, CursorWektor.X); double Angle = -45; CursorWektorAngled = rotate_wektor(0, 0, (float)Angle, CursorWektor); // CursorWektorAngled.X = CursorWektor.X * (float)Math.Sin(Angle -ConvertToRadians(90)); // CursorWektorAngled.Z = CursorWektor.Z * (float)Math.Cos(Angle -ConvertToRadians(90)); // Get the OpenGL object. OpenGL gl = openGLControl.OpenGL; rysow = new Rysownik(gl); // Clear the color and depth buffer. gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); // (x > 0 ? x : (2*PI + x)) * 360 / (2*PI) double AngleX; AngleX = CursorWektor.X; // if(CursorWektor.X<0){AngleX = (2*Math.PI + CursorWektor.X) * 360 / (2*Math.PI) ;} double AngleY; AngleY = CursorWektor.Z; // if (CursorWektor.Z < 0) { AngleY = (2 * Math.PI + CursorWektor.Z) * 360 / (2 * Math.PI); } Angle_between_wektor_X_Z(WektorZero, CursorWektor); // Load the identity matrix. gl.MatrixMode(OpenGL.GL_PROJECTION); // Load the identity. gl.LoadIdentity(); gl.Perspective(60.0f, 0, 0, 0); rysow.DrawLive(new Wektor(0.9f, -0.7f, 0), new Wektor(0.05f, 0.03f, 0f), PlayerLive); rysow.DrawLive(new Wektor(-0.9f, -0.7f, 0), new Wektor(0.05f, 0.04f, 0f), Boss.Live); // gl.DepthMask(0); // rysow.DrawCubo(0, 0, 0, 0.33f, 0.33f, 0.33f,0.0f,true,0.6f); // gl.DepthMask(1); gl.Enable(SharpGL.OpenGL.GL_SMOOTH); gl.Enable(SharpGL.OpenGL.GL_FLAT); // gl.Enable(SharpGL.OpenGL.GL_LINE_SMOOTH); // Create a perspective transformation. gl.Perspective(60.0f, (double)Width / (double)Height, 0.01, 100.0); // Use the 'look at' helper function to position and aim the camera. gl.LookAt(cuboPlayer.polozenie.X - 5, YAxisCamera, cuboPlayer.polozenie.Z - 5, cuboPlayer.polozenie.X, cuboPlayer.polozenie.Y, cuboPlayer.polozenie.Z, 0, 1, 0); // Rotate around the Y axis. float samesize= 2.3f; // =new Wektor(1.0, 1.0, 1.0); //Wektor re(1.0,1.0,1.0); for (int i = 0; i < listaPociskow.Count; i++) // Loop with for. { rysow.DrawCubo(listaPociskow[i].polozenie.X, listaPociskow[i].polozenie.Y, listaPociskow[i].polozenie.Z, listaPociskow[i].grubosci.X, listaPociskow[i].grubosci.Y, listaPociskow[i].grubosci.Z, (float)listaPociskow[i].angle + rotation, true,1.0f); } // list for (int i = 0; i < listaPociskowPlayera.Count; i++) // Loop with for. { rysow.DrawCubo(listaPociskowPlayera[i].polozenie.X, listaPociskowPlayera[i].polozenie.Y, listaPociskowPlayera[i].polozenie.Z, listaPociskowPlayera[i].grubosci.X, listaPociskowPlayera[i].grubosci.Y, listaPociskowPlayera[i].grubosci.Z, (float)listaPociskowPlayera[i].angle + rotation, true, 1.0f); } rysow.DrawCubo(Boss.polozenie.X, Boss.polozenie.Y, Boss.polozenie.Z, Boss.grubosci.X, Boss.grubosci.Y, Boss.grubosci.Z, 20,2); rysow.draw_floor(); cuboPlayer.angle = -1f * Angle_between_wektor_X_Z(cuboPlayer.polozenie, CursorWektor); rysow.DrawPlayer(cuboPlayer.polozenie, cuboPlayer.grubosci, cuboPlayer.angle); gl.Enable(SharpGL.OpenGL.GL_BLEND); gl.BlendFunc(SharpGL.OpenGL.GL_SRC_ALPHA,SharpGL.OpenGL.GL_ONE_MINUS_SRC_ALPHA); // glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); rysow.DrawCubo_with_alpha(CursorWektor.X, CursorWektor.Y, CursorWektor.Z, cuboPlayer.grubosci.X, cuboPlayer.grubosci.Y, cuboPlayer.grubosci.Z, rotation * 2,0.3f); rysow.DrawCubo_with_alpha(CursorWektorAngled.X,CursorWektorAngled.Y,CursorWektorAngled.Z, cuboPlayer.grubosci.X, cuboPlayer.grubosci.Y*3, cuboPlayer.grubosci.Z, (float)(1.5 * -1) * rotation ,0.3f); //player config int hour_0_to_7; hour_0_to_7 = 900000; if (KeyW && !KeyA && !KeyD && !KeyS) { hour_0_to_7 = -1; } if (!KeyW && !KeyA && !KeyD && KeyS) { hour_0_to_7 = 4; } if (!KeyW && KeyA && !KeyD && !KeyS) { hour_0_to_7 = 6; } if (!KeyW && !KeyA && KeyD && !KeyS) { hour_0_to_7 = 2; } if (KeyA && KeyS && !KeyW) { hour_0_to_7 = 5; } if (KeyS && KeyD && !KeyW) { hour_0_to_7 = 3; } if (KeyD && KeyW) { hour_0_to_7 = 1; } if (KeyW && KeyA) { hour_0_to_7 = 7; } Wektor temp; temp = new Wektor(0.0f, 0.0f, 0.2f); if (Math.Abs(cuboPlayer.predkosc.X) < 0.2f && Math.Abs(cuboPlayer.predkosc.Z) < 0.2f) { switch (hour_0_to_7) { case -1: cuboPlayer.predkosc = RotateWektorOnZero(temp, 315); break; case 1: cuboPlayer.predkosc = temp; // cuboPlayer.predkosc.Z += 0.21f; Debug.WriteLine(RotateWektorOnZero(temp, 45).X + " " + RotateWektorOnZero(temp, 45).Z); break; case 2: cuboPlayer.predkosc = RotateWektorOnZero(temp, 45); //cuboPlayer.predkosc.Z += RotateWektorOnZero(temp, 90).Z; Debug.WriteLine(RotateWektorOnZero(temp, 90).X + " " + RotateWektorOnZero(temp, 90).Z); break; case 3: cuboPlayer.predkosc = RotateWektorOnZero(temp, 90); break; case 4: cuboPlayer.predkosc = RotateWektorOnZero(temp, 135); break; case 5: cuboPlayer.predkosc = RotateWektorOnZero(temp, 180); break; case 6: cuboPlayer.predkosc = RotateWektorOnZero(temp, 225); break; case 7: cuboPlayer.predkosc = RotateWektorOnZero(temp, 270); break; // default: // cuboPlayer.wycisz_predkosc_only_XZ_o(0.1f); } } cuboPlayer.wycisz_predkosc_only_XZ_o(0.01f); cuboPlayer.krok_naprzod(); if (bulletOne != null) { bulletOne.krok_naprzod(); } Boss.krok_naprzod(); // foreach (KwadratMaterialnyPocisk prime in listaPociskow) // Loop through List with foreach. // { // prime.krok_naprzod(); // } for (int i = 0; i < listaPociskow.Count; i++) // Loop with for. { if (listaPociskow[i].vitality < 1) { listaPociskow.RemoveAt(i); } else { listaPociskow[i].krok_naprzod(); } } //foreach (KwadratMaterialnyPocisk prime in listaPociskowPlayera) // Loop through List with foreach. //{ // if (prime.vitality < 3) // { // listaPociskowPlayera.Remove(prime); // } // else // { // prime.krok_naprzod(); // } //} for (int i = 0; i < listaPociskowPlayera.Count; i++) // Loop with for. { if(czy_nachodza(listaPociskowPlayera[i].polozenie,Boss.polozenie,Boss.grubosci.X)) { Boss.Live--; Debug.WriteLine("nachodza"); } if (listaPociskowPlayera[i].vitality < 3) { listaPociskowPlayera.RemoveAt(i); } else { listaPociskowPlayera[i].krok_naprzod(); } } if(Boss.counter%250 == 0) { listaPociskow = new List<KwadratMaterialnyPocisk>(); for (int i = 0; i < 13; i++) { listaPociskow.Add(new KwadratMaterialnyPocisk(Boss.polozenie, losowyWektorPredkosci(), 20)); } } // cuboOne.daj_kat_kwadrata(); // Nudge the rotation. rotation += 3.0f; Wektor inc; inc = new Wektor(0.01f, 0.0f, 0.0f); da += inc; re= re * 1.01f; if (bulletOne != null) { if (bulletOne.vitality < 0) { bulletOne = null; } } }