From 3198f3419dbf49e3579009db6b45d07fc024acf0 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Tue, 16 Feb 2010 08:35:34 +1300 Subject: [PATCH] wtf, still doesnt work. probably i'm misunderstanding how to use VBOs --- OpenRa.Gl/GraphicsDevice.cs | 23 +++++++++++++++++++---- chrome-rgba.fx | 6 ++++-- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/OpenRa.Gl/GraphicsDevice.cs b/OpenRa.Gl/GraphicsDevice.cs index 031f431fc9..4f71653832 100644 --- a/OpenRa.Gl/GraphicsDevice.cs +++ b/OpenRa.Gl/GraphicsDevice.cs @@ -56,6 +56,11 @@ namespace OpenRa.GlRenderer CgGl.cgGLSetManageTextureParameters(cgContext, true); vertexProfile = CgGl.cgGLGetLatestProfile(CgGl.CG_GL_VERTEX); fragmentProfile = CgGl.cgGLGetLatestProfile(CgGl.CG_GL_FRAGMENT); + + Gl.glEnableClientState(Gl.GL_VERTEX_ARRAY); + CheckGlError(); + Gl.glEnableClientState(Gl.GL_INDEX_ARRAY); + CheckGlError(); } void CgErrorCallback() @@ -97,13 +102,23 @@ namespace OpenRa.GlRenderer CheckGlError(); } - public void DrawIndexedPrimitives(PrimitiveType pt, Range vertices, Range indices) { } - public void DrawIndexedPrimitives(PrimitiveType pt, int numVerts, int numPrimitives) { } + public void DrawIndexedPrimitives(PrimitiveType pt, Range vertices, Range indices) + { + Gl.glDrawElements((int)pt, indices.End - indices.Start, Gl.GL_UNSIGNED_SHORT, new IntPtr( indices.Start )); + CheckGlError(); + } + + public void DrawIndexedPrimitives(PrimitiveType pt, int numVerts, int numPrimitives) + { + Gl.glDrawElements((int)pt, numPrimitives, Gl.GL_UNSIGNED_SHORT, IntPtr.Zero); + CheckGlError(); + } } public struct Range { - public Range(T start, T end) { } + public readonly T Start, End; + public Range(T start, T end) { Start = start; End = end; } } public class VertexBuffer where T : struct @@ -241,7 +256,7 @@ namespace OpenRa.GlRenderer public void SetValue(string name, Texture texture) { var param = Cg.cgGetNamedEffectParameter(effect, name); - CgGl.cgGLSetTextureParameter(param, texture.texture); + CgGl.cgGLSetupSampler(param, texture.texture); } public void SetValue(string name, float x, float y) diff --git a/chrome-rgba.fx b/chrome-rgba.fx index 9fc0532280..c3549974bd 100644 --- a/chrome-rgba.fx +++ b/chrome-rgba.fx @@ -32,14 +32,16 @@ VertexOut Simple_vp(VertexIn v) { } float4 Simple_fp(FragmentIn f) : COLOR0 { - float4 r = tex2D(DiffuseTexture, f.Tex0); - return r; + return float4( 1,0,0,1 ); +// float4 r = tex2D(DiffuseTexture, f.Tex0); +// return r; } technique high_quality { pass p0 { BlendEnable = true; DepthTestEnable = false; +// CullFace = NONE; // CullMode = None; // FillMode = Solid; VertexProgram = compile arbvp1 Simple_vp();