#### Archived

This topic is now archived and is closed to further replies.

# tao vertexpointers...

This topic is 5098 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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

##### Share on other sites
out of curiosity, what platform are you using tao on?

WinXP

##### Share on other sites
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.

##### Share on other sites
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]

##### Share on other sites
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)...

 fixed url

[edited by - superdeveloper on March 5, 2004 10:08:36 AM]

##### Share on other sites
He''s talking Tao.OpenGl (http://www.randyridge.com/Tao/) and not the Tao Group.

##### Share on other sites
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

##### Share on other sites
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

##### Share on other sites
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.

##### Share on other sites
but hw do set up and access those?

• 9
• 10
• 18
• 14
• 10