Jump to content
  • Advertisement

Merlino

Member
  • Content Count

    36
  • Joined

  • Last visited

Community Reputation

122 Neutral

About Merlino

  • Rank
    Member
  1. Merlino

    Animation Math

    Hi, I am rather new to programming and I have a question about animation. Here's a theoric example: imagine that there are 2 variables and one evolves based on the other one, let's say that the width of a rectangle on screen evolves based on time. So, when time is equal to a, width is equal to d, when time is equal to b, width is equal to e and so on. Imagine I know the values of a, b, c, d and f. How do I calculate e based on these values? Thanks in advance, Merlino Edit: please post only once; the Forum FAQ contains useful information about how to format your post (I mean, images are enclosed by normal <img> tags) -- .ED
  2. Merlino

    Class / Pointers Question

    Argh, I'm sooo stupid.. actually it works. SORRY !! But anyway, is "case 2" a good way of structuring classes if using class pointers? Thanks, and again, sorry.
  3. Hi, I have a question about pointers to classes: It's kind of hard for me to explain so here's an example I've made up: I have 3 classes: Instruments, Window, and Main. Instruments is a class that stores info about the time (say time = time elapsed since program startup); Window is a class that stores the info of one window and it needs acces to the value time of the Instruments class. Main is a class that stores pointers to all the other classes.. it's the root class. class Instruments { public: long int time; short mouseX; } class Window { public: short x; short y; short width; shory height; void Animate(); } class main { public: Instruments * instr; Window * window; main() {allocate memory for the class pointers}; } Now, here is my problem. How do I get the window class to acces the time value of the Instruments class? I thought about 2 solutions: 1- replace the Animate() function by Animate(long int time) and, when using the function like this: window->Animate(instr->time). But this can get kind of messy if, in this case, the window class has to acces members from lots of other classes. 2- create a pointer to Instruments class in the Window class and acces the values this way. In this case I don't want to create another Instruments object but make the pointer to point the same thing as the main pointer. In code this would equal to: class Window { public: short x; short y; short width; shory height; Instruments * instr; void Animate(); { acces instr->time ... } } main::main() { ... window = new Window; instr = new instr; window->instr = this->instr; } I tried this in my program but it does not seem to work because if i modify the values through main->instr->time, and then acces it through main->window->instr->time it is not the same. Did I do something wrong or is it normal? If so, is there any other way to do this ? Thanks in advance, Merlino.
  4. Hi, i have one fast question: imagine that you need a class that has many objects and you also need several functions that modify the object's values. Do you get a better performance if you create one class with all the functions and another one with the values and only create one object for the function class OR is it better to create just one class with the values and the functions and create all the objects for it? Example: -- Case 1 -- class number { private: int value; int halfOfTheValue; friend class handle; } class handle { public: divideBy2(); multiplyBy3(); setTo0(); } main { number * 1, *2, *3, *4.....; handle * Handle; } -- Case 2 -- class number { private: int value; int halfOfTheValue; public: divideBy2(number * Number); multiplyBy3(number * Number); setTo0(number * Number); } main { number * 1, *2, *3, *4.....; } I think case 2 is better but I am not sure, that's why I'm posting. THX :D
  5. I've been looking for tutorials about file input all day, but I could understand how extract values from a file: Most of the tutos I read suggested to use the functions getline()/get() to pass the contnent of the file to a string. But suppose you want to extract some other values from the string such as integers or shorts... how do you do it? The only way to extract values other than string and chars from a file, as far as I got to know from the tutos I found, is using the "<<" operators like this: int number; ifstream myFile("blabla.txt"); myFile >> number; The problem is that, in order to use this "function", the inside get-pointer must be at the right position, just before the int. I read that there are functions to move this pointer (i.e. seekg()) but there is no point in reading from files and not just passing the values "by hand" if you have to count the number of spaces between every value... ...so isn't there a function that can look for strings in a file just like strstr() does with strings? So, to sum up, here's the file from which I have to extract the values (actually it's a bit bigger than this but it does not matter): a x 37 y 0 W 67 H 108 b x 113 y 0 W 67 H 108 c x 187 y 0 W 59 H 108 d x 258 y 0 W 69 H 108 e x 337 y 0 W 61 H 108 f x 402 y 0 W 52 H 108 g x 460 y 0 W 67 H 108 h x 544 y 0 W 64 H 108 i x 602 y 0 W 17 H 108 j x 631 y 0 W 42 H 108 k x 704 y 0 W 66 H 108 l x 756 y 0 W 18 H 108 m x 836 y 0 W 104 H 108 n x 936 y 0 W 61 H 108 o x 1017 y 0 W 70 H 108 p x 1100 y 0 W 68 H 108 q x 1177 y 0 W 68 H 108 r x 1252 y 0 W 44 H 108 s x 1306 y 0 W 53 H 108 t x 1364 y 0 W 46 H 108 u x 1428 y 0 W 65 H 108 v x 1503 y 0 W 68 H 108 w x 1587 y 0 W 101 H 108 x x 1676 y 0 W 70 H 108 y x 1750 y 0 W 69 H 108 z x 1821 y 0 W 61 H 108 I have a class that has x, y, Width, Height members and I want to put the info from this file into the objects of that class. There should be 1 object per letter, so for example: object['a'].x = 37. Does anybody know how to do it? Thanks, Merlino.
  6. So does anybody know how to turn the antialiasing on?
  7. Alright, alright. So this means I won't be able to use a per letter glow right? Unless I combine all the glows of the letters of the text in one single texture while program is running. Do you think this could be a good solution?
  8. Quote:Original post by Falhar i think using texture for each letter is litle bit overkill. Are you sure? I tried to check the fps of the scene and, even with a line full of letters, they don't go under 999. Ok, the scene is rather simple and my computer is quite powerful (AMDX2 3800+,x800GTO2), but 999 fps is a lot (I'm using fraps for benchmarking and I think 999 is the max it can record). But this is not the point, I was not especially talking about fonts being aliased but just textures in general. Anyway thanks, I'll give a try to http://www.angelcode.com/products/bmfont/
  9. I've looked a bit on google for the truetype font rendering, and I am not sure that this is what I should use because I want to put some glows to the words I made later on, using a per letter glow, and it would be a lot easyer to do it having the letter drawn as a texture... Anyway, you said I should use Antialiasing: I looked for some tutos about it on google but I did not find how to turn it on. So how do I turn on antialiasing? As for mipmaps, you say I should do this right?: glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 212,212,0,GL_RGB, GL_UNSIGNED_BYTE, texObject0); glTexImage2D(GL_TEXTURE_2D, 1, GL_RGB, 106,106,0,GL_RGB, GL_UNSIGNED_BYTE, texObject1); glTexImage2D(GL_TEXTURE_2D, 2, GL_RGB, 52,52,0,GL_RGB, GL_UNSIGNED_BYTE, texObject2); glTexImage2D(GL_TEXTURE_2D, 3, GL_RGB, 26,26,0,GL_RGB, GL_UNSIGNED_BYTE, texObject3); glTexImage2D(GL_TEXTURE_2D, 4, GL_RGB, 12,12,0,GL_RGB, GL_UNSIGNED_BYTE, texObject4); ... and so on. For the mipmaps do I have to tell the App which one to use based on the font size or does it do it by himself? And are the GL_TEXTURE_MIN/MAG_FILTER useful as I set them ? Thanks
  10. I'm creating an App for displaying text through openGL textures. I decided to create a .tga image for every letter and I made them rather big (213x213 pix) so that I could render large words on screen. The problem comes when I render small words, say 0.1 of the original image size, the letters appear rather aliased. Aliased Textures Yes, it is not THAT aliased, but I'm sure there is a way to render it better, I just don't know how to do it. I read about Mipmaps but they are only useful when the scene is not static. Anyway, I used the gluBuild2DMipmaps function to create the textures so this should not be the problem. As for the GL_TEXTURE_MAG_FILTER, I used GL_LINEAR and GL_LINEAR_MIPMAP_LINEAR for the GL_TEXTURE_MIN_FILTER. So how can I anti-alias these textures? Thanks in advance, Merlino
  11. what is glsl? Anyway isn't there a simple way to do this?
  12. Hi, I am quite new to OpenGL and I was trying to render some textures using multitexturing... So, I have 2 24-bit targa images loaded in 2 different texture objects.. The first image is a grayscale image and the second one a colored image. So lets say: image1 = grayscale -> objectname = Alpha image2 = colored -> objectname = RGB What I wanted to do was to create a texture using the Alpha object as a alpha value and the RGB object as a RGB value... So here's how I set up the textures: Init() { glActiveTexture(GL_TEXTURE0); glEnable(GL_TEXTURE_2D); Alpha = genTexture("grayscaleImage", true); glActiveTexture(GL_TEXTURE1); glEnable(GL_TEXTURE_2D); RGB = genTexture("coloredImage", true); } genTexture(char * filename, bool mipmaps) { if (filename != NULL) this->Load(filename); glGenTextures(1, &this->textureObject); glBindTexture(GL_TEXTURE_2D, this->textureObject); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); if (mipmaps == true) gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, this->GetWidth(), this->GetHeight(), GL_RGB, GL_UNSIGNED_BYTE, this->GetImage()); else glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, this->GetWidth(), this->GetHeight(), 0, GL_RGB, GL_UNSIGNED_BYTE, this->GetImage()); return this->textureObject; } Next I tried to use the glTexEnvf() also with GL_COMBINE but with no result, as I didn't really undestand how the different function values work.. ^^ I'm sure I have to use this function in order to make the texturing work, but i don't know how to do it. Can anybody tell me? Thanks, Merlino. [Edited by - Merlino on October 21, 2006 12:31:41 PM]
  13. Merlino

    Char* string: How To??

    Ok, one thing and then I'm done: In my program, instead of outputing the string with cout I need to use a the OpenGL renderFont function; Point is it only accepts a char* value; So, to "convert" the string I tried to use .c_str(); Assuming that inputText is a std::string that's what I wrote: font->RenderFont(0, 0, font->m_fontListBase, inputText.c_str()); If I use this function I get an error saying: "Invalid conversion from const char* to char*" It smells like this has also been answered a million times.. ..I'm sorry ^^. Problem Solved !!! Changing the value type renderFont accepts from char* to const char* worked. Again, thanks a lot for you patience and sorry for my ignorance. Merlino
  14. Merlino

    Char* string: How To??

    Quote:Original post by Emmanuel Deloget The other people are right, but this doesn't disallow you to use this litteral constant in your code. Remember that it's type is not "char*" but "const char*" and that you should not modify it by any mean and you're quite safe. Actually, no, you are not that safe. As pointed out by both our lovely Zahlman and our dedicated Enigma, in C++ you should use std::string and its methods, not char* strings and a bunch of unsecure and obsolete C functions. I repeat it and underline it: use std::string. (There is a missing C++ by the way. C doesn't have std::string [smile]) It's ok, I got it :D I understood, I just wanted to know a bit more .. just for culture. I'll use arrays, just like text1 and text2 in nobodynews reply. Thanks again. PS: Emm, does anybody know where I can find any std::string tutorials? I've looked on google but, since I live in france.. it gets to google.fr and I can't find much.. ^^
  • 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!