Posts

opengl : How to install it

Image
'opengl' is a open source graphic library for showing something nice in your computer. Of course you can use some of engines like Unreal Engine4 or Unity for showing graphics. But it is much better to learn opengl for student who want to study or want to get a scheme of graphics. You can learn and understand 'lighting', 'shadowing', 'shading', '3D geometry', and a lot of other things deeper (but not easier) than just using engine. This is the post for how to install opengl in visual studio. The 'khronos' group offers some of files which can be used to build library for opengl in your computer environment. You can use those file by using 'cmake' software. But there's already files builded for specific environment like '64bit visualstudio 2013'. Here's link you can get files for setting opengl in visual studio https://drive.google.com/file/d/1cMGeEtJSj3EsLywZV0dGABzYixL_9oR9/view?usp=sharing After unzip f...

Smart pointer_application

Image
Let's look at shared_ptr's applications and problems we are often faced with. There are beautiful examples in data structure such as linked-list and tree. In this post, we will take tree example. Before learning shared_ptr, it is common to use normal pointer to save children node's information. When taking tree structure, we can use shared_ptr instead of normal pointer since every node is usually allocated in heap memory. Advantage, when using shared_ptr, is ofcurse automatic  memory releasing. In existing tree structure, Node class should be deleted from high level(or leaf node). So we create  wrapping class called 'tree' and use postorder algorithm to release memory. However Node class ,used with shared_ptr, doesn't need wrapper one and also dose not need to do anything in destructor. Memory will be released automatically in an ordered way. For example, when node is deleted, deleting shared_ptr also follows. Then, shared_ptr's de...

계산미학

계산미학 ( 오병남 , 『 미학강의 』 , 서울대학교출판문화원 )   융합공학부 디지털이미징공학 정진서   - 서론 계산미학 , 아름다움을 컴퓨팅 알고리즘으로 수행하기 위해 살펴봐야할 개념은 단연 알고리즘과 미학이다 . 그 중에서도 컴퓨터와 코딩에만 익숙한 공대생의 입장에서 계산과 미학의 융합적 사고를 형성하기 위해서는 미학에 관한 개념에 중점을 두어야한다 . 이러한 의미에서 선택한 오병남 교수님의 ‘ 미학강의 ’ 를 읽고 서평을 쓴다 . ‘ 미학강의 ’ 에서는 고전 미학부터 현대 미학까지의 발전 과정과 모방 , 영감 , 상상으로서의 예술 , 그리고 저자가 주장하는 정상인 개념으로서의 미학 , 한국 미학에 대한 분석과 반성으로 이루어져있다 . 계산미학의 관점에서는 알고리즘화 하고자하는 ‘ 미학 ’ 은 단연 중요한 개념이다 . 따라서 저자의 ‘ 정상인 ’ 개념과 모방 , 영감 , 상상으로서의 예술 보다는 미학의 발전이 어떻게 계산미학에 접목될 수 있는가에 초점을 맞추어 보고자 한다 . 이번 서평에서는 전통적 , 고전적 , 근 ⦁ 현대의 미학으로의 개념 변화를 살펴 본 후 , 계산미학이 어떻게 객관주의와 주관주의로서의 미학에 적용되어 질 수 있는지 고찰하고 , 아직 태동기인 계산미학이 나아가야할 방향에 대해서 주관적인 생각을 서술해보고자 한다 . - 배경 알파고를 대두로 AI 가 한창 인기이다 . 알렉사 , 빅스비 , 시리 등이 주도적으로 비서 역할을 수행하고 , 전기자동차의 자동주행은 4 차 산업혁명에 대한 기대 속에서 뜨거운 감자로 자기 매김하고 있다 . 컴퓨터가 ‘AI’ 말 그대로 인간과 같이 지능을 가진 존재로 인식되는 현상은 더욱 짙어지고 있다 . 지능을 가진 인간은 저마다의 주관적인 미적 태도를 형성하고 , 아름다움을 느끼고 예술을 감상 , 창작할 수 있는 능력을 지닌 존재다 . 그렇다면 인공지능 컴퓨터 또한 그것의 고유한 미적 태도를 통해 아름다움을 느끼고 예술 활동을 할 수 있는 것일까 ? 이...

Smart pointer

Image
This post is about shared_ptr in C++11. We will take a look at (dis)advantages of shared_ptr and how to use it. Usually we are only aware of advantages of smart pointer. Through this post, I hope we freely talk about disadvantages also.   Smart pointer? First of all, It isn't reasonable not to talk about smart pointer. Smart pointer is what designed for preventing user from memory leak when user forgot to delete dynamic memory allocation. 'Automatic memory-care pointer' is enough to understand smart pointer. You can see advantage of smart pointer preventing mistake from below example.   Someone assign other address to normal_pointer eventhough it has already address of heap memory. If heap memory will be used after, developer should save its address to other pointer and if heap will not be used, delete operator is neeeded. But we often do these mistakes. It might be arrogant trusting oneself can care all of memory. To see whether memroy is del...

스마트 포인터 활용

Image
shared_ptr 의 활용법과 발생할 수 있는 문제와 해결방안을 살펴보겠습니다 . linked list, tree 같은 자료구조에서 smart pointer 의 아름다움을 한껏 느낄 수 있습니다 . 제가 자주 사용하는 방법인 트리구조에서의 활용을 살펴보겠습니다 . shared_ptr 을 배우기 전까지는 자식노드 정보를 저장하기 위해 일반적인 포인터를 사용하였을 것입니다 .  Tree 와 같은 자료구조를 사용 시 , 일반적으로 각 노드들은 힙메모리에 할당되므로 보통 포인터 대신 shared_ptr 을 적용할 수 있습니다 .  보통 포인터가 아닌 shared_ptr 을 이용했을 때의 장점은 단연 메모리 해제에 있습니다 . 기존의 Node 클래스는 하위 노드부터 제거해나가야 하므로 , Tree 라는 래퍼클래스를 더 만들어 주어 후위 순회를 하며 메모리를 해제시켜주어야 합니다 . 하지만 shared_ptr 을 이용한 Node 클래스는 래퍼클래스가 필요하지도 , 소멸자에서 딱히 해줄 일도 없이 차근차근 메모리가 해제되는 기분 좋은 현상을 볼 수 있습니다 .  노드가 해제되면 shared_ptr 도 해제되고 , 뒤이어 그것이 가리키고 있던 메모리도 해제되기 때문입니다 . 자기를 가리키는 유일한 shared_ptr 이 없어짐으로써 자신도 해제되는 그림입니다 .  스마트 포인터의 장점을 한껏 보여줄 수 있는 예제로 충분합니다 . 주의사항이 있습니다 . 앞의 포스트 ( 스마트 포인터 ) 에서 살펴보았듯이 스마트포인터에는 스택메모리 주소를 보관해서는 안 됩니다 . 만약 스택에 할당된 메모리를 트리에 보관한다면 , 사용자의 의도와는 다르게 해제될 수 있고 , 하위 노드들에 대한 정보를 모두 잃어버릴 수 있습니다 .  그렇기에 만약 스택메모리에 할당된 정보를 트리구조로서 관리하고자 한다면 똑같은 복사본을 만들어 사용하는 수 밖에 없습니다 . 그리고 이것은 불필요한 정보...