/// <summary> /// The render. /// </summary> /// <param name="model"> /// The model. /// </param> /// <param name="flags"> /// The flags. /// </param> /// <returns> /// The render. /// </returns> public override uint Render(CIwModel model, uint flags) { try { CIwMaterial material = model.GetMaterial(this.materialId); if (material != null) { material.Enable(); } S3E.CheckOpenGLStatus(); GL.Begin(BeginMode.Triangles); base.Render(model, flags); GL.End(); if (material != null) { material.Disable(); } S3E.CheckOpenGLStatus(); } catch (Exception ex) { throw; } return(0); }
/// <summary> /// The render. /// </summary> /// <param name="model"> /// The model. /// </param> /// <param name="flags"> /// The flags. /// </param> /// <returns> /// The render. /// </returns> public override uint Render(CIwModel model, uint flags) { CIwMaterial material = model.GetMaterial(this.m_MaterialID); if (material != null) { material.Enable(); } S3E.CheckOpenGLStatus(); GL.Begin(BeginMode.Triangles); var verts = model.ResolveBlock <CIwModelBlockVerts>(); var colors = model.ResolveBlock <CIwModelBlockCols>(); var normals = model.ResolveBlock <CIwModelBlockNorms>(); var indGroups = model.ResolveBlock <CIwModelBlockIndGroups>(); if (verts != null) { foreach (var iwModelPrim in this.prims) { iwModelPrim.Render(model, flags, verts, indGroups, colors); } } GL.End(); if (material != null) { material.Disable(); } S3E.CheckOpenGLStatus(); return(0); }
private void RenderGameScreen(object sender, PaintEventArgs e) { if (!this.isLoaded) { return; } GL.ClearColor(Color.SkyBlue); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); int w = this.glControl.Width; int h = this.glControl.Height; GL.MatrixMode(MatrixMode.Projection); GL.LoadIdentity(); int hh = 2000 * h / w; GL.Ortho(-2000, 2000, -hh, hh, -2000, 2000); // Верхний левый угол имеет кооординаты(0, 0) GL.Viewport(0, 0, w, h); // Использовать всю поверхность GLControl под рисование S3E.CheckOpenGLStatus(); GL.Enable(EnableCap.DepthTest); GL.MatrixMode(MatrixMode.Modelview); GL.LoadIdentity(); this.angle += (float)Math.PI / 200; Matrix4 m = Matrix4.CreateRotationY(this.angle); GL.LoadMatrix(ref m); S3E.CheckOpenGLStatus(); if (this.@group != null) { var models = [email protected]("CIwModel"); if (models != null) { for (int i = 0; i < models.Size; ++i) { ((CIwModel)models[i]).Render(); // break; } } } ////GL.Color3(Color.Yellow); ////GL.Begin(BeginMode.Triangles); ////GL.Vertex2(10, 20); ////GL.Vertex2(100, 20); ////GL.Vertex2(100, 50); ////GL.End(); // S3E.CheckOpenGLStatus(); this.glControl.SwapBuffers(); }
/// <summary> /// The upload. /// </summary> public void Upload() { GL.TexImage2D( TextureTarget.Texture2D, 0, PixelInternalFormat.Rgb, this.Width, this.Height, 0, PixelFormat.Rgb, PixelType.UnsignedByte, this.Pixels); S3E.CheckOpenGLStatus(); }
private void Parse() { for (;;) { var s = this.ReadString(); if (s == null) { break; } if (s == "include") { var fileName = this.ReadString(); continue; } if (s == "}") { this.GetObject(0).ParseClose(this); this.PopObject(); continue; } if (this.parseStack.Count > 0) { if (this.GetObject(0).ParseAttribute(this, s)) { continue; } } if (this.PeekString() == "{") { this.ReadString(); IwClassFactory iwClassFactory = this.classRegistry.Get(S3E.HashString(s)); if (iwClassFactory == null) { throw new Exception(string.Format("Can't find class {0}", s)); } this.PushObject(iwClassFactory.Create()); this.GetObject(0).ParseOpen(this); } else { throw new Exception(string.Format("{0} is not an attribute in {1}", s, this.GetObject(0).GetType().Name)); } } }
/// <summary> /// The enable. /// </summary> /// <param name="index"> /// The index. /// </param> public void Enable(int index) { GL.ActiveTexture(TextureUnit.Texture0 + index); GL.Enable(EnableCap.Texture2D); S3E.CheckOpenGLStatus(); GL.BindTexture(TextureTarget.Texture2D, this.GlTexture); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureWrapMode.Repeat); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.Repeat); S3E.CheckOpenGLStatus(); // GL.Enable(EnableCap.Blend); }
/// <summary> /// The render. /// </summary> /// <param name="model"> /// The model. /// </param> /// <param name="flags"> /// The flags. /// </param> /// <returns> /// The render. /// </returns> public override uint Render(CIwModel model, uint flags) { CIwMaterial material = model.GetMaterial(this.materialId); if (material != null) { material.Enable(); } GL.Begin(BeginMode.TriangleStrip); base.Render(model, flags); GL.End(); S3E.CheckOpenGLStatus(); if (material != null) { material.Disable(); } return(0); }
/// <summary> /// The hash string. /// </summary> /// <param name="name"> /// The name. /// </param> /// <returns> /// The hash string. /// </returns> public static uint HashString(string name) { return(S3E.HashString(name)); }
/// <summary> /// Case insensetive hash. /// </summary> /// <param name="s"> /// String to calculate hash for. /// </param> /// <returns> /// Calculated hash. /// </returns> public static uint ToeHash(this string s) { return(S3E.HashString(s)); }
/// <summary> /// The read string hash. /// </summary> /// <returns> /// The read string hash. /// </returns> public uint ReadStringHash() { return(S3E.HashString(this.ReadString())); }
private void Upload() { GL.BindTexture(TextureTarget.Texture2D, this.glTexture); S3E.CheckOpenGLStatus(); this.image.Upload(); }