Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void render(unsigned int width, unsigned int height)
- {
- // Allocate space for target image
- float *pixel_data = new float[width * height * 3];
- // Do other stuff
- // Main rendering loop
- float calculated_data[3];
- for (unsigned int y = 0; y < height; ++y)
- {
- for (unsigned int x = 0; x < width; ++x)
- {
- // Calculate stuff
- // and store in calculated_data
- // Write pixel
- unsigned int pixel_index = (x + y*width)*3;
- pixel_data[pixel_index + 0] = calculated_data[0];
- pixel_data[pixel_index + 1] = calculated_data[1];
- pixel_data[pixel_index + 2] = calculated_data[2];
- }
- }
- // Write image to png/bmp/...
- // Free memory (would be WAY more involved for a 3D array)
- delete [] pixel_data;
- }
Add Comment
Please, Sign In to add comment