Archived

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

deadlydog

Do you need to use vertices to load textures?

Recommended Posts

deadlydog    170
I''m a little confused right now. I''m reading Programming Role Playing Games With DirectX right now and in it to load a texture they say to setup 4 vertices (to make a rectangle), then load a texture into the vertices (texture mapping). But in the graphics engine I do not see them using vertices at all to load the textures. So do u need to use vertices to load a texture, or does DirectX have a built in function to just load a texture from a file? and if so, what is the point of texture mapping? (Why use it)? - God is my favorite fictional character

Share this post


Link to post
Share on other sites
You don''t need vertices to load a texture, you can just call D3DXCreateTextureFromFileEx()

In order to display a texture you typically use vertices. Vertices will include their position, color, and a point on a texture. To make a rectangle with a texture on it you need 4 vertices (4 points in space).

Share this post


Link to post
Share on other sites
superpig    1825
You''re confusing two concepts - loading a texture (extracting it from a file into memory) and displaying a texture.

As NTNet (ooh, can I call you that?) said, to load a texture you just call something like D3DXCreateTextureFromFile() to load the texture from disk into memory, ready to be used. It doesn''t display anything, doesn''t require any vertices or other things like that (except a Direct3D device object).

To actually *display* a texture you''ve got two options: do a pixel-by-pixel copy to the render target a la DirectDraw (not a good idea on modern cards), or draw some polygons that have the texture applied to them - "texture mapping." In order to draw polygons, you do of course need vertices - to apply the texture to those polygons, you need to give the vertices some texture coordinates (along with their position, color, normal, or whatever) and you need to configure the texturing stuff to use your specific texture.

Share this post


Link to post
Share on other sites