์๋ฌด๋๋ ์ด์ ์ ์ฌ๋ ธ๋ ๊ฒ๋ค์ ์์ ์๊ฐ์ ๊ต์๋์ ๋์์ ๋ฐ์ ํ๋ ๊ฒ๋ค์ธ๋ฐ
๊ฝค ์ ์ง ์์ ๋ถ๋ค์ด openGL์ ๋ํด ๊ด์ฌ์ด ์๋ ๊ฒ ๊ฐ์์ ๊ณต๋ถ๋ ํ ๊ฒธ ๋ด๊ฐ ์ง์ ์ฌ๋ฌ๊ฐ์ง ์๋ฃ๋ค์ ์ฐธ๊ณ ํ์ฌ์ ๋ง๋ค์ด๋ณด๋ ค๊ณ ํ๋ค.
์ผ๋จ ๋๋ VisualStudio 2017์ ์ฌ์ฉํ ๊ฒ์ด๋ค.
ํ๋ก์ ํธ๋ฅผ ๋ง๋ค๊ณ main.cpp๋ฅผ ์์ค ์ถ๊ฐํด์ฃผ๊ณ
ํ๋ก์ ํธ(P) → ์์ฑ(P) ์ ํด๋ฆญํ์ฌ ํ๋ก์ ํธ์ ์์ฑ์ ํจ๋ค.
1. C/C++ → ์ผ๋ฐ → ์ถ๊ฐ ํฌํจ ๋๋ ํฐ๋ฆฌ
2. ๋ง์ปค → ์ผ๋ฐ → ์ถ๊ฐ ํฌํจ ๋๋ ํฐ๋ฆฌ
3. ๋ง์ปค → ์ ๋ ฅ → ์ถ๊ฐ ์ข ์์ฑ
์ GLFW์ gl3w๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ถ๊ฐํด์ค๋ค.
GLFW ๋ผ์ด๋ธ๋ฌ๋ฆฌ : https://www.glfw.org/
GLFW๋ ๋ฐ์คํฌํ์์ OpenGL, OpenGL ES ๋ฐ Vulkan ๊ฐ๋ฐ์ ์ํ ์คํ ์์ค ๋ค์ค ํ๋ซํผ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ด๋ค.
์ฐฝ, ์ปจํ
์คํธ ๋ฐ ํ๋ฉด ์์ฑ, ์
๋ ฅ ๋ฐ ์ด๋ฒคํธ ์์ ์ ์ํ ๊ฐ๋จํ API๋ฅผ ์ ๊ณตํด์ค๋ค.
glfwinit(), glfwCreateWindow() ๋ฑ๊ณผ ๊ฐ์ ํจ์๋ฅผ ํฌํจํ๊ณ ์๋ค.
gl3w ๋ผ์ด๋ธ๋ฌ๋ฆฌ : https://github.com/skaslev/gl3w (cmake ์ด์ฉํด์ ๋น๋ํด์ผํ ๋ฏ)
gl3w๋ glew๋ฅผ ๋์ฒดํ ์ ์๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ก glew๋ ์๋ ๋ฒ์ ์ OpenGL๊น์ง ์ง์ํ๋ค.
gl3w ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ OpenGL 3์ 4์ ์ฝ์ด ํ๋กํ์ผ์ ์ด์ ์ ๋ง์ถ๊ณ ์๋ค.
๋ง์ฝ LNK2001 ์๋ฌ๊ฐ ๋ฌ๋ค๋ฉด ํด๋น ํจ์์ ์ด๊ธฐํ๊ฐ ๋์ง ์์ ๊ฒ์ด๋ gl3w.c ํ์ผ์ ํ๋ก์ ํธ ์์ ์์ค๋ก ์ถ๊ฐํ์. ํด๊ฒฐ ๋ฐฉ๋ฒ ์ฐพ์ ๋งํฌ
main์ ๊ธฐ๋ณธํ์ ์ ์ด์ฃผ๊ณ (https://www.khronos.org/opengl/wiki/OpenGL_Loading_Library#GL3W ์ ์ฐธ๊ณ ํจ)
๊ทธ๋ฆฌ๊ณ
#include <GL/gl3w.h> #include <GLFW/glfw3.h>
์ด๋ถ๋ถ์ ๊ผญ ์์๋ฅผ ๋ค๋ฅด๊ฒ ์ ์ง ๋ง๊ณ ๋๊ฐ์ด ์ ์ด์ผ ํ๋ค.
๊ทธ๋ฆฌ๊ณ ์ปดํ์ผํด๋ณด๋ฉด
์ด ์ฐฝ์ด ๋จ๋ฉด ์ ์์ด๋ค. ์๋ฌ๊ฐ ๋จ๋ฉด ๋ค์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ๊ฒฝ๋ก๊ฐ ์๋ชป๋์ง ์์๋์ง, 64๋นํธ 32๋นํธ ์ ํ์ธํ๋์ง ํ๋ฒ ๋ ์ฒดํฌํด๋ณด์.
ํ์๋ ์คํ์์ค์ธ ImGUI๋ฅผ ์ด์ฉํ์ฌ์ ํ๋ก์ ํธ๋ฅผ ์งํํ๋๋ก ํ๊ฒ ๋ค.
์ฐธ๊ณ ๋งํฌ : https://github.com/ocornut/imgui
๋ค์ ํ ๋ฒ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ถ๊ฐ ํฌํจ ๋๋ ํฐ๋ฆฌ์ ๋ฃ๋๋ค.
ImGUI๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ๋ฐ๋ก ์์ฒด์ ์ผ๋ก ์ ์ํ๊ฑฐ๋ ์๋๋ฉด ํต์ง๋ก ์์ค์ฝ๋๋ฅผ ๋ด๋ถ์ ๋ฃ์ด์ ๋น๋ํ๋ฉด ๋๋ค.
๋๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ ์ ์๋ ๋งํฌ์ ๋ธ๋ก๊ทธ๋ฅผ ๋ฐ๋ผ์ ์ ์ํด์ ์ฌ์ฉํ์๋ค.
https://swstar.tistory.com/229#gref
๋น์ฃผ์ผ ์คํ๋์ค C/C++ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ๋ง๋ค๊ธฐ
์ด๋ฒ ํฌ์คํ ์์๋ ๋ง์ดํฌ๋ก์ํํธ ๋น์ฃผ์ผ ์คํ๋์ค์์ C์ธ์ด ๋๋ C++ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ ์ํ๊ณ ์ฌ์ฉํ๋ ๋ฒ์ ๋ํด ์์๋ด ์๋ค. ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ ์ ์ (static) ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ๋์ (dynamic) ๋ผ์ด๋ธ๋ฌ
swstar.tistory.com
๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ค์ ์ด ๋๋๋ฉด
https://github.com/ocornut/imgui/blob/master/examples/opengl3_example/main.cpp
์ด ์ชฝ์ผ๋ก ๋ค์ด๊ฐ๋ฉด imgui์ glfw3,gl3w์ ๊ดํ ์์ ๋ฅผ ์ฐพ์ ์ ์๋ค.
์ด๊ฒ์ ์กฐ๊ธ ์ฐธ๊ณ ํ์ฌ์ ๋ฃ์ด๋ณด์.
--------------------------------------------------------------------------------------------------------------
์ต๊ทผ์ ๋ค์ ๋ค์ด๊ฐ๋ณด๋ ๋ช๊ฐ์ง URL๋ ์ฌ๋ผ์ง๊ณ ํด์ ๊ฐ๋จํ ๋ฐฉ๋ฒ์ ์ฐ๊ธธ ๋ฐ๋๋ค.
์๋ฌด๋๋ ์ ๋ฐ์ดํธ๋ฅผ ์์ฃผ ํ์๋ค ๋ณด๋ ๋ฐฉ๋ฒ์ ๋ฐ๊พผ๋ฏ ํ๋ฐ
๊ฐ๋จํ๊ฒ https://github.com/ocornut/imgui ์ฌ๊ธฐ์ ์ด๋ก์ Code ๋ฒํผ -> download Zip -> ์์ถํด์ ํ imgui ๊ด๋ จ ์์ค๋ค์ ํ๋ก์ ํธ์ ํฌํจ์์ผ์ ์งํํ๋ฉด ๋ ๊ฒ ๊ฐ๋ค.
๋๋ ์ ๊ทธ๋ฆผ๊ณผ ๊ฐ์ด ImGUI ์์ค๋ค์ ์ถ๊ฐํ์๊ณ ์์ฑ๋ค์ ๋ค์ ์ฌ์ค์ ํ์๋ค.
glfw ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์์ฑ์ ์ถ๊ฐํ์ฌ์ฃผ์๊ณ
glviewport, glclearcolor, glclear ํจ์๋ฅผ ์ฐพ์ ์ ์๋ LNK2019 ์๋ฌ๊ฐ ๋จ๋ ๊ฒฝ์ฐ์๋
์์ ๊ทธ๋ฆผ๊ณผ ๊ฐ์ด ์ถ๊ฐ ์ข ์์ฑ์ glfw3.lib์ opengl32.lib๋ฅผ ๋ฃ์ด๋ณด๊ธธ ๋ฐ๋๋ค.
opengl3_loader.h์ ๊ฒฝ์ฐ ํ์ฌ gl3w.h์ ์ต์ํ์ ๊ธฐ๋ฅ๋ค์ ๋ก๊ฒจ์ ์ค๋ฏ๋ก ๋์ค์ gl3w.lib๋ฅผ ์ถ๊ฐํ๊ณ ๋ก๊ฒจ์ค๋ ๊ฒฝ์ฐ ์ฌ์ ์ ๋ฌธ์ ๊ฐ ๋ฐ์ํ๋ค.
https://github.com/ocornut/imgui/issues/4445
OpenGL backend now embeds its own GL loader (imgui_impl_opengl3_loader.h) · Issue #4445 · ocornut/imgui
TL;DR; Our GL backend now embed its own minimal GL loader (embedded file; full source repo) User/application don't need to configure anything related to GL loader. User/application can use their ow...
github.com
์์ ๋งํฌ๋ ํด๋น ์๋ฌ์ ๋ํ imgui ์ ์์๊ฐ ๋ต๋ณํ ๊ฒฝ์ฐ์ด๋ฉฐ gl3w_stripped๋ผ๋ ํ์ผ์ ์ ์ํ์ฌ ๋ ๊ฐ์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ถฉ๋์ํค์ง ์๊ฒ๋ ๋ง๋ค๋ผ๋ ๊ฒ์ธ๋ฐ
https://github.com/dearimgui/gl3w_stripped
GitHub - dearimgui/gl3w_stripped: Simple OpenGL core profile loading, customized for Dear ImGui
Simple OpenGL core profile loading, customized for Dear ImGui - GitHub - dearimgui/gl3w_stripped: Simple OpenGL core profile loading, customized for Dear ImGui
github.com
๋์ ๊ฒฝ์ฐ cmake๋ฅผ ํตํด ํ๋ก์ ํธ๋ฅผ ๋ค์ ๋ง๋ค์ด์ ๋๋ฆฌ๋๊น imgui_loader.h์ ํ์ํ gl3w ํ์ผ๋ค์ด ์ ์๋์ด์ gl3w.h ํค๋ํ์ผ ๋์ imgui_impl_opengl3_loader.h ํ์ผ์ ์ฌ์ฉํ๋๊น ํด๊ฒฐ๋์๋ค.
https://github.com/ocornut/imgui/blob/master/examples/example_glfw_opengl3/main.cpp
์ด ์์ ๋ฅผ ์ฌ์ฉํ์ฌ์ main ํจ์๋ฅผ ์ ์ํ์๋ค.
๋ณธ ํ๋ฉด์ด ๋ณ๋ค๋ฉด ์ฑ๊ณตํ ๊ฒ์ด๋ค. ์์ผ๋ก ์ด ImGUI์ ํจ๊ป openGL์ ๊ณต๋ถํด๋ณด๋๋ก ํ์!
์ด์ ๋ช ๊ฐ์ง ์ฐธ๊ณ ํ ๋งํ ์ฌ์ดํธ์ ๋งํฌ๋ค์ ์ข ๋จ๊ฒจ๋๊ฒ ์ต๋๋ค
์ ๋ ์ ์ผ์ด ์ ๋ฆฌ๊ฐ ๋๋ฉด ์๋ง ํฌ์คํ ์ ๋ค์ ์์ํ๊ฒ ๋ ๊ฒ ๊ฐ์ต๋๋ค~!
LearnOpenGL
Learn OpenGL, extensive tutorial resource for learning Modern OpenGL
Welcome to OpenGL Welcome to the online book for learning OpenGL! Whether you are trying to learn OpenGL for academic purposes, to pursue a career or simply looking for a hobby, this book will teach you the basics, the intermediate, and all the advanced kn
learnopengl.com
LearnOpenGL ๋ฒ์ญ ๋ธ๋ก๊ทธ
[Learn OpenGL ๋ฒ์ญ] 2-1. ์์ํ๊ธฐ - OpenGL
OpenGL ์์ํ๊ธฐ/OpenGL ์์ํ๊ธฐ ์ ์ ๋จผ์ OpenGL์ด๋ ๋ฌด์์ธ์ง ์์์ผ ํฉ๋๋ค. OpenGL์ ๊ทธ๋ํฝ ๋ฐ ์ด๋ฏธ์ง๋ฅผ ์กฐ์ํ๋ ๋ฐ ์ฌ์ฉํ ์ ์๋ ๋ง์ ๊ธฐ๋ฅ๋ค์ ์ ๊ณตํ๋ API( Application Programming Interface )๋ผ..
heinleinsgame.tistory.com
P.S ํน์ฌ๋ ๋ฌธ์ ๊ฐ ๋๊ฑฐ๋ ํ๋ฆฐ ์ฌํญ์ ๊ฐ๋ฅด์ณ์ฃผ์๋ฉด ๊ฐ์ฌํฉ๋๋ค :)
'OpenGL ๋ฐ๋ผ๊ฐ๊ธฐ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[์ปดํจํฐ ๊ทธ๋ํฝ์ค] OpenGL ์์ํด๋ณด์2 - ๊ทธ๋ํฝ์ค ํ์ดํ๋ผ์ธ1 (0) | 2021.11.28 |
---|