erzeugung vom ersten test image. farbuebergang rot und gruen.
This commit is contained in:
Generated
+1
@@ -2,5 +2,6 @@
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/stb" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
+3
-1
@@ -3,4 +3,6 @@ project(Raytracer C)
|
||||
|
||||
set(CMAKE_C_STANDARD 23)
|
||||
|
||||
add_executable(Raytracer main.c)
|
||||
add_executable(Raytracer main.c
|
||||
examples.c
|
||||
examples.h)
|
||||
|
||||
+19
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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 *);
|
||||
@@ -1,6 +1,20 @@
|
||||
#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;
|
||||
}
|
||||
}
|
||||
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
Reference in New Issue
Block a user