Most likely, the compiler doesn't know what the type vglTex is - you need to include the appropriate header file for that class.
--
Mats
Most likely, the compiler doesn't know what the type vglTex is - you need to include the appropriate header file for that class.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
i wanna define that object in vurtialGL.cpp and the class is defined in virtualGL.h
i dont include that file, because it is automaticly included isnt it?
well you see the source code i uploaded lately (..._demo3.zip)
what is it that i'm doing wrong? i think i might mis understood the usage of header files as well as several other mistakes... tell me please
Last edited by Devils Child; 01-30-2008 at 09:11 AM.
No, there are no "automatically included" header files - anywhere.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
these include issues are so over complicated... what exactly does every of these 7 files include?
Includes are not complicated. You must simply include a file that contains a declaration of definition of what you're trying to use.
So make a vglTex.cpp file to contain the implementation. The source file should include vglTex.h, which contains the class definition, and all files that uses the class vglTex should also include vglTex.h.
dont know what i am doing wrong but it sure is my fault: i mean, i'm not very sure about all this. this works well, but as soon as i need classes, everything stops working well...
sample.cppvirtualGL.cppCode:#include <string> #include "SDL/SDL.h" #include "VGL-Inc/VirtualGL.h" #include "VGL-Inc/Matrix.h" #include "VGL-Inc/Utility.h"virtualGL.hCode:#include <string> #include <time.h> #include "SDL/SDL.h" #include "Matrix.h" #include "Utility.h"matrix.cppCode:#include "SDL/SDL.h" #include "Utility.h"matrix.hCode:#include "VirtualGL.h"utility.cppCode://utility.hCode:#include "SDL/SDL.h"Code://nothing included here
Last edited by Devils Child; 01-30-2008 at 09:37 AM.
yes it is.
anyhow... what do you want me to do now that you see my include structure?
Split the class into its own files.
If you include the correct header and it still isn't working, then either your compiler is broken (unlikely) or you have circular dependencies - ie file A includes file B and file B includes file A.
Plus if you split it, it will much easier to debug what it isn't working if it's not working.
hey cool man
it's working when i use an external header file for the class
thanks again
i'll be here when something doesnt work again and i dont get it.
oh there is another tricky problem (sorry):
VirtualGL.cpp:Classes.h:Code:vglTexture *vglTextur;of course the vglTexture variable is not defined at this point, but it can not be defined there because the class doesnt even exist yet...Code:class vglTexture { private: public: int w, h, buf[257][257]; void LoadFromFile(char path[]) { SDL_Surface *image = SDL_LoadBMP(path); w = image->w; h = image->h; if (w > 256) w = 256; if (h > 256) h = 256; for (int y = 0; y <= h; y++) { for (int x = 0; x <= w; x++) { buf[x][y] = GetPixel(image, x, y); } } SDL_FreeSurface(image); } void SetActive() { >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> vglTextur = this; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> } };
i guess there is a pretty easy solution for this umh...
This is very bad programming. Do not use global variables and using a class to set an active global pointer is just another bad programming step.
Objects are self-contained. They do all the necessary work to function and expose interfaces for the programmer to work with them. There shouldn't be a SetActive function to set a global pointer to this class there.
Each function that works with such a class should instead take an argument to a vglTexture object, and not use a global "active" pointer.
And I stressed this before, implement the functions in the source file, not the header.
sure it is bad programming, but how does the program know which texture is the active one?
you mean that i should add a parameter to the texture class such as "bool active;" ? how would that work? i dont even know how to iterate trough classes
By doing something like "ActiveTexture = SomeTexture;"
Most graphics environments have a "Graphics Context", which is some sort of object/structure that contains "everything current" (or active to use your term). There are calls to "SetActiveXXXX", where XXX may be texture, pen/brush, etc, etc.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.