Welcome to Dream.In.Code
Getting Help is Easy!

Join 132,392 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,237 people online right now. Registration is fast and FREE... Join Now!




directx texture question

 
Reply to this topicStart new topic

directx texture question

Mugglecaster
post 24 Aug, 2008 - 11:41 PM
Post #1


New D.I.C Head

*
Joined: 2 Jan, 2008
Posts: 16


My Contributions


if i have a LPDIRECT3DTEXTURE9 texture can i draw that texture more than once in a frame when ever i try none are drawn at all but it seems a waste to load the same texture more than once
User is offlineProfile CardPM

Go to the top of the page

KYA
post 25 Aug, 2008 - 07:05 AM
Post #2


#include <nerd.h>

Group Icon
Joined: 14 Sep, 2007
Posts: 4,205



Thanked 50 times

Dream Kudos: 1150
My Contributions


You load the texture from file and then apply it to the various devices that you have. An idea:

cpp

//in initialization code
D3DXCreateTextureFromFile( g_pd3dDevice, "woodfloor.bmp", &g_pTexture );
//in render code
g_pd3dDevice->SetTexture( 0, g_pTexture );
User is online!Profile CardPM

Go to the top of the page

Mugglecaster
post 25 Aug, 2008 - 10:34 PM
Post #3


New D.I.C Head

*
Joined: 2 Jan, 2008
Posts: 16


My Contributions


i tried what you said but its still not working if i try to draw more than one none come up at all here's some of the code im using:

CODE

//code to load texture from file
D3DXCreateTextureFromFileEx(d3ddev, "pacDot.bmp", D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, NULL, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, D3DCOLOR_XRGB(255, 0, 255), NULL, NULL, &pacDot);

//and the code to draw the image
for(int i = 1; i == 10; ++i) {
[indent]sptInterface->Draw(pacDot, NULL, &defaultCenter, &pacDotPosition[i], D3DCOLOR_XRGB(255,255,255));
}


i tried adding the SetTexture function in but it didnt seem to help
User is offlineProfile CardPM

Go to the top of the page

stayscrisp
post 26 Aug, 2008 - 04:09 AM
Post #4


D.I.C Regular

***
Joined: 14 Feb, 2008
Posts: 258



Thanked 6 times
My Contributions


CODE

for(int i = 1; i == 10; ++i) {


Nasty :s

CODE

for(int i = 1; i < 10; i++) {


Better smile.gif

but i think you should add your textures to a vector or something like that so you can store them and get them easier

for example , load your texture from file, do some error checking to see if it has worked, convert to texture then return the texture and push it into a vector, then you can use the std vector functions to get the files smile.gif

good luck
User is offlineProfile CardPM

Go to the top of the page

KYA
post 26 Aug, 2008 - 06:03 AM
Post #5


#include <nerd.h>

Group Icon
Joined: 14 Sep, 2007
Posts: 4,205



Thanked 50 times

Dream Kudos: 1150
My Contributions


That's a great idea staycrisp.

Also, I don't know how you have your device pointer set up, but you should be able to use one texture on all the objects in the world if you so desired.
User is online!Profile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/22/08 07:11AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month