Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Graphics/Aman/camera.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#ifndef CAMERAH
#define CAMERAH

#include "ray.h"

class camera {
public:
camera() {
lower_left_corner = vec3(-2.0,-1.0,-1.0);
horizontal = vec3(4.0,0.0,0.0);
vertical = vec3(0.0,2.0,0.0);
origin = vec3(0.0,0.0,0.0);
}
ray get_ray(float u, float v) { return ray(origin, lower_left_corner+u*horizontal+v*vertical - origin);}

vec3 lower_left_corner;
vec3 origin;
vec3 vertical;
vec3 horizontal;
};

#endif
24 changes: 24 additions & 0 deletions Graphics/Aman/chap1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <fstream>
#include <iostream>

int main(){
int nx=200;
int ny=100;
std::ofstream fout("chap1.ppm");
if(fout.fail()) return -1;

fout <<"P3\n" << nx << " " << ny << "\n255\n";
for(int j= ny-1;j>=0;j--){
for(int i=0;i<nx;i++){
float r = float(i)/float(nx);
float g = float(j)/float(ny);
float b = 0.2;
int ir= int(255.99*r);
int ig = int(255.99*g);
int ib = int(255.99*b);
fout<< ir <<" "<<ig<<" "<<ib<<"\n";
}
}
std::cout<<"Successful\n";
return 0;
}
Binary file added Graphics/Aman/chap1.exe
Binary file not shown.
Loading