erzeugung vom ersten test image. farbuebergang rot und gruen.

This commit is contained in:
any
2026-07-19 19:14:42 +02:00
parent 22af45e1c9
commit ff8c8a2bdc
9 changed files with 20440 additions and 4 deletions
Generated
+1
View File
@@ -2,5 +2,6 @@
<project version="4"> <project version="4">
<component name="VcsDirectoryMappings"> <component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" /> <mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="$PROJECT_DIR$/stb" vcs="Git" />
</component> </component>
</project> </project>
+3 -1
View File
@@ -3,4 +3,6 @@ project(Raytracer C)
set(CMAKE_C_STANDARD 23) set(CMAKE_C_STANDARD 23)
add_executable(Raytracer main.c) add_executable(Raytracer main.c
examples.c
examples.h)
+19
View File
@@ -0,0 +1,19 @@
//
// Created by ary on 19.07.2026.
//
#include "examples.h"
void example_color(int width, int height, int channels, unsigned char *image) {
for (int i = 0; i < height * width; i++) {
int step = i *channels;
int x = i % width;
int y = i / width;
image[step] = 0 + (int)((((double)x)/width) * 255);
image[step+1] = 0 + (int)((((double)y)/width) * 255);
image[step+2] = 0;
if (channels == 4) {
image[step+3] = 255;
}
}
}
+9
View File
@@ -0,0 +1,9 @@
//
// Created by ary on 19.07.2026.
//
#ifndef RAYTRACER_EXAMPLES_H
#define RAYTRACER_EXAMPLES_H
#endif //RAYTRACER_EXAMPLES_H
void example_color(int, int, int, unsigned char *);
+16 -2
View File
@@ -1,6 +1,20 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image/stb_image.h"
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "stb_image/stb_image_write.h"
#include "examples.h"
int main() {
int width = 1280;
int height = 780;
int channels = 4;
unsigned char *image = (unsigned char*)malloc(width * height * channels );
example_color(width, height, channels, image);
stbi_write_png("C:/Users/ary/CLionProjects/Raytracer/test.png", width, height, channels, image, width * channels);
free(image);
int main(void) {
printf("Hello, Worldd!\n");
return 0; return 0;
} }
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB