Archived

This topic is now archived and is closed to further replies.

Tera_Dragon

Text and Textures

Recommended Posts

I have a quad with a texture. Before I draw the quad I use glColor4f(1.0f, 1.0f, 1.0f, 1.0f); Then after I draw the quad I then use glColor4f(1.0f, 1.0f, 1.0f, 0.0f); and try to draw a bitmap font. The font, though, does not get draw. What am I doing wrong? Or can''t u use bitmap font''s over a quad? Thanks ofr any help given Tera_Dragon ------------------------------------------------------------ Programmers Resource Central

Share this post


Link to post
Share on other sites
Well first things first: If the quad and the text are both White, then how do you know its not drawing? It could be, but since its the same color, it might just be invisible. change the color of either the quad or the text.

other things:

Is alpha blending enabled? If so, what is your BlendFunc?

Try turning off depth testing when drawing the font, maybe its behind the quad.



Waramp.

Before you insult a man, walk a mile in his shoes.
That way, when you do insult him, you''ll be a mile away, and you''ll have his shoes.

Share this post


Link to post
Share on other sites
I said in my first post that the quad had a texture on it, so it isn't white, which the text should be.
I am using glBlendFunc(GL_SRC_ALPHA, GL_ONE);
I tried turning off depth testing but it didn't work.

------------------------------------------------------------
Programmers Resource Central

[edited by - Tera_Dragon on May 27, 2004 10:07:15 AM]

Share this post


Link to post
Share on other sites
Is there a quick way to add a char to a string when that key is pressed? I don''t want to have to write out:
if(keyPressed[''M''] && !mp)
{
mp = true;
word += "m";
}
if(!keyPressed[''M''])
{
mp = false;
}
for every key.

Share this post


Link to post
Share on other sites
I have this:

void outPut()
{
for(static int i = 97; i < 122; i++)
{
if(keyPressed[(i - 97)] && !key[(i - 97)])
{
key[(i - 97)] = true;
word += i;
}
if(!keyPressed[(i - 97)])
{
key[(i - 97)] = false;
}
}
}


but it doesn''t work, y not?

Share this post


Link to post
Share on other sites
quote:
Original post by TomasH
//Shouldn't this:

keyPressed[(i - 97)]
//be like this:

keyPressed[ i]
// ????



yeah, I got that worng, but even when ifxed it didn't help.
Now I'm using wParam in my WndProc function.
But I am now getting problems with deleting characters from a string. I am using:


case VK_BACK:
word.erase( (word.length()-1), 1);
break;

but this for some reason doesn't change the length of the string. So I can only delete 1 character.

------------------------------------------------------------
Programmers Resource Central

[edited by - Tera_Dragon on May 27, 2004 12:39:31 PM]

[edited by - Tera_Dragon on May 27, 2004 1:12:27 PM]

[edited by - Tera_Dragon on May 27, 2004 1:12:59 PM]

[edited by - Tera_Dragon on May 27, 2004 1:13:40 PM]

[edited by - Tera_Dragon on May 27, 2004 1:14:16 PM]

Share this post


Link to post
Share on other sites
Is it that the user can now type fine and the text gets displayed fine, but your backspace functionality isn't working? Normally, I'd say to post the code for word.erase () but when you call word.erase (...), I don't see you changing the length of the word, all I see you doing is passing (word.length () - 1) to word.erase () always, which, if you don't change the length in your erase function, will be a constant - whatever length is minus one. If that's not the problem, post the relevant code.

~Urayami

[edited by - urayami on May 27, 2004 2:29:24 PM]

Share this post


Link to post
Share on other sites

case VK_BACK:
if(word == "Start:")
return (DefWindowProc(hwnd, message, wParam, lParam));;

//word = word.substr(0, (word.size() - 1));


word.erase( (word.length()-1), 1);

word.resize( (word.length() - 1) );


break;


I am using this, I don''t know whether to use word = word.substr(0, (word.size() - 1)); (this doesn''t work the second time around on it''s own either) with resize or erase with resize.
When either of the first are used as a pair with resize the string is visably shorted, but not always by 1. If you enter a few chars then delete 2 r deleted, then it deletes 1 and somethimes it doesn''t delete any at all. Also the string word is "Start:" when the program loads as u can see if backspace is hit when word == "Start:" then is will skip the deletion code. But if I enter some chars first and then delete, I can delete the "Start:"
I will appericiate any help
Tera_Dragon

------------------------------------------------------------
Programmers Resource Central

Share this post


Link to post
Share on other sites
word = word.substr(0, (word.size() - 1));
word.erase( (word.length()-1), 1);
word.resize( (word.length()-1) );

The above three lines should give the exact same result, which is to remove the last character from "word." I'd say the last solution is the nicest.
Of course, if you do both erase() and resize(), you remove two characters at once.

EDIT: urayami, he's using std::string

[edited by - TomasH on May 27, 2004 2:56:18 PM]

Share this post


Link to post
Share on other sites
as I said before, if I just use one of them then it will delete a char the first time I use it, but for it to work again I have to add an extra character. So it is as though the size is not changing.
e.g.
I enter ''hello'', then hit backspace, it changes hello to ''hell'', but no matter how many more times I hit backspace it stays at ''hell'', I then add an ''o'' to make ''hello'', then hit backspace, and it changes to ,hell, etc etc etc. And I have tried it with different sized strings, not just ''hell'' and ''hello''

------------------------------------------------------------
Programmers Resource Central

Share this post


Link to post
Share on other sites
                               case VK_BACK:
if(word == "Start:")
return (DefWindowProc(hwnd, mess
age, wParam, lParam));;

//word = word.substr(0, (word.size() - 1

));

//word.erase( (word.length()-1), 1);


word.resize( (word.length() - 1) );


break;

case VK_RETURN:
promptMenu();
break;

}
keyPressed[wParam] = true;

if(wParam > 64 && wParam < 91)
word += (wParam + 32);
else
word += wParam; // <-------


return 0;

The line above (marked with <-------) will be reached even when backspace is pressed. So what happens when you press backspace is that the last character is removed from the string and VK_BACK is added to it.
Try changing the if-else, so that you actually check wParam in the else instead of just adding it 8)

Share this post


Link to post
Share on other sites
thanks!! :D :D
I really appreciate your help.
I''ve changed me code to this if any body wants to know for reference ;-):

case VK_BACK:
if(word == "Start:")
return (DefWindowProc(hwnd, message, wParam, lParam));

word.resize( (word.length() - 1) );


break;

case VK_RETURN:
promptMenu();
break;

default:
keyPressed[wParam] = true;

if(wParam > 64 && wParam < 91)
word += (wParam + 32);
else
word += wParam;

return 0;
break;


------------------------------------------------------------
Programmers Resource Central

Share this post


Link to post
Share on other sites
the font I am using is Courier (I have also tried Times New Roman), and these both have /''[],.\etc. but they do not show.
I am using word += wParam; to add characters to the string. Doesn''t wParam hold ,./''#[];\etc? If so how do I use them?

------------------------------------------------------------
Programmers Resource Central

Share this post


Link to post
Share on other sites