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);
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<int> vertices, Range<int> indices) { }
public void DrawIndexedPrimitives(PrimitiveType pt, int numVerts, int numPrimitives) { }
public void DrawIndexedPrimitives(PrimitiveType pt, Range<int> vertices, Range<int> 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<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
@@ -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)

View File

@@ -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();