Jump to content
  • Advertisement
Sign in to follow this  

Structs and Textures

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

I've recently been working on a platformer, and ran into a wierd bug. I'm not sure if its due to my data losing scope or what, but I created a class that holds the information about the world. Well I also included an array to hold information about each cell, and of course one of these would be the texture being used for that cell. Now when I try to use that texture to draw my sprites to the screen they never show up. So after a bit of working, I transfered the texture information out of the struct and made it its own array, and it works fine. Anyone know a reason behind this? The rest of the data from the struct works fine and can update at the same location where I need to draw, but for some reason I can't retrieve any texture information. Thanks for your time. Slyprid

Share this post

Link to post
Share on other sites
Without more details its near impossible to tell for sure.

Was the field a IDirect3DTexture9* pointer? (if so, were you AddRef'ing copies, or re-loading per-tile?), if not, then what information are you storing?

What are the debug runtimes saying?

Using an invalid texture sometimes generates a debug message, if not you'll get a solid white (iirc) colour instead.


Share this post

Link to post
Share on other sites
Was wondering if I should throw the code in or not. Well let me try to give it a shot.

Main loop
All this is is where the rendering is happening


World class

#pragma once

#include <d3d9.h>
#include <d3dx9.h>
#include <d3dx9math.h>
#include <assert.h>
#include <string>
#include "DX.h"

using namespace std;

class clsWorld
struct cellData
bool overlay_visible;
string event_type;
int event_LocX;
int event_LocY;
bool textured;

int world;
int stage;
int cellTotal;
int worldLength;
int worldHeight;
int FocusX;
int FocusY;
int back1X;
int back2X;

cellData cells[4][50];

LPDIRECT3DTEXTURE9 LoadTexture(char *filename, D3DCOLOR transcolor);

extern clsWorld *world;

In the main I declare clsWorld *world like I do with all my other externs, but like I said the texture info within the struct doesn't seem to show up. Will try to get what debug is saying and post also. Thanks for your time.


Share this post

Link to post
Share on other sites
You are passing the entire struct into the draw call. Try this:


Also, you don't seem to be giving the call all the parms it needs. I am not really familiar with sprites, but what about:

CONST RECT * pSrcRect,
CONST D3DXVECTOR3 * pPosition,

Maybe you are using an older SDK version?

Share this post

Link to post
Share on other sites
The draw command I use is just a function. Thats why its only 3 parameters. I forgot to type in the .texture for the struct on the command also. Thats what i'm actually using.

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.

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!