Sign in to follow this  
Direct

[.net] C# skybox

Recommended Posts

I'v tried searching, I've tried filling vertex buffers every which way, and I'm about ready to kick myself...I am trying to learn to use DirectX in C# without much luck...I figure a simple experiment to try first is a skybox...but I can't seem to find a proper way to fill in the data. I created an array of vertices (using my own simple 'vertex' with x,y,z,u,v), but have been unable to successfully find a way to fill a vertexbuffer...the directx FAQ states I need to specify the size of each vertex in my array for instance...but you can't use sizeof() in safe code? Has anyone seen a simple example of a skybox out there? I'm floundering, and the help provided by microsoft seems to be entirely devoid of decent examples.

Share this post


Link to post
Share on other sites
this might help a little:
there is a helper method in directx (Microsoft.DirectX.DXHelp.GetTypeSize) that should run in a safe context. You can also just figure out the size yourself by adding up all the sizes of the types in your vert. You can even use the StructLayout attributes to explicitly control the size if you need to.

Are you using FVF or Declarations for your custom vertex? If you use decleartions, the size passed to the buffer can be greater than the actual size of your vert.

If you are just starting you don't need to use a VertexBuffer, take a look at Device.DrawUserPrimitive/DrawIndexedUserPrimitive. It is slower, but it might get you going.

Share this post


Link to post
Share on other sites
Was using FVF...I'd be all about loading a mesh for the skybox if I could quite figure out how to do one...I figured the vertexbuffer would be simpler to start with. I'll take a look at the mesh stuff and see if something jumps out at me :)

Share this post


Link to post
Share on other sites

I'm going to put further questions on this in the DirectX forum, as I feel my problem is my understanding of using DirectX, not C#, at this point.

[Edited by - Direct on December 6, 2004 8:42:24 AM]

Share this post


Link to post
Share on other sites
//Loading files (in initialization)
Mesh m = Mesh.FromFile(/*insert parameters here*/);
Texture texName = TextureLoader.FromFile(/*insert params here*/);

//Drawing
device.SetTexture(0, texName);
m.DrawSubset(0);

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this