Jump to content
  • Advertisement

Archived

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

tao vertexpointers...

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
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)...

[edit] fixed url

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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
He''s talking Tao.OpenGl (http://www.randyridge.com/Tao/) and not the Tao Group.

Share this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!