ich bin gerade dabei, alle char* aus meinem programm zu entfernen.
allerdings stolpere ich da �ber ein paar funktionen, welche umbedingt const
char* bzw char* verlangen. bis jetzt kam ich noch ohne typumwandlung beim
programmieren aus, doch leider muss ich jetzt irgendwie meine string objekte
in char* wandel. hat einer ne idee, wie so ne umwandlung ohne viel
brimborium funktioniert. ich habe mir nat�rlich auch �berlegt, die
funktionen welche char* verlangen, umzubauen. leider scheitere ich daran,
das genau diese funktion aus einem tutorial f�r OpenGL kommt, und ich
eigentlich keinen plan habe, was diese funktionen eigentlich machen. ( ich
bin da etwas skeptisch, da so wenig code mir lauter super sachen macht
(textausgabe mit GL) . ich mag keine typ umwandlung. ich denke mir eher
sollte ich gleich mit den richtigen typen arbeiten, als die ganze zeit was
umbiegen/wandeln. was zur folge h�tte, die glPrint funktion selbst zu
verwirklichen. hat einer ne idee, wie ich am besten vorgehen sollte?
henrik
anbei die sorgen-funktionen
/***********************************************************
** GL Font - Part of the GAIA/FirstImpact Project **
** by Henrik Schneider **
** www.x-nas.org **
** Copyright by the Coder '04 **
** or see end of file for more info **
***********************************************************/
// BuildFont(GLvoid); KillFont(GLvoid) and glPrint are taken from nehe.gamedev.net
// code by Jeff Molofee. see EOF
void fiLogOutput(char* MessageToLog)
{
FILE *fo;
fo = fopen("log/system.txt","a");
fprintf(fo,MessageToLog);
// fprintf(fo,MsgType);
fprintf(fo,"\n");
fclose(fo);
}
GLvoid BuildFont(GLvoid) // Build Our Bitmap Font
{
HFONT font; // Windows Font ID
HFONT oldfont; // Used For Good House Keeping
base = glGenLists(96); // Storage For 96 Characters
font = CreateFont( -12, // Height Of Font
0, // Width Of Font
0, // Angle Of Escapement
0, // Orientation Angle
FALSE, // Font Weight FW_BOLD
FALSE, // Italic
FALSE, // Underline
FALSE, // Strikeout
ANSI_CHARSET, // Character Set Identifier
OUT_TT_PRECIS, // Output Precision
CLIP_DEFAULT_PRECIS, // Clipping Precision
ANTIALIASED_QUALITY, // Output Quality
FF_DONTCARE|DEFAULT_PITCH, // Family And Pitch
"Arial"); // Font Name
oldfont = (HFONT)SelectObject(hDC, font); // Selects The Font We Want
wglUseFontBitmaps(hDC, 32, 96, base); // Builds 96 Characters Starting At Character 32
SelectObject(hDC, oldfont); // Selects The Font We Want
DeleteObject(font); // Delete The Font
fiLogOutput("Font built");
}
GLvoid KillFont(GLvoid) // Delete The Font List
{
glDeleteLists(base, 96); // Delete All 96 Characters
fiLogOutput("Font deleted");
}
//GLvoid glPrint(const char *fmt, ...)
//{
GLvoid glPrint(char* fmt, ...) // Custom GL "Print" Routine
{
char text[256]; // Holds Our String
va_list ap; // Pointer To List Of Arguments
if (fmt == FALSE) // If There's No Text
return; // Do Nothing
va_start(ap, fmt); // Parses The String For Variables
vsprintf(text, fmt, ap); // And Converts Symbols To Actual Numbers
va_end(ap); // Results Are Stored In Text
glPushAttrib(GL_LIST_BIT); // Pushes The Display List Bits
glListBase(base - 32); // Sets The Base Character to 32
glCallLists(strlen(text), GL_UNSIGNED_BYTE, text); // Draws The Display List Text
glPopAttrib(); // Pops The Display List Bits
// fiLogOutput("Displayed Message");
}
//notes and rights
/*
* This Code Was Created By Jeff Molofee 2000
* Modified by Shawn T. to handle (%3.2f, num) parameters.
* A HUGE Thanks To Fredric Echols For Cleaning Up
* And Optimizing The Base Code, Making It More Flexible!
* If You've Found This Code Useful, Please Let Me Know.
* Visit My Site At nehe.gamedev.net
*/