// -*-C++-*- #include #define FPARAM(name, default) float name = params->getFloat(#name, default); void GENERATE(TextureParam *params, int width, int height, int depth, int components, float *data) { FPARAM(bias, 0); FPARAM(scale, 1); FPARAM(radius, 0.75); FPARAM(line_width, 2); int ind=0, i, j; float x, y; float xstep = 1.0 / width; float ystep = 1.0 / height; ind = 0; for (j = 0, y = 0; j < height; j++, y += ystep) { for (i = 0, x = 0; i < width; i++, x += xstep) { float c = 0.5, a = 1; if (j < height/2 + line_width) c = 0; if (j < height/2) c = 1; //a = 1; //c = y; if (components >= 1) data[ind++] = c * scale + bias; if (components >= 2) data[ind++] = c * scale + bias; if (components >= 3) data[ind++] = c * scale + bias; if (components >= 4) data[ind++] = a * scale + bias; } } }