Skip to content

Commit

Permalink
ass1
Browse files Browse the repository at this point in the history
  • Loading branch information
kybeka committed Sep 16, 2024
1 parent 00ae839 commit 8446e3d
Show file tree
Hide file tree
Showing 385 changed files with 61,302 additions and 0 deletions.
Binary file added assignment 1/assignment 1.pdf
Binary file not shown.
98 changes: 98 additions & 0 deletions assignment 1/template/Image.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
//
/**
@file Image.h
*/


// Image.h
// Raytracer
//
// Created by Piotr Didyk on 14.07.21.
//

#ifndef Image_h
#define Image_h

using namespace std;

/**
Class allowing for creating an image and writing it to a file
*/
class Image{

private:
int width, height; ///< width and height of the image
int *data; ///< a pointer to the data representing the images

public:
/**
@param width with of the image
@param height height of the image
*/
Image(int width, int height): width(width), height(height){
data = new int[3*width*height];
}

/**
Writes and image to a file in ppm format
@param path the path where to the target image
*/
void writeImage(const char *path){
ofstream file;
file.open(path);
file << "P3" << endl;
file << width << " " << height <<endl;
file << 255 << endl;
for(int h = 0; h < height; h++){
for (int w = 0; w < width; w++){
file << data[3 * (h*width + w)] <<" ";
file << data[3 * (h*width + w) + 1] <<" ";
file << data[3 * (h*width + w) + 2] << " ";
}
file<<endl;
}
file.close();
}

/**
Set a value for one pixel
@param x x coordinate of the pixel - index of the column counting from left to right
@param y y coordinate of the pixel - index of the row counting from top to bottom
@param r red chanel value in range from 0 to 255
@param g green chanel value in range from 0 to 255
@param b blue chanel value in range from 0 to 255
*/
void setPixel(int x, int y, int r, int g, int b){
data[3 * (y*width + x)] = r;
data[3 * (y*width + x) + 1] = g;
data[3 * (y*width + x) + 2] = b;
}

/**
Set a value for one pixel
@param x x coordinate of the pixel - index of the column counting from left to right
@param y y coordinate of the pixel - index of the row counting from top to bottom
@param r red chanel value in range from 0 to 1
@param g green chanel value in range from 0 to 1
@param b blue chanel value in range from 0 to 1
*/
void setPixel(int x, int y, float r, float g, float b){
data[3 * (y*width + x)] = (float)(255 * r);
data[3 * (y*width + x) + 1] = (float)(255 * g);
data[3 * (y*width + x) + 2] = (float)(255 * b);
}

/**
Set a value for one pixel
@param x x coordinate of the pixel - index of the column counting from left to right
@param y y coordinate of the pixel - index of the row counting from top to bottom
@param color color of the pixel expressed as vec3 of RGB values in range from 0 to 1
*/
void setPixel(int x, int y, glm::vec3 color){
data[3 * (y*width + x)] = (float)(255 * color.r);
data[3 * (y*width + x) + 1] = (float)(255 * color.g);
data[3 * (y*width + x) + 2] = (float)(255 * color.b);
}
};

#endif /* Image_h */
Binary file added assignment 1/template/a.out
Binary file not shown.
70 changes: 70 additions & 0 deletions assignment 1/template/glm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
file(GLOB ROOT_SOURCE *.cpp)
file(GLOB ROOT_INLINE *.inl)
file(GLOB ROOT_HEADER *.hpp)
file(GLOB ROOT_TEXT ../*.txt)
file(GLOB ROOT_MD ../*.md)
file(GLOB ROOT_NAT ../util/glm.natvis)

file(GLOB_RECURSE CORE_SOURCE ./detail/*.cpp)
file(GLOB_RECURSE CORE_INLINE ./detail/*.inl)
file(GLOB_RECURSE CORE_HEADER ./detail/*.hpp)

file(GLOB_RECURSE EXT_SOURCE ./ext/*.cpp)
file(GLOB_RECURSE EXT_INLINE ./ext/*.inl)
file(GLOB_RECURSE EXT_HEADER ./ext/*.hpp)

file(GLOB_RECURSE GTC_SOURCE ./gtc/*.cpp)
file(GLOB_RECURSE GTC_INLINE ./gtc/*.inl)
file(GLOB_RECURSE GTC_HEADER ./gtc/*.hpp)

file(GLOB_RECURSE GTX_SOURCE ./gtx/*.cpp)
file(GLOB_RECURSE GTX_INLINE ./gtx/*.inl)
file(GLOB_RECURSE GTX_HEADER ./gtx/*.hpp)

file(GLOB_RECURSE SIMD_SOURCE ./simd/*.cpp)
file(GLOB_RECURSE SIMD_INLINE ./simd/*.inl)
file(GLOB_RECURSE SIMD_HEADER ./simd/*.h)

source_group("Text Files" FILES ${ROOT_TEXT} ${ROOT_MD})
source_group("Core Files" FILES ${CORE_SOURCE})
source_group("Core Files" FILES ${CORE_INLINE})
source_group("Core Files" FILES ${CORE_HEADER})
source_group("EXT Files" FILES ${EXT_SOURCE})
source_group("EXT Files" FILES ${EXT_INLINE})
source_group("EXT Files" FILES ${EXT_HEADER})
source_group("GTC Files" FILES ${GTC_SOURCE})
source_group("GTC Files" FILES ${GTC_INLINE})
source_group("GTC Files" FILES ${GTC_HEADER})
source_group("GTX Files" FILES ${GTX_SOURCE})
source_group("GTX Files" FILES ${GTX_INLINE})
source_group("GTX Files" FILES ${GTX_HEADER})
source_group("SIMD Files" FILES ${SIMD_SOURCE})
source_group("SIMD Files" FILES ${SIMD_INLINE})
source_group("SIMD Files" FILES ${SIMD_HEADER})

add_library(glm INTERFACE)
target_include_directories(glm INTERFACE ../)

if(BUILD_STATIC_LIBS)
add_library(glm_static STATIC ${ROOT_TEXT} ${ROOT_MD} ${ROOT_NAT}
${ROOT_SOURCE} ${ROOT_INLINE} ${ROOT_HEADER}
${CORE_SOURCE} ${CORE_INLINE} ${CORE_HEADER}
${EXT_SOURCE} ${EXT_INLINE} ${EXT_HEADER}
${GTC_SOURCE} ${GTC_INLINE} ${GTC_HEADER}
${GTX_SOURCE} ${GTX_INLINE} ${GTX_HEADER}
${SIMD_SOURCE} ${SIMD_INLINE} ${SIMD_HEADER})
target_link_libraries(glm_static PUBLIC glm)
add_library(glm::glm_static ALIAS glm_static)
endif()

if(BUILD_SHARED_LIBS)
add_library(glm_shared SHARED ${ROOT_TEXT} ${ROOT_MD} ${ROOT_NAT}
${ROOT_SOURCE} ${ROOT_INLINE} ${ROOT_HEADER}
${CORE_SOURCE} ${CORE_INLINE} ${CORE_HEADER}
${EXT_SOURCE} ${EXT_INLINE} ${EXT_HEADER}
${GTC_SOURCE} ${GTC_INLINE} ${GTC_HEADER}
${GTX_SOURCE} ${GTX_INLINE} ${GTX_HEADER}
${SIMD_SOURCE} ${SIMD_INLINE} ${SIMD_HEADER})
target_link_libraries(glm_shared PUBLIC glm)
add_library(glm::glm_shared ALIAS glm_shared)
endif()
Loading

0 comments on commit 8446e3d

Please sign in to comment.