Пример #1
0
        public Shader(GraphicsDevice dev, Stream s)
        {
            this.dev = dev;
            string code;
            using (var file = new StreamReader(s))
                code = file.ReadToEnd();
            effect = Cg.cgCreateEffect(dev.cgContext, code, null);

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

            technique = Cg.cgGetFirstTechnique(effect);
            if (technique == IntPtr.Zero)
                throw new InvalidOperationException("No techniques");
            while (Cg.cgValidateTechnique(technique) == 0)
            {
                technique = 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
 public IndexBuffer(GraphicsDevice dev, int size)
 {
     Gl.glGenBuffers(1, out buffer);
     GraphicsDevice.CheckGlError();
 }
Пример #4
0
 public Texture(GraphicsDevice dev, Bitmap bitmap)
 {
     Gl.glGenTextures(1, out texture);
     GraphicsDevice.CheckGlError();
     SetData(bitmap);
 }
Пример #5
0
 public Texture(GraphicsDevice dev)
 {
     Gl.glGenTextures(1, out texture);
     GraphicsDevice.CheckGlError();
 }