예제 #1
0
        private bool DrawToTexture(ShaderController shader, int textureId)
        {
            //GL.BindTexture(TextureTarget.Texture2D, oldTextureId);
            DrawQuad(1f, 1f, 1f, 1f);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
            GL.Enable(EnableCap.Blend);

            shader.Begin();

            GL.ActiveTexture(TextureUnit.Texture0);
            GL.BindTexture(TextureTarget.Texture2D, headTextureId);
            shader.UpdateUniform("u_Texture", 0);

            GL.ActiveTexture(TextureUnit.Texture1);
            GL.BindTexture(TextureTarget.Texture2D, textureId);
            shader.UpdateUniform("u_BaseTexture", 1);

            shader.UpdateUniform("u_BlendDirectionX", HeadMesh.HeadAngle >= 0 ? 1.0f : -1.0f);

            HeadMesh.DrawToTexture(textureId);

            shader.End();
            GL.Disable(EnableCap.Blend);
            return(true);
        }
예제 #2
0
        public void Render()
        {
            if (!loaded)  // whlie context not create
            {
                return;
            }
            GL.ClearColor(Color.White);

            // Clear the render canvas with the current color
            GL.Clear(
                ClearBufferMask.ColorBufferBit |
                ClearBufferMask.DepthBufferBit);

            camera.PutCamera();

            GL.PushMatrix();
            GL.Enable(EnableCap.Texture2D);
            GL.Hint(HintTarget.PerspectiveCorrectionHint, HintMode.Nicest);
            GL.Enable(EnableCap.DepthTest);
            GL.Enable(EnableCap.Normalize);
            GL.Disable(EnableCap.CullFace);

            idleShader.Begin();
            DrawHead();
            idleShader.End();

            if (drawSpheres)
            {
                HeadPoints.DrawSpheres();
            }

            GL.PopMatrix();
            GL.Disable(EnableCap.Texture2D);
            GL.Disable(EnableCap.DepthTest);

            if (drawRotation)
            {
                DrawMeshRotation();
            }

            if (drawAxis)
            {
                DrawAxis();
            }

            if (drawDots)
            {
                HeadPoints.DrawDots();
            }

            if (drawPoints)
            {
                ProjectedPoints.Draw();
            }

            if (drawPointTriangles)
            {
                DrawPointTriangles(additionalMorphing.Type);
            }

            if (drawConvex)
            {
                DrawConvex();
            }


            //DrawShapeLine();

            if (drawTriangles)
            {
                headMorphing.Draw(useProfileTriangles);
                EnableTransparent();
                headMorphing.DrawTriangles(useProfileTriangles);
                DisableTransparent();
            }

            glControl.SwapBuffers();
        }