Skip to content

Commit

Permalink
Version 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
syby119 committed Sep 18, 2022
1 parent 7a1e073 commit 4249477
Show file tree
Hide file tree
Showing 168 changed files with 21,444 additions and 493 deletions.
5 changes: 4 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@
*.sh text eol=lf

*.doc -text
*.pptx -text
*.pdf -text
*.jpg -text
*.jpeg -text
*.png -text
*.hdr -text
*.bmp -text
*.obj -text
*.pdf -text
*.gltf text
*.dll -text
*.lib -text
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/*
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ set_target_properties(tinygltf PROPERTIES FOLDER "lib")
add_subdirectory(./projects/get_start)
set_target_properties(get_start PROPERTIES FOLDER "demo")

# add_subdirectory(./projects/pbr_viewer)
# set_target_properties(pbr_viewer PROPERTIES FOLDER "demo")
add_subdirectory(./projects/pbr_viewer)
set_target_properties(pbr_viewer PROPERTIES FOLDER "demo")

add_subdirectory(./projects/project1)
set_target_properties(project1 PROPERTIES FOLDER "project")
Expand Down
Binary file modified demo/screenshots/bonus1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified demo/screenshots/bonus2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added demo/screenshots/pbr_viewer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified demo/screenshots/project5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified demo/screenshots/project6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified demo/winexe/bonus1.exe
Binary file not shown.
Binary file modified demo/winexe/bonus2.exe
Binary file not shown.
Binary file modified demo/winexe/get_start.exe
Binary file not shown.
Binary file added demo/winexe/pbr_viewer.exe
Binary file not shown.
Binary file modified demo/winexe/project1.exe
Binary file not shown.
Binary file modified demo/winexe/project2.exe
Binary file not shown.
Binary file modified demo/winexe/project3.exe
Binary file not shown.
Binary file modified demo/winexe/project4.exe
Binary file not shown.
Binary file modified demo/winexe/project5.exe
Binary file not shown.
Binary file modified demo/winexe/project6.exe
Binary file not shown.
Binary file added doc/3d rotation.pdf
Binary file not shown.
Binary file added doc/a tour of OpenGL.pptx
Binary file not shown.
15 changes: 15 additions & 0 deletions doc/c++ tutorial/1. new grammer/1. input and output/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <stdio.h>

int main() {
char name[80];
unsigned int number;

printf("Input name: ");
scanf("%s", name);
printf("Input school number: ");
scanf("%u", &number);

printf("Greetings from %s(%u).\n", name, number);

return 0;
}
15 changes: 15 additions & 0 deletions doc/c++ tutorial/1. new grammer/1. input and output/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <iostream>
#include <string>

int main() {
std::string name;
unsigned int number;

std::cout << "Input name: ";
std::cin >> name;
std::cout << "Input school number: ";
std::cin >> number;
std::cout << "Greetings from " << name << "(" << number << ")." << std::endl;

return 0;
}
53 changes: 53 additions & 0 deletions doc/c++ tutorial/1. new grammer/2. reference/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#include <stdio.h>

void update(int* p, int value) {
*p = value;
}

void example1() {
int i = 0;
int* iPtr = &i;

printf("Example1: refence as aliasing\n");

printf("1. Initial state\n");
printf("i: %d\n", i);
printf("*iPtr: %d\n\n", *iPtr);

printf("2. Change i value\n");
i = 100;
printf("i: %d\n", i);
printf("*iPtr: %d\n\n", *iPtr);

printf("3. Change the value iPtr pointing to\n");
*iPtr = 200;
printf("i: %d\n", i);
printf("*iPtr: %d\n\n", *iPtr);
}

void example2() {
int i = 0;
int* iPtr = &i;

printf("Example2: refence as function parameters\n");
printf("1. Initial state\n");
printf("i: %d\n", i);
printf("*iPtr: %d\n\n", *iPtr);

printf("2. Pass the address of i to update\n");
update(&i, 100);
printf("i: %d\n", i);
printf("*iPtr: %d\n\n", *iPtr);

printf("3. Pass iPtr to update\n");
update(iPtr, 200);
printf("i: %d\n", i);
printf("*iPtr: %d\n\n", *iPtr);
}

int main() {
example1();
example2();

return 0;
}
53 changes: 53 additions & 0 deletions doc/c++ tutorial/1. new grammer/2. reference/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#include <iostream>

void update(int& ref, int value) {
ref = value;
}

void example1() {
int i = 0;
int& iRef = i;

std::cout << "Example1: refence as aliasing" << std::endl;

std::cout << "1. Initial state" << std::endl;
std::cout << "i: " << i << std::endl;
std::cout << "iRef: " << iRef << '\n' << std::endl;

std::cout << "2. Change i value" << std::endl;
i = 100;
std::cout << "i: " << i << std::endl;
std::cout << "iRef: " << iRef << '\n' << std::endl;

std::cout << "3. Change iRef value" << std::endl;
iRef = 200;
std::cout << "i: " << i << std::endl;
std::cout << "iRef: " << iRef << '\n' << std::endl;
}

void example2() {
int i = 0;
int& iRef = i;

std::cout << "Example2: refence as function parameters" << std::endl;
std::cout << "1. Initial state" << std::endl;
std::cout << "i: " << i << std::endl;
std::cout << "iRef: " << iRef << '\n' << std::endl;

std::cout << "2. Pass i to update" << std::endl;
update(i, 100);
std::cout << "i: " << i << std::endl;
std::cout << "iRef: " << iRef << '\n' << std::endl;

std::cout << "3. Pass iRef to update" << std::endl;
update(iRef, 200);
std::cout << "i: " << i << std::endl;
std::cout << "iRef: " << iRef << '\n' << std::endl;
}

int main() {
example1();
example2();

return 0;
}
43 changes: 43 additions & 0 deletions doc/c++ tutorial/1. new grammer/3. dynamic memory issue/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include <stdio.h>
#include <stdlib.h>

#define N 10

typedef struct Student {
char name[80];
int age;
} Student;

void example1() {
printf("Example1: dynamic object\n");
int* i = (int*)malloc(sizeof(int));

*i = 100;
printf("i = %d\n\n", *i);

free(i);
}

void example2() {
printf("Example2: dynamic array\n");
Student* students = (Student*)malloc(sizeof(Student) * N);

for (int i = 0; i < N; ++i) {
students[i].name[0] = (char)('A' + i);
students[i].name[1] = '\0';
students[i].age = 20 + i;
}

for (int i = 0; i < N; ++i) {
printf("students[%d] = { %s, %d }\n", i, students[i].name, students[i].age);
}

free(students);
}

int main() {
example1();
example2();

return 0;
}
43 changes: 43 additions & 0 deletions doc/c++ tutorial/1. new grammer/3. dynamic memory issue/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include <iostream>
#include <string>

constexpr int N = 10;

struct Student {
std::string name;
int age;
};

void example1() {
printf("Example1: dynamic object\n");
int* i = new int;

*i = 100;
std::cout << "i = " << *i << '\n' << std::endl;

delete i;
}

void example2() {
printf("Example2: dynamic array\n");
Student* students = new Student[N];

for (int i = 0; i < N; ++i) {
students[i].name = std::string(1, (char)('A' + i));
students[i].age = 20 + i;
}

for (int i = 0; i < N; ++i) {
std::cout << "students[" << i << "] = { "
<< students[i].name << ", " << students[i].age << " }" << std::endl;
}

delete[] students;
}

int main() {
example1();
example2();

return 0;
}
34 changes: 34 additions & 0 deletions doc/c++ tutorial/1. new grammer/4. operator overloading/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include <stdio.h>

typedef struct Vector3f {
float x, y, z;
} Vector3f;

Vector3f add(const Vector3f* lhs, const Vector3f* rhs) {
Vector3f result;
result.x = lhs->x + rhs->x;
result.y = lhs->y + rhs->y;
result.z = lhs->z + rhs->z;

return result;
}

void print(const Vector3f* v) {
printf("(%.3f, %.3f, %.3f)", v->x, v->y, v->z);
}

int main() {
Vector3f v1 = { 1.0f, 0.0f, 0.0f };
Vector3f v2 = { 0.0f, 1.0f, 0.0f };

Vector3f v = add(&v1, &v2);

print(&v1);
printf(" + ");
print(&v2);
printf(" = ");
print(&v);
printf("\n");

return 0;
}
30 changes: 30 additions & 0 deletions doc/c++ tutorial/1. new grammer/4. operator overloading/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include <iostream>

struct Vector3f {
float x, y, z;
};

Vector3f operator+(const Vector3f& lhs, const Vector3f& rhs) {
Vector3f result;
result.x = lhs.x + rhs.x;
result.y = lhs.y + rhs.y;
result.z = lhs.z + rhs.z;

return result;
}

std::ostream& operator<<(std::ostream& os, const Vector3f& v) {
os << "(" << v.x << ", " << v.y << ", " << v.z << ")";
return os;
}

int main() {
Vector3f v1 = { 1.0f, 0.0f, 0.0f };
Vector3f v2 = { 0.0f, 1.0f, 0.0f };

Vector3f v = v1 + v2;

std::cout << v1 << " + " << v2 << " = " << v << std::endl;

return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#include <stdio.h>
#include "person.h"

int main() {
/* default constructor */ {
printf("Init person\n");
Person p;
initPersonDefault(&p);

printPersonInfo(&p);
}

/* constructor with name and age */ {
printf("\nInit person with name and age\n");
Person p;
initPerson(&p, "Ben", 27);

printPersonInfo(&p);
}

/* copy constructor */ {
printf("\nInit person with another person\n");
Person q;
initPerson(&q, "Sarah", 23);

Person p;
initPersonCopy(&p, &q);

printPersonInfo(&p);
}

/* assign operator */ {
printf("\nAssign person with another person\n");
Person p, q;
initPerson(&p, "Ben", 27);
initPerson(&q, "Sarah", 23);

assignPerson(&p, &q);

printPersonInfo(&p);
}

/* get info */ {
printf("\nGet test\n");
Person p;
initPerson(&p, "Ben", 27);
printf("name: %s\n", getPersonName(&p));
printf("age: %d\n", getPersonAge(&p));
}

/* set info */ {
printf("\nSet test\n");
Person p;
initPerson(&p, "Ben", 27);
setPersonName(&p, "NEW NAME");
setPersonAge(&p, 100);
printPersonInfo(&p);
}

return 0;
}
Loading

0 comments on commit 4249477

Please sign in to comment.