본문 바로가기

opengl16

[그래픽스] 공간(Local Space, World Space, Eye Space) 간 변환 * Computer Graphics Programming in OpenGL with C++ 책을 참고하였습니다. * 책을 번역한 것이 아닌, 제가 독학 후 책을 참고하여 설명하는 게시물입니다. 따라서 책에 없는 부연 설명이 있기도 하며, 의역 또는 오역, 오개념이 있을 수 있습니다. 피드백은 댓글을 남겨주세요. * 영어 용어를 최대한 한국어로 번역하지 않습니다. 처음부터 코드에서 사용되는, 또는 원서나 인터넷에서 사용되는 보편적 용어를 사용하여 개념을 잡는 것을 추천드립니다. Local Space OpenGL 또는 다른 프레임워크들로 3D 그래픽스를 사용하는 목적은 주로 3차원의 세상을 구현하고 그 속에 오브젝트를 배치하여 모니터로 보는 것입니다. 3D 오브젝트 모델을 처음 생성할 때에는, 모델을 가장 .. 2022. 3. 2.
[그래픽스] 2D 애니메이션 (니모를 찾는 니모 아빠와 도리) #include "cg.h" #include "draw.h" int w = 1000; int h = 1000; float t = 0.0; void display() { glClear(GL_COLOR_BUFFER_BIT); glClearColor(0.2, 0.2, 1.0, 1.0); // center glColor3f(0.2, 0.2, 1.0); rect(vector2D(-0.1, 0.1), vector2D(0.1, -0.1)); // Nemo's body glPushMatrix(); glRotatef(20.0 * t, 0.0, 0.0, 1.0); glTranslatef(0.0, 0.5 + 0.05 * sin(4 * t), 0.0); glColor3f(1.0, 0.6, 0.0); ellipse(vector.. 2022. 2. 9.
[그래픽스] 나만의 드로잉 2022. 2. 9.
[그래픽스] line.cpp 만들기 vec.h #pragma once #include #include #define M_PI 3.14159265358979323846 #define radians(x) x*M_PI/180.0 #define degrees(x) x*180.0/M_PI ////////////////////////////////////////////////////////////////////////////// // // 2D vector // ///////////////////////////////////////////////////////////////////////////// class vector2D { float x; float y; public: // // --- Constructors and Destructors ---.. 2022. 1. 28.
[GLSL] Translate https://thebookofshaders.com/08/ 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; uniform vec2 u_mouse; uniform float u_time; float bar (vec2 loc, vec2 size, vec2 coord){ vec2 lb = loc - size/2.; vec2 rt = loc + size/2.; vec2 st = step(lb, coord.. 2022. 1. 6.
[GLSL] Polar Shapes https://thebookofshaders.com/07/ The Book of Shaders Gentle step-by-step guide through the abstract and complex universe of Fragment Shaders. thebookofshaders.com A circle is a figure with the same radius regardless of the angle from the center. But this time, let's make a shape that changes the distance to the center according to the angle. Declare the variables a, d, and r in the default code... 2022. 1. 6.
[GLSL] Circle Shapes https://thebookofshaders.com/07/ The Book of Shaders Gentle step-by-step guide through the abstract and complex universe of Fragment Shaders. thebookofshaders.com Let's make mirrored circle wave. New default codes: #ifdef GL_ES precision mediump float; #endif uniform vec2 u_resolution; uniform vec2 u_mouse; uniform float u_time; void main(){ vec2 coord = gl_FragCoord.xy/u_resolution; coord.x *= .. 2022. 1. 6.
[GLSL] Circle https://thebookofshaders.com/07/ To make circle, the functions ‘length’ and ‘distance’ are often used. // Author @patriciogv - 2015 // http://patriciogonzalezvivo.com #ifdef GL_ES precision mediump float; #endif uniform vec2 u_resolution; uniform vec2 u_mouse; uniform float u_time; void main(){ vec2 st = gl_FragCoord.xy/u_resolution; float pct = 0.0; vec2 toCenter = vec2(0.5)-st; pct = length(to.. 2022. 1. 6.
[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.