Do you need to use vertices to load textures?

Started by
1 comment, last by deadlydog 19 years, 11 months ago
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
-Dan- Can't never could do anything | DansKingdom.com | Dynamic Particle System Framework for XNA
Advertisement
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).
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.

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

This topic is closed to new replies.

Advertisement