Sign in to follow this  

Structs and Textures

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this