A very simple question is that I need a library for writing raw pixels similar to ByteBuffers in Java (if you are familiar with that), using
a sort of image object, that can be used with the method of pixel drawing (with some raytracing stuff) that I will demonstrate.
The way I raytrace is by writing the rayOrgin, discriminant, and returning the color in a function named PerPixel of type int with a 2-float Vector named "coord" and then suppling the data to the image data via a nested for loop.
This is what it should look like:
for (int y = 0; y < IMAGE_WIDTH; y++)
{
for (int y = 0; y < IMAGE_HEIGHT; y++)
{
Vector2f coord = { x / (float) IMAGE_WIDTH, y / (float) IMAGE_HEIGHT };
imageData[x + y * IMAGE_WIDTH] = PerPixel(coord);
}
}
int PerPixel(Vector2f coord)
{
if (discriminant >= 0)
return 0xffff00ff;
return 0xff000000;
}
What I have tried:
I have tried SDL however when I did the image creation correctly, it just failed when I gone to the raytracing part. I've tried OpenGL
instead but this time it gave me an exception when tried to create an image using VAOs, VBOs, TBOs and etc.
Except for image creation, I don't need any big tutorial, just a code snippet of something similar to the code snippet that I showed earlier working with a library (and also obviously give me the name of the library).