wtf, still doesnt work. probably i'm misunderstanding how to use VBOs

This commit is contained in:
Chris Forbes
2010-02-16 08:35:34 +13:00
parent 09ee4ee50d
commit 3198f3419d
2 changed files with 23 additions and 6 deletions

View File

@@ -56,6 +56,11 @@ namespace OpenRa.GlRenderer
CgGl.cgGLSetManageTextureParameters(cgContext, true); CgGl.cgGLSetManageTextureParameters(cgContext, true);
vertexProfile = CgGl.cgGLGetLatestProfile(CgGl.CG_GL_VERTEX); vertexProfile = CgGl.cgGLGetLatestProfile(CgGl.CG_GL_VERTEX);
fragmentProfile = CgGl.cgGLGetLatestProfile(CgGl.CG_GL_FRAGMENT); fragmentProfile = CgGl.cgGLGetLatestProfile(CgGl.CG_GL_FRAGMENT);
Gl.glEnableClientState(Gl.GL_VERTEX_ARRAY);
CheckGlError();
Gl.glEnableClientState(Gl.GL_INDEX_ARRAY);
CheckGlError();
} }
void CgErrorCallback() void CgErrorCallback()
@@ -97,13 +102,23 @@ namespace OpenRa.GlRenderer
CheckGlError(); CheckGlError();
} }
public void DrawIndexedPrimitives(PrimitiveType pt, Range<int> vertices, Range<int> indices) { } public void DrawIndexedPrimitives(PrimitiveType pt, Range<int> vertices, Range<int> indices)
public void DrawIndexedPrimitives(PrimitiveType pt, int numVerts, int numPrimitives) { } {
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<T> public struct Range<T>
{ {
public Range(T start, T end) { } public readonly T Start, End;
public Range(T start, T end) { Start = start; End = end; }
} }
public class VertexBuffer<T> where T : struct public class VertexBuffer<T> where T : struct
@@ -241,7 +256,7 @@ namespace OpenRa.GlRenderer
public void SetValue(string name, Texture texture) public void SetValue(string name, Texture texture)
{ {
var param = Cg.cgGetNamedEffectParameter(effect, name); 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) public void SetValue(string name, float x, float y)

View File

@@ -32,14 +32,16 @@ VertexOut Simple_vp(VertexIn v) {
} }
float4 Simple_fp(FragmentIn f) : COLOR0 { float4 Simple_fp(FragmentIn f) : COLOR0 {
float4 r = tex2D(DiffuseTexture, f.Tex0); return float4( 1,0,0,1 );
return r; // float4 r = tex2D(DiffuseTexture, f.Tex0);
// return r;
} }
technique high_quality { technique high_quality {
pass p0 { pass p0 {
BlendEnable = true; BlendEnable = true;
DepthTestEnable = false; DepthTestEnable = false;
// CullFace = NONE;
// CullMode = None; // CullMode = None;
// FillMode = Solid; // FillMode = Solid;
VertexProgram = compile arbvp1 Simple_vp(); VertexProgram = compile arbvp1 Simple_vp();