public void Draw() { if (output is null) { return; } OpenGL gl = output.OpenGL; gl.ClearColor(bgColor.R / 255.0f, bgColor.G / 255.0f, bgColor.B / 255.0f, 1.0f); gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); gl.LineWidth(size); gl.PointSize(size); if (displayMode == DisplayMode.Fill) { gl.PolygonMode(FaceMode.FrontAndBack, PolygonMode.Filled); } else if (displayMode == DisplayMode.Lines) { gl.PolygonMode(FaceMode.FrontAndBack, PolygonMode.Lines); } else { gl.PolygonMode(FaceMode.FrontAndBack, PolygonMode.Points); } gl.CallList(OpenGL.GL_LIST_BASE + 1); gl.Flush(); }
public override void Draw(OpenGL gl) { gl.PushAttrib(AttributeMask.All); gl.PushMatrix(); gl.CallList(ListInd); gl.PopMatrix(); gl.PopAttrib(); }
public override void Draw(OpenGL gl) { gl.PushAttrib(AttributeMask.All); gl.PushMatrix(); gl.Translate(position.x, position.y, position.z); gl.CallList(ListInd); gl.PopMatrix(); gl.PopAttrib(); }
public void Render(OpenGL gl, Vector3 position, Vector3 rotation) { if (_axisDrawListId == uint.MinValue) { CreateDrawList(gl); } gl.Color(255, 255, 255); gl.MatrixMode(MatrixMode.Modelview); gl.PushMatrix(); gl.Translate(position.X, position.Z, position.Y); gl.Rotate(rotation.X, 1, 0, 0); gl.Rotate(rotation.Y, 0, 1, 0); gl.Rotate(rotation.Z, 0, 0, 1); gl.CallList(_axisDrawListId); gl.Rotate(90, 1, 0, 0); gl.CallList(_axisDrawListId); gl.Rotate(-90, 0, 0, 1); gl.CallList(_axisDrawListId); gl.PopMatrix(); }
public override void Draw(OpenGL gl) { gl.PushAttrib(SharpGL.Enumerations.AttributeMask.All); gl.PushMatrix(); //gl.Translate(position.x, position.y, position.z); //DrawFigures(gl, boardSize, colorWhite, colorBlack, textureWhite, textureBlack); gl.CallList(ListInd); gl.PopMatrix(); gl.PopAttrib(); }
//{------------------------------------------------------------------} //{ Draw the entire tentacle object //{------------------------------------------------------------------} private void DrawObject(float DemoTime, OpenGL gl) { gl.Color(1.0, 1.0, 1.0); colorsTex.Bind(gl); //Draw the first cube gl.CallList(CubeDL); gl.Scale(0.9, 0.9, 0.9); float angle = (float)(25 * Math.Sin(DemoTime / 600)); float twistangle = (float)(25 * Math.Sin(DemoTime / 800)); gl.PushMatrix(); DrawTentacle(0, angle, twistangle, gl); gl.PopMatrix(); angle = (float)(25 * Math.Cos(DemoTime / 500)); twistangle = (float)(25 * Math.Sin(DemoTime / 800)); gl.Rotate(90, 0, 1, 0); gl.PushMatrix(); DrawTentacle(0, angle, -twistangle, gl); gl.PopMatrix(); angle = (float)(25 * Math.Sin(DemoTime / 500)); twistangle = (float)(25 * Math.Cos(DemoTime / 600)); gl.Rotate(90, 0, 1, 0); gl.PushMatrix(); DrawTentacle(0, angle, twistangle, gl); gl.PopMatrix(); angle = (float)(25 * Math.Sin(DemoTime / 600)); twistangle = (float)(25 * Math.Sin(DemoTime / 400)); gl.Rotate(90, 0, 1, 0); gl.PushMatrix(); DrawTentacle(0, angle, -twistangle, gl); gl.PopMatrix(); angle = (float)(25 * Math.Sin(DemoTime / 600)); twistangle = (float)(25 * Math.Cos(DemoTime / 400)); gl.Rotate(90, 0, 0, 1); gl.PushMatrix(); DrawTentacle(0, angle, twistangle, gl); gl.PopMatrix(); angle = (float)(25 * Math.Sin(DemoTime / 400)); twistangle = (float)(25 * Math.Cos(DemoTime / 800)); gl.Rotate(180, 0, 0, 1); gl.PushMatrix(); DrawTentacle(0, -angle, -twistangle, gl); gl.PopMatrix(); }
//{------------------------------------------------------------------} //{ Draw a tentacle //{------------------------------------------------------------------} private void DrawTentacle(int Step, float angle, float twistangle, OpenGL gl) { if (Step == 19) { return; } // Translate along the x-axis gl.Translate(2.25, 0, 0); gl.Rotate(angle, 0, 1, 0); gl.Rotate(twistangle, 1, 0, 0); gl.CallList(CubeDL); gl.Scale(0.9, 0.9, 0.9); DrawTentacle(Step + 1, angle, twistangle, gl); }
public override void Draw(OpenGL gl) { gl.PushAttrib(AttributeMask.All); gl.PushMatrix(); gl.Translate(position.x, position.y, position.z); gl.Scale(scale, scale, scale); if (texture != null) { gl.Enable(OpenGL.GL_TEXTURE_2D); texture.Bind(gl); } gl.CallList(ListInd); gl.PopMatrix(); gl.PopAttrib(); }
/// <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(); Angle = (elapsedMillisecs / 300); int ElapsedTime = elapsedMillisecs; gl.Color(1.0, 1.0, 1.0); gl.Translate(0.0, 0.0, -14); gl.Rotate(ElapsedTime / 20, 1, 0, 0); gl.CallList(TorusDL); endTime = DateTime.Now; elapsedMillisecs = (int)((TimeSpan)(endTime - startTime)).TotalMilliseconds; LastTime = elapsedMillisecs; }
/// <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) { angle += 0.4f; // Get the OpenGL object. OpenGL gl = openGLControl.OpenGL; // Clear The Screen And The Depth Buffer gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); // Reset The View gl.LoadIdentity(); gl.PushMatrix(); gl.Translate(0.0, 2.0, -35); gl.BindTexture(OpenGL.GL_TEXTURE_2D, TexEarth.TextureName); gl.Color(1.0, 1.0, 1.0); gl.Rotate(angle, 0.0, 1.0, 0.0); gl.CallList(SphereDL); gl.PopMatrix(); gl.LoadIdentity(); // Draw Rotating Galaxy gl.PushMatrix(); gl.Translate(0.0, 0.0, -30); gl.Scale(4.0, 4.0, 4.0); // Bind the Texture to the object gl.BindTexture(OpenGL.GL_TEXTURE_2D, texBackground.TextureName); gl.Rotate(elapsedTime / 100, 0, 0, 1); gl.Color(1.0, 1.0, 1.0); gl.Begin(OpenGL.GL_QUADS); gl.TexCoord(0.0, 0.0); gl.Vertex(-7.6, -7.6, 0); gl.TexCoord(1.0, 0.0); gl.Vertex(7.6, -7.6, 0); gl.TexCoord(1.0, 1.0); gl.Vertex(7.6, 7.6, 0); gl.TexCoord(0.0, 1.0); gl.Vertex(-7.6, 7.6, 0); gl.End(); gl.PopMatrix(); // Draw Text Strings gl.PushMatrix(); gl.Translate(0.0, 0 + g_TextScroller, -3); // Bind the Texture to the object gl.BindTexture(OpenGL.GL_TEXTURE_2D, texFont.TextureName); // Line One glImgWrite("this is some test text."); // Line Two gl.Translate(0.0, -0.1, 0.0); glImgWrite("here we have a second line of text."); // Rolling Text gl.Translate(0.0, -0.5, 0.0); gl.Rotate(-(elapsedTime / 10), 1, 0, 0); glImgWrite("lets see of this text can rotate."); xAngle = xAngle + xSpeed; yAngle = yAngle + ySpeed; zAngle = zAngle + zSpeed; gl.PopMatrix(); gl.PushMatrix(); gl.Translate(2 - g_TextScroller2, -0.35, -1.03); gl.Rotate(-(elapsedTime / 10), 1, 0, 0); glImgWrite("test horizontal.........www.sulaco.co.za"); gl.PopMatrix(); gl.PushMatrix(); gl.Translate(-0.60, 0.6, -1.9); gl.Rotate(-(elapsedTime / 10), 1, 0, 0); glImgWrite("FPS : ");// + FPSCountTxt); gl.PopMatrix(); // Text Scrolling from the top, downwards g_TextScroller = g_TextScroller + 0.008f; g_TextScroller2 = g_TextScroller2 + xScrollSpeed; if (g_TextScroller > 1.5) { g_TextScroller = -1.5f; } if (g_TextScroller2 > 5.5) { g_TextScroller2 = -1.5f; } gl.PushMatrix(); gl.Translate(0.0, 2.0 - g_TextScroller, -4.1); glImgWrite("text scrolling from the top."); gl.PopMatrix(); // Growing Text gl.PushMatrix(); //gl.Translate(0.0,0.0,8.0 * g_TextScroller); gl.Translate(0.0, 2.8 * -g_TextScroller, 8 * g_TextScroller); glImgWrite("www.opengl..org"); gl.PopMatrix(); gl.LoadIdentity(); gl.PushMatrix(); gl.Translate(-2, -0.5, -7); //{ For movement that requires a constant speed on all machines use ... } //gl.Rotate(ElapsedTime/20, 1, 0, 0); //gl.Rotate(ElapsedTime/30, 0, 1, 0); gl.Rotate(xAngle, 1, 0, 0); gl.Rotate(yAngle, 0, 1, 0); gl.Rotate(zAngle, 0, 0, 1); //Left Cube gl.BindTexture(OpenGL.GL_TEXTURE_2D, TexCube.TextureName); // Bind the Texture to the object gl.Begin(OpenGL.GL_QUADS); // Front Face gl.Normal(0.0, 0.0, 1.0); gl.TexCoord(0.0, 0.0); gl.Vertex(-1.0, -1.0, 1.0); gl.TexCoord(1.0, 0.0); gl.Vertex(1.0, -1.0, 1.0); gl.TexCoord(1.0, 1.0); gl.Vertex(1.0, 1.0, 1.0); gl.TexCoord(0.0, 1.0); gl.Vertex(-1.0, 1.0, 1.0); // Back Face gl.Normal(0.0, 0.0, -1.0); gl.TexCoord(1.0, 0.0); gl.Vertex(-1.0, -1.0, -1.0); gl.TexCoord(1.0, 1.0); gl.Vertex(-1.0, 1.0, -1.0); gl.TexCoord(0.0, 1.0); gl.Vertex(1.0, 1.0, -1.0); gl.TexCoord(0.0, 0.0); gl.Vertex(1.0, -1.0, -1.0); // Top Face gl.Normal(0.0, 1.0, 0.0); gl.TexCoord(0.0, 1.0); gl.Vertex(-1.0, 1.0, -1.0); gl.TexCoord(0.0, 0.0); gl.Vertex(-1.0, 1.0, 1.0); gl.TexCoord(1.0, 0.0); gl.Vertex(1.0, 1.0, 1.0); gl.TexCoord(1.0, 1.0); gl.Vertex(1.0, 1.0, -1.0); // Bottom Face gl.Normal(0.0, -1.0, 0.0); gl.TexCoord(1.0, 1.0); gl.Vertex(-1.0, -1.0, -1.0); gl.TexCoord(0.0, 1.0); gl.Vertex(1.0, -1.0, -1.0); gl.TexCoord(0.0, 0.0); gl.Vertex(1.0, -1.0, 1.0); gl.TexCoord(1.0, 0.0); gl.Vertex(-1.0, -1.0, 1.0); // Right face gl.Normal(1.0, 0.0, 0.0); gl.TexCoord(1.0, 0.0); gl.Vertex(1.0, -1.0, -1.0); gl.TexCoord(1.0, 1.0); gl.Vertex(1.0, 1.0, -1.0); gl.TexCoord(0.0, 1.0); gl.Vertex(1.0, 1.0, 1.0); gl.TexCoord(0.0, 0.0); gl.Vertex(1.0, -1.0, 1.0); // Left Face gl.Normal(-1.0, 0.0, 0.0); gl.TexCoord(0.0, 0.0); gl.Vertex(-1.0, -1.0, -1.0); gl.TexCoord(1.0, 0.0); gl.Vertex(-1.0, -1.0, 1.0); gl.TexCoord(1.0, 1.0); gl.Vertex(-1.0, 1.0, 1.0); gl.TexCoord(0.0, 1.0); gl.Vertex(-1.0, 1.0, -1.0); gl.End(); gl.PopMatrix(); gl.LoadIdentity(); gl.Disable(OpenGL.GL_TEXTURE_2D); gl.PushMatrix(); //Sauvegarde la matrice active gl.Scale(0.4, 0.4, 0.4); //Redimensionne l'objet gl.Translate(5, -1, g_Zcube); //Translation (x,y,z) gl.Rotate(-angle, 0, 1, 0); gl.Rotate(-angle, 1, 0, 0); gl.Rotate(-angle, 0, 0, 1); gl.Begin(OpenGL.GL_QUADS); //1 ère face\\ gl.Color(1.0f, 0.0f, 0.0f); gl.Vertex(2, 2, 2); //1p gl.Color(0.0f, 1.0f, 0.0f); gl.Vertex(2, -2, 2); //2p gl.Color(1.0f, 0.0f, 0.0f); gl.Vertex(-2, -2, 2); //3p gl.Color(0.0f, 0.0f, 1.0f); gl.Vertex(-2, 2, 2); //4p //2 ème face\\ gl.Color(0.0f, 1.0f, 0.0f); gl.Vertex(2, 2, -2); //1p gl.Color(0.0f, 1.0f, 0.0f); gl.Vertex(2, -2, -2); //2p gl.Color(0.0f, 1.0f, 0.0f); gl.Vertex(-2, -2, -2); //3p gl.Color(0.0f, 1.0f, 0.0f); gl.Vertex(-2, 2, -2); //4p //3 ème face\\ gl.Color(1.0f, 0.0f, 0.0f); gl.Vertex(2, 2, 2); //1p gl.Color(0.0f, 0.0f, 1.0f); gl.Vertex(2, -2, 2); //2p gl.Color(0.0f, 1.0f, 0.0f); gl.Vertex(2, -2, -2); //3p gl.Color(1.0f, 1.0f, 0.0f); gl.Vertex(2, 2, -2); //4p //4 ème face\\ gl.Color(1.0f, 1.0f, 0.0f); gl.Vertex(-2, 2, 2); //1p gl.Color(0.0f, 1.0f, 0.0f); gl.Vertex(-2, -2, 2); //2p gl.Color(0.0f, 0.0f, 1.0f); gl.Vertex(-2, -2, -2); //3p gl.Color(1.0f, 0.0f, 0.0f); gl.Vertex(-2, 2, -2); //4p //5 ème face\\ gl.Color(0.0f, 1.0f, 0.0f); gl.Vertex(-2, 2, -2); //1p gl.Color(1.0f, 1.0f, 0.0f); gl.Vertex(-2, 2, 2); //2p gl.Color(1.0f, 0.0f, 0.0f); gl.Vertex(2, 2, 2); //3p gl.Color(0.0f, 0.0f, 1.0f); gl.Vertex(2, 2, -2); //4p //6 ème face\\ gl.Color(1.0f, 1.0f, 0.0f); gl.Vertex(-2, -2, -2); //1p gl.Color(0.0f, 1.0f, 0.0f); gl.Vertex(-2, -2, 2); //2p gl.Color(0.0f, 0.0f, 1.0f); gl.Vertex(2, -2, 2); //3p gl.Color(1.0f, 0.0f, 0.0f); gl.Vertex(2, -2, -2); //4p gl.End(); //Finis de dessiner le carré gl.PopMatrix(); //Recupérer la matrice précédemment sauvegarder gl.Enable(OpenGL.GL_TEXTURE_2D); gl.Flush(); LastTime = elapsedTime; endTime = DateTime.Now; elapsedTime = (float)((TimeSpan)(endTime - startTime)).TotalMilliseconds; }
public virtual void Call(OpenGL gl) { gl.CallList(list); }