Hello once again, I've continued my engine somewhat and the rendering functions are now working fine thanks to Stinomus (feel free to applaud). However to enable it to load data I must use files containing strings describing objects in the game world. That in turn works perfectly and passes the relevant string to a function that stores it.
However I realised my engine would be quite a proportion harder to code if I was unable to display 'debug' messages on the screen with values etc, in this regard I decided to create a function that would accept strings from anywhere in my program (in this case the file loading application) store them in a vector of structs and then parse them to the rendering routine before flipping the backbuffer.
In case your not familiar as to why i don't just output them immediately hardware graphics coding requires that anything output to the screen be placed between a startscene() and endscene() function, thus any debug messages I want to display must be stalled until rendering takes place.
The function to store the string works fine, however when I attempt to load the string from the structure using the vector the string data comes out as a garbled lines of gibberish. My only explination is either the string isn't being stored correctly and I'm reading the next set of memory blocks after it's location, or for some reason it's being converted between formats in some fashion. I have only gleaned a use of vectors recently so though perhaps it would be wise to see if anyone has an explanation or can find fault in my code I am unaware of (more likely by far).
the structure that stores my 'message' data and other declared variables
struct PrintBuffer
{
int onscreen;
int ypos;
LPCWSTR PrintString;
};
vector<PrintBuffer> StringBuffer;
int DebugYPos=0;
The function that stores a message
void DrawDebugText(LPCWSTR oString)
{
PrintBuffer PushString;
PushString.onscreen=0;
PushString.PrintString = oString;
PushString.ypos=DebugYPos;
StringBuffer.push_back(PushString);
DebugYPos+=20;
for(int i=0;i<int(StringBuffer.size()-1);i++)
{
if (StringBuffer.at(i).ypos==DebugYPos)
{
DebugYPos+=20;
}
}
if (DebugYPos >= SCREENHEIGHT) DebugYPos=0;
}
the code to send the string to the rendering function (rendering function DrawTextScreen() works perfectly thus is ommited
void RenderDebugText()
{
if (StringBuffer.empty())
{DebugYPos=0;return;}
for(int i=0;i<int(StringBuffer.size());i++)
{
if (StringBuffer.at(i).onscreen >=255)
{
StringBuffer.erase(StringBuffer.begin()+i);
}else
{
StringBuffer.at(i).onscreen++;
DrawTextScreen((StringBuffer.at(i).PrintString),0.0f,StringBuffer.at(i).ypos+0.0f,20.0f,200.0f,D3DCOLOR_ARGB(255-StringBuffer.at(i).onscreen,255,255,255));
}
}
}
Having checked the values during run time with break points the string stored in the vector is definitely "data/level1/level.info", however the output is seemingly random characters (mostly Traditional Japanese or Mandarin) while that may fit well with my anime style game, it certainly does not help me check the data as i load it, thus any solution will be gratefully appreciated.