Skip to main content
gamedev.net
🔒 Locked

tao vertexpointers...

Started by xyz Mar 4, 2004 at 2:53 PM 9 replies 1k views
Original Post
xyz
xyz
Hi, I''m trying to use vertexpointers in Tao with c#... A simple (not working) example:
float[] vertices = { -1, -1, 1, 1, -1, 1, 1, 1, 1 };
float[] indices = { 0, 1, 2 };

Gl.glEnableClientState(Gl.GL_VERTEX_ARRAY);

Gl.glVertexPointer(3, Gl.GL_FLOAT, sizeof(float), vertices);
Gl.glDrawElements(Gl.GL_TRIANGLES, 3, Gl.GL_UNSIGNED_INT, indices);

Gl.glDisableClientState(Gl.GL_VERTEX_ARRAY);
 
And I get ''Object reference not set to an instance of an object'', somewhere in the closing bracket of my main function (?!)... Whats wrong? Thanks
xyz
xyz
WinXP
Brother Bob
Brother Bob
quote:
Original post by xyz

float[] indices = { 0, 1, 2 };
...
Gl.glDrawElements(Gl.GL_TRIANGLES, 3, Gl.GL_UNSIGNED_INT, indices);



Not that I know C# or Tao or whatever, but the above code (the bold parts more specifically) sure looks stragne.

NLDEV
NLDEV
quote:
Original post by xyz
Hi,

I'm trying to use vertexpointers in Tao with c#... A simple (not working) example:


Gl.glVertexPointer(3, Gl.GL_FLOAT, sizeof(float), vertices);
Gl.glDrawElements(Gl.GL_TRIANGLES, 3, Gl.GL_UNSIGNED_INT, indices);





Two things that I can see. For the stride argument of glVertexPointer(), you can pass 0 as your vertices are tightly packed. In your call of glDrawElements, it is calling for the indices be stored in some kind of integer, which you specify as being an unsigned int, yet you are passing an array of floats. Not sure if these are your problems, but just my two cents.

[edited by - MikeMJH on March 5, 2004 9:53:01 AM]
superdeveloper
superdeveloper
xyz, forgive me for being nosy, but I though tao was an O/s VM developer (that's why I asked which platform).

Now, tao does come for windows, in teh form of Elate, but this is a java vm, so how C# mingles is beyond me.

I am thinking of TAO Group.. IS this the same Tao that you are referring to?

Sorry for going off on tangents

I am curious about all of this because I have been working with (tao-group) Tao for a few years now on various platforms and devices (non gaming or 3D apps)...

[edit] fixed url

[edited by - superdeveloper on March 5, 2004 10:08:36 AM]
_the_phantom_
_the_phantom_
quote:
Original post by xyz
And I get ''Object reference not set to an instance of an object'', somewhere in the closing bracket of my main function (?!)...

Whats wrong?



C# might not be my thing atm, however i would guess that error msg relates to you trying to use an object without it being setup correctly

xyz
xyz
thanks, just one more thing: i have my vertices set up like this:


public class Vertice
{
public float[] position = new float[3];
}



Vertice[] vertices = new Vertice[numVerts]


but then glVertexPointer requires a float[], this would work in c++: vertices->position, but there are no pointers in c# and I don''t want to use unsafe code, how can I do it?

Thanks again

leedgitar
leedgitar
Try a short array for your indices and Gl.glDrawElements(Gl.GL_TRIANGLES, 3, Gl.GL_UNSIGNED_SHORT, indices).

I use vertex pointers (as a fallback for lack of vertex_buffer_object support) in Axiom (http://axiomengine.sf.net) using Tao.OpenGL with no problems.
________________________________________________Chris McGuirkLead Programmer - Axiom 3D EngineC# gaming, the way of the future!http://www.axiom3d.org
xyz
xyz
but hw do set up and access those?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.