본문 바로가기

College Study77

[GLSL] Uniform https://thebookofshaders.com/03/ The Book of Shaders Gentle step-by-step guide through the abstract and complex universe of Fragment Shaders. thebookofshaders.com #ifdef GL_ES precision mediump float; #endif uniform vec2 u_resolution; // Canvas size (width,height) uniform vec2 u_mouse; // mouse position in screen pixels uniform float u_time; // Time in seconds since load void main() { gl_FragCol.. 2022. 1. 5.
[GLSL] Hello World https://thebookofshaders.com/02/ The Book of Shaders Gentle step-by-step guide through the abstract and complex universe of Fragment Shaders. thebookofshaders.com #ifdef GL_ES precision mediump float; #endif void main() { gl_FragColor = vec4(1.0,0.0,1.0,1.0); } 1. Shader Language is C-flavored language. 2. The final pixel color is assigned to the reserved global variable gl_FragColor. 3. Shader .. 2022. 1. 5.
[GLSL] What is a shader? https://thebookofshaders.com/01/ The Book of Shaders Gentle step-by-step guide through the abstract and complex universe of Fragment Shaders. thebookofshaders.com Shaders are also a set of instructions, but the instructions are executed all at once for every single pixel on the screen. That means the code you write has to behave differently depending on the position of the pixel on the screen. L.. 2022. 1. 5.
[GLSL] Let's Dive in to the Shader! I wanted to study graphics languages (especially shaders), but I was worried about which language to choose between OpenGL and DirectX. I am currently using a MacBook and would like to use an online tutorial which name is "The Book of Shaders". Furthermore, in fact, GLSL and HLSL are similar to each other except for a few syntax... so I finally decided to study OpenGL shaders. As I mentioned, I .. 2022. 1. 5.
[C++] C++ 11/14/17/... New STL (ENG) Unordered Map std::unordered_map std::unordered_multimap // std::map #include #include #include int main() { std::map scores; scores["Nana"] = 60; scores["Mocha"] = 70; scores["Coco"] = 100; for (auto it = scores.begin(); it != scores.end(); ++it) { std::cout first 2022. 1. 2.
[C++] C++ 11/14/17/... New Types (ENG) nullptr The old C style of NULL is a number. // Class.h float GetScore(const char* name); // meant to call this float GetScore(int id); // actual // Main.cpp #define NULL 0 Class* myClass = new Class("COMP3100"); // ... int score = myClass->GetScore(NULL); So in C++ 11, you can use nullptr as a pointer. typedef decltype(nullptr) nullptr_t; // null pointer constant int number = NULL; // OK int* p.. 2022. 1. 2.
[C++] C++ 11/14/17/... New Keywords (ENG) auto The keyword auto infers the data type automatically. It is not a dynamic type (like var of JavaScript). So you need to initialize auto's variables. auto x; // error auto x = "Chris"; // OK auto x = 50; // error It can get values, pointers, and even references (and so on). auto for pointers can omit *, but it's better to use * for readability of programmers. Reference types must use & so tha.. 2022. 1. 2.
[C++] Template Programming (ENG) Function Template STL container is also a template. With template, you don't have to write codes in duplicate. template // typename can be replaced with class (even if it is not a class) T Add(T a, T b) { return a + b; } Function template is a template for functions. You can skip the template parameter. Add (3,10); Add (3,10); There's not the difference between typename and class, so I'll use ty.. 2022. 1. 2.
[C++] Purpose of STL Container (ENG) the Purpose STL container has a standard interface that can be applied to every container. - It is a little weird. Extremely object-oriented. std::vector scores; scores.push_back(10); // seems like a stack std::list ages; ages.push_back(100); // seems like a stack std algorithms work in many containers. It is based on template programming. It allows the memory to be menaged automatically. - Freq.. 2022. 1. 2.