Jump to content
  • Advertisement
Sign in to follow this  
billconan

OpenGL help me with datastructure

This topic is 4890 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 all, i'm writing a 3d tool using the directx. because the mesh data of directx doesn't suit for my tool, i wrote one myself. but when rendering scene, i need to create a directx structure from my structure, which makes the performance not robust. so i don't know how to deal with it. is it true that the directx is more suitable for developing the games while opengl is more powerful in developing 3d tools? any suggestion? thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
Hello billconan,

It's fine that you are using your own data structures to hold mesh information and I would recommend it. Since you already have your own data structures all you will need to do is

1) Create a vertex buffer(IDirect3DVertexBuffer9) and possible an index buffer(IDirect3DIndexBuffer9).
2) Lock the buffers using their Lock method.
3) Fill in the data
4) UnLock the buffers using their UnLock method.

With this you can set any type of data to render with. You are not bound to using ID3DXMesh

EDIT: It's late and I'm not really sure what you are asking and I just read over my post and it doesn't seem to helpful. Basically, yes you'll have to some how move the data from your application to the GPU. The GPU can not "create" geometry(a side from the tesselator). Regardless if you use DX or OGL, you will have to somehow send vertices from your app to the graphics card. In the case of DX you will want to use a dynamic vertex buffer this will be your fastest bet.

Share this post


Link to post
Share on other sites
How frequently does your data actually change? I'd imagine it's not on a frame-by-frame basis. If you're trying to improve performance in your app you could see about preserving the vertex/index data between frames in a static VB, and when the user actually changes the mesh you just lock and update the relevant parts. Locking/editing a static VB on a frame-by-frame basis isn't generally recommended, but if you only lock it once a frame and only on frames where the user is actually editing the mesh it ought not to be too bad.

Share this post


Link to post
Share on other sites
hi there,
thanks for replying me.

since it is a tool not a game, the frame doesn't updata frequently.

so i do use a vb to hold a render mesh and my structure to save the real mesh.

every time the user edit the model, i updata the vb for rendering.

but i also think of another way, i can write a function which handle for rendering a single face, and i use a loop to visit the whole faces to render them.

i don't know which one is fast.

current screenshot

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!