Jump to content
  • Advertisement

Archived

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

Ysaneya

OpenGL D3D Vertex buffers as in OpenGL ?

This topic is 6107 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

Please, bear with me as i''m fluent in OpenGL but a newbie to D3D. In OpenGL, it would be possible to reuse the same texture coordinate array for 2 different TMUs. Like, say you have an array of UV coordinates defined by float *uv; then you could set up a texture matrix on TMU1 and use uv, and set up a different texture matrix on TMU2, and use the same pointer to uv. That way, you do not provide data twice. I simply would like to know if it''s possible to do that in D3D and if so, how (hints to a doc would be fine). I can still duplicate the uv once per TMU, but it doesn''t seem very efficient to me. Another thing, more or less related, is about the way vertices are stored in a vertex buffer. In OpenGL, you are not forced to using an interleaved format (that is: xyz0,uv0,xyz1,uv1,xyz2,uv2 etc.. ); you can also use a linear array of components (xyz0,xyz1,xyz2,uv0,uv1,uv2). I would also like to know if it could be done in D3D or not. In a real situation, say i have 2 pass, for example a first one to draw a diffuse texture, and a second one to blend some lightmap over it (i''m assuming i do not have access to multitexturing, but that''s just for the example). Since the vertices positions (xyz) are the same in the 2 pass, i would like to avoid duplicating them in the 2 vertex buffers... that could easily be done in OpenGL by setting up a pointer to the same array. Any help is appreciated. Y.

Share this post


Link to post
Share on other sites
Advertisement
You can set multiple streams sources if you are using vertex shaders, but you cannot if you are using the fixed function pipeline. Take a look at the SetStreamSource and vertex shader declaration portions of the docs.

Share this post


Link to post
Share on other sites
You certainly can reuse a texture coordinate in multiple texture stages:

- Take a look at IDirect3DDevice8::SetTextureStageState() [set the per-stage (TMU) render states], in particular look at the SDK docs for the D3DTSS_TEXCOORDINDEX state.

- For the texture matrices, the IDirect3DDevice8::SetTransform() call is what you''re after. The D3DTS_TEXTURE0 through to D3DTS_TEXTURE7 matrices are those applied to texture coordinates.

- Finally look at the D3DTSS_TEXTURETRANSFORMFLAGS TextureStageState which define how the matrix is to be used in processing of texture coordinates for that stage (is it homogeneous, how many coordinates are passed etc).

--
Simon O''''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites
Oops - sorry, I read the post too quickly. To sum up...

Yes, you can reuse coordinates a la Simon''s comments, but if you are using shaders you can also mix and match streams that have different data. Say you have position data and several possible uv coordinates. You can set things up to draw data from two different streams and trade the different uv streams out as needed.

I think you might be able to use linear arrays as you''ve described if you played around enough with start indices and strides, but I''ve never tried.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!