|
|
Before I post this in the bugs forum, I would like to check that I'm not doing anything painfully stupid - although I've programmed for a while I am very new to FLTK..
I am writing a simple drawing widget that will build up an image out of pixels which are calculated within the main body of code. Once a pixel is calculated (by some slow method, like a ray-tracer) it is sent to my widget which will store its colour in a local array, and display it. If the array is defined within the widget, I get a crash when compiling with GCC, if it is defined globally, the code is fine.
Here is the stripped down app which will crash every time for me:
//----------------------------------------------------------------------
#include <fltk/run.h>
#include <fltk/Window.h>
#include <fltk/Widget.h>
#include <fltk/math.h>
#include <fltk/draw.h>
using namespace fltk;
class Pictar : public Widget
{
public:
Pictar(int x,int y,int w,int h,const char *l=0) : Widget(x,y,w,h,l) {};
private:
double img[600][600];
};
int main(int argc, char **argv)
{
// create a window
Window window(600, 600);
window.begin();
// add a pictar widget that draws stuff
Pictar pic(0, 0, 600, 600);
// display the window
window.end();
window.show();
/*
* do some calculations to make an image..
*/
// tadaa!
return run();
}
//----------------------------------------------------------------------
Running Windows XP with half a gig of ram, I find this will crash every time. If img is reduced to an array of 600x400 the code will generate a white window, at 600x600 it crashes. Also, if img is moved to global scope, it will compile and run fine.
Does the problem lie with my code, my system, or FLTK in general?
Many thanks!
[ Direct Link to Message ] | |
|
| |