예제 #1
1
        public Shader(GraphicsDevice dev, string name)
        {
            this.dev = dev;
            string code;
            using (var file = new StreamReader(FileSystem.Open("cg{0}{1}.fx".F(Path.DirectorySeparatorChar, name))))
                code = file.ReadToEnd();
            effect = Tao.Cg.Cg.cgCreateEffect(dev.Context, code, null);

            if (effect == IntPtr.Zero)
            {
                var err = Tao.Cg.Cg.cgGetErrorString(Tao.Cg.Cg.cgGetError());
                var results = Tao.Cg.Cg.cgGetLastListing(dev.Context);
                throw new InvalidOperationException(
                    "Cg compile failed ({0}):\n{1}".F(err, results));
            }

            technique = Tao.Cg.Cg.cgGetFirstTechnique(effect);
            if (technique == IntPtr.Zero)
                throw new InvalidOperationException("No techniques");
            while (Tao.Cg.Cg.cgValidateTechnique(technique) == 0)
            {
                technique = Tao.Cg.Cg.cgGetNextTechnique(technique);
                if (technique == IntPtr.Zero)
                    throw new InvalidOperationException("No valid techniques");
            }
        }
예제 #2
0
 public IndexBuffer(GraphicsDevice dev, int size)
 {
     Gl.glGenBuffers(1, out buffer);
     GraphicsDevice.CheckGlError();
     Bind();
     Gl.glBufferData(Gl.GL_ELEMENT_ARRAY_BUFFER,
         new IntPtr(2 * size),
         new ushort[ size ],
         Gl.GL_DYNAMIC_DRAW);
     GraphicsDevice.CheckGlError();
 }
예제 #3
0
파일: Texture.cs 프로젝트: patthoyts/OpenRA
 public Texture(GraphicsDevice dev, Bitmap bitmap)
 {
     Gl.glGenTextures(1, out texture);
     GraphicsDevice.CheckGlError();
     SetData(bitmap);
 }
예제 #4
0
파일: Texture.cs 프로젝트: patthoyts/OpenRA
 public Texture(GraphicsDevice dev)
 {
     Gl.glGenTextures(1, out texture);
     GraphicsDevice.CheckGlError();
 }