why would that cause a stack overflow? - i mean, i need some bytes to store the texture. accessing the texture via the image would be slow....
so what else should i use instead of an array?
and what's about the class problem? :P
why would that cause a stack overflow? - i mean, i need some bytes to store the texture. accessing the texture via the image would be slow....
so what else should i use instead of an array?
and what's about the class problem? :P
Well, the stack is limited to about 2MB, so if you create a local variable of 1MB+, you have already used up half the stack in one fell swoop. Better to use a heap-allocation (new), and free it after use (delete).
--
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.
whats that? is that a kind of array that is as fast as one?
because i need to store the texture in some sort of array.
in basic it would beCode:CreateBank() FreeBank() PokeInt(...) PeekInt(...)
Oh gods. You don't even know about the heap?
http://www.cprogramming.com/tutorial...eory/heap.html
http://www.cprogramming.com/tutorial/lesson6.html
Long story short (KISS), the stack is the stack and the heap is the computer RAM.
you can use vector instead of array. It will allocate memory dynamically and handle it for you
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
hm ok. this seems better than an array.
but there is still one question open: how do i do that thing with the classes?
you said that i need to define the class in the virtualGL.h file and write it's functions to virtualGL.cpp
but then the compiler says something like "___CLASS_NAME___ is not a class"
umh...
i did show the code here lately, but i will upload it again with the class
http://www.dev-ch.de/upload/files/De...lGL2_Demo3.zip (1.64 MB)
the class is called "vglTex" and is my texture class. if i get how it works, i will implement a matrix and a program class.
this code how it is gives me this error log:and you just told me that it would work.Code:1>------ Build started: Project: VirtualGL, Configuration: Debug Win32 ------ 1>Compiling... 1>Matrix.cpp 1>d:\martin\progs\c++\virtualgl\vgl-inc\virtualgl.h(6) : error C2065: 'SDL_Surface' : undeclared identifier 1>d:\martin\progs\c++\virtualgl\vgl-inc\virtualgl.h(6) : error C2065: 'image' : undeclared identifier 1>d:\martin\progs\c++\virtualgl\vgl-inc\virtualgl.h(6) : error C3861: 'SDL_LoadBMP': identifier not found 1>d:\martin\progs\c++\virtualgl\vgl-inc\virtualgl.h(7) : error C2227: left of '->w' must point to class/struct/union/generic type 1> type is ''unknown-type'' 1>d:\martin\progs\c++\virtualgl\vgl-inc\virtualgl.h(8) : error C2227: left of '->h' must point to class/struct/union/generic type 1> type is ''unknown-type'' 1>d:\martin\progs\c++\virtualgl\vgl-inc\virtualgl.h(11) : error C3861: 'GetPixel': identifier not found 1>d:\martin\progs\c++\virtualgl\vgl-inc\virtualgl.h(14) : error C3861: 'SDL_FreeSurface': identifier not found 1>Sample.cpp 1>d:\martin\progs\c++\virtualgl\vgl-inc\virtualgl.h(11) : error C3861: 'GetPixel': identifier not found 1>d:\martin\progs\c++\virtualgl\vgl-inc\utility.h(2) : error C2365: 'GetPixel' : redefinition; previous definition was 'formerly unknown identifier' 1>Generating Code... 1>Build log was saved at "file://d:\Martin\Progs\C++\VirtualGL\Debug\BuildLog.htm" 1>VirtualGL - 9 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
to the headers: i always thought that the function should be declared in the header file? or what else would it be good for??
anyway, how do i finally get this class working in every cpp file?
It does work. You're just not doing it right. The header VirtualGL.h obviously needs to include other heads, specifically the SDL headers that contains the SDL_Surface header.
It's very, very easy:
Code:// Definition in .h file class CFoo { public: void foo(int foo); }; // Implementation - .cpp file. void CFoo::foo(int foo) { // My code }
oki now it's finaly working!
great job guys! thanks a lot
oh wait! when i declare an object of the class vglTex like this:, the compiler tells meCode:vglTex tex;what does that mean?syntax error : missing ';' before identifier 'tex'
Usually means the compiler doesn't know what vglText is, so it thinks there must a ; after it.
Which in essence means you haven't shown the compiler the class (or type) definition, which probably means you've probably not included the correct header.