ã¯ããã«
Cè¨èªã®å¦ç¿ãé²ãã¦ãã¾ãããã°ã©ãã£ãã¯ã¹å¦çãè¡ãã«ããã£ã¦ä»¥åæ§ç¯ããVSCodeã®ç°å¢æ§ç¯ã§ã¯ä¸è¶³ãã¦ããé¨åããããåæ§ç¯ãã¾ããã
ã®ã§ãWindows11ä¸ã®VSCodeã§OpenGLãç¨ãã¦Cè¨èªãæ±ãç°å¢ã®æ§ç¯æé ãåå¿é²ã¨ãã¦è¨è¼ãã¾ãã
èæ¯
以åããã®è¨äºã§ã¿ã¼ããã«ä¸ã«çµæãåºåããCè¨èªã®éçºç°å¢ãæ§ç¯ãã¦ãã¾ããã
Â
paizaããã®Cè¨èªå
¥éãçµãã£ãã®ã§ãæCã«æ«æãããã¦åå¼·ç¨ã«è³¼å
¥ãããã®ã®ããã®ã¾ã¾æ«æãã¦ãã¾ã£ãã®ã§æªèªã®ã¾ã¾æ¾ç½®ããã¦ãã以ä¸ã®æ¸ç±ããã©ãã©ã¨èªãã§ãã¾ããã
paizaããã®Cè¨èªå ¥éã®è¬åº§ãä½ã¨ãå ¨é¨çµããã¾ããï½ð¥³ææ¥ä»¥éã¯ææ§ãªã¨ããã復ç¿ããªãããæè²·ã£ã¦ããåã«æ«æãã¦ãã¾ã£ãæ¬ã«åãã£ã¬ã³ã¸ãã¦ã¿ããã¨æãã¾ããããDLã§ããªãç´ æãããã ãããªâ¦ã pic.twitter.com/4CyAKhlcja
â ã㨠(@chawatuki) 2024å¹´10æ14æ¥
Â
çµæããã®æ¬ã§ã¯ããªãæ©ã段éããã°ã©ãã£ã«ã«ã³ã³ã½ã¼ã«ã使ç¨ããæé ãåºã¦ãããã¾ããã®å©ç¨ã¯å½æDLã§ãã¦ãããã®æ¬ã®ä»é²ã®ç¬èªã¢ã¸ã¥ã¼ã«ã«ä¾ã£ã¦ãã¾ããã
ä»ã¯ããDLã§ããªãã£ãï¼ä½¿ããã¦ããã®ãVisual Studio ã¨.cppã§å®è³ªC++ã®ã³ã¼ãã®ãããªã®ã§ãVSCodeã§åãããã«ãªã«ãã§ããªããâ¦ã¨è©¦è¡é¯èª¤ããçµæããããªã£ãã¨ããæãã§ãã
Â
åæ
ã»VSCodeãã¤ã³ã¹ãã¼ã«ããã¦ãããã¨
â»ã¤ã³ã¹ãã¼ã«ããæ¡å¼µæ©è½ã ãå
¥ããç¶æ
ãsetting.jsonãªã©ãã¾ã£ããã§ã.cãã¡ã¤ã«ãå®è¡ããã¨gccãèªèãããªãã¨ã©ã¼ãåºã
Â
æé
ï¼ï¼MSYS2ã®ãã¦ã³ãã¼ã
MSYS2ã¯Windowsä¸ã§Unixç³»ã®ã½ããã¦ã§ã¢ãå©ç¨ã§ããç°å¢ãæä¾ãããã¼ã«ã§ããpacmanã¨ããããã±ã¼ã¸ããã¼ã¸ã£ã¼ãã¤ãã£ã¦ã½ããã¦ã§ã¢ã®ã¤ã³ã¹ãã¼ã«ã管çãè¡ããæ©è½ãããã®ã§ãããä»åã¯ãã®æ©è½ã使ã£ã¦ä¸è¿°ã®GlibãWindowsã¸ã¤ã³ã¹ãã¼ã«ãã¾ãã
â»ãã®ããããã£ããã§ãLinuxã§aptã¨ãyumã使ããããªã¤ã¡ã¼ã¸
ã»MSYS2ã®å
¬å¼ãµã¤ãã¸ã¢ã¯ã»ã¹ããDLãã¾ãã
Â
ã»DLããexeãä»»æå ´æã¸é ç½®ããèµ·åãã¾ãã
Â
ã»èµ·åããã¨ã»ããã¢ããã¡ãã¥ã¼ãéãã®ã§ããNextã
Â
ã»ã¤ã³ã¹ãã¼ã«å ´æãæå®ãã¦ãNextã
Â
ã»MSYS2ãç´ã¥ãããµã¼ãã¹ãé¸æãä»åã¯ä¸è¦ãªã®ã§é¸æããªãã¾ã¾ãNextã
Â
ã»ã¤ã³ã¹ãã¼ã«ãã¿ã³ãã¯ãªãã¯
ï¼ãã®ç»é¢ã«é·ç§»ããæç¹ã§å¤å°é²ãã ç¶æ
ã«ãªã£ã¦ãã¾ãï¼
Â
ã»100%ã«ãªã£ãããNextããã¯ãªãã¯ã
Â
ã»ã¤ã³ã¹ãã¼ã«å®äºå¾ããFinishããã¯ãªãã¯ã
ãRun MSYS2 now.ããONã«ãã¦ããã°ãFinishã¯ãªãã¯ã§MSYS2ãèµ·åãã¾ãã
Â
ï¼ï¼MSYS2ã®è¨å®
MSYS2ã®ã¿ã¼ããã«ãèµ·åããã®ã§ã以ä¸ã®ã³ãã³ããå®æ½ããããã±ã¼ã¸ãã¼ã¿ãã¼ã¹ãæ´æ°ãã¾ãã
â»éä¸ããy/nã(yes/no)å
¥åãæ±ããããã®ã§ãyãå
¥å
pacman -Syu
Â
éä¸ã§ã¿ã¼ããã«ãèªåã§éããã®ã§ãã¤ã³ã¹ãã¼ã«å ´æã«ç§»åããmsys2.exeãã¯ãªãã¯ãå度ã¿ã¼ããã«ãèµ·åãã¾ãã
èµ·åå¾ãããä¸åº¦ããã±ã¼ã¸ãæ´æ°ã
pacman -Syu
å®äºããã¨ãã¿ã¼ããã«ã¯ã¯ãã¼ãºãããã®ãããªå½¢ã«ãªãã¾ãã
Â
æå¾ã«ãã®ã³ãã³ãã§GCCã®ã¤ã³ã¹ãã¼ã«ãå®è¡ã
åããã±ã¼ã¸ã®æ¦è¦ã¯ä»¥ä¸ã§ãã
ã»mingw-w64-x86_64-binutils:
ãã³ã³ãã¤ã©é¢é£ã®ã¦ã¼ãã£ãªãã£ï¼ã¢ã»ã³ãã©ããªã³ã«ã¼ãªã©ï¼ãæä¾ãã¾ããã»mingw-w64-x86_64-crt-git:
ãCã©ã³ã¿ã¤ã ã©ã¤ãã©ãªã§ããCè¨èªã®æ¨æºã©ã¤ãã©ãªé¢æ°ãæä¾ãã¾ããã»mingw-w64-x86_64-gcc:
ãGNU Compiler Collectionã®ä¸é¨ã§ãC/C++ã³ã³ãã¤ã©ãå«ã¿ã¾ããã»mingw-w64-x86_64-gdb:
ãGNU Debuggerã§ããããã°ã©ã ã®ãããã°ã«ä½¿ç¨ããã¾ããã»mingw-w64-x86_64-gdb-multiarch:
ããã«ãã¢ã¼ããã¯ãã£å¯¾å¿ã®GDBã§ããç°ãªãã¢ã¼ããã¯ãã£éã§ã®ãããã°ã«ä½¿ç¨ããã¾ããã»mingw-w64-x86_64-headers-git:
ããããã¼ãã¡ã¤ã«ã®ã»ããã§ããC/C++ããã°ã©ãã³ã°ã§å¿ è¦ãªãããã¼ãã¡ã¤ã«ãå«ã¾ãã¾ããã»mingw-w64-x86_64-libmangle-git:
ãé¢æ°åã®ãã³ã°ãªã³ã°ã¨ããã³ã°ãªã³ã°ãå¦çããã©ã¤ãã©ãªã§ããã»mingw-w64-x86_64-libwinpthread-git:
ãWindowsä¸ã§ã®POSIXã¹ã¬ããï¼pthreadsï¼ãæä¾ããã©ã¤ãã©ãªã§ããã»mingw-w64-x86_64-make:
ããã«ããªã¼ãã¡ã¼ã·ã§ã³ãã¼ã«ã§ããMakefileã使ç¨ãã¦ããã¸ã§ã¯ãã®ãã«ããèªååãã¾ããã»mingw-w64-x86_64-pkgconf:
ãããã±ã¼ã¸è¨å®ãã¼ã«ã§ããã¤ã³ã¹ãã¼ã«æ¸ã¿ã®ã©ã¤ãã©ãªããã¼ã«ã®æ å ±ãåå¾ãã¾ããã»mingw-w64-x86_64-tools-git:
ãéçºãã¼ã«ã®ã»ããã§ãã便å©ãªã¦ã¼ãã£ãªãã£ãå«ã¾ãã¾ããã»mingw-w64-x86_64-winpthreads-git:
ãWindowsä¸ã§ã®pthreadsã®å®è£ ã§ããPOSIXã¹ã¬ããã¨äºææ§ãããã¾ããã»mingw-w64-x86_64-winstorecompat-git:
ãWindowsã¹ãã¢äºææ§ãæä¾ããã©ã¤ãã©ãªã§ãã
Â
Â
ï¼ï¼GLFWããã¦ã³ãã¼ããã
ã»å ¬å¼HPããGLWFã®ãã¡ã¤ã«ãDLãã¾ãã
ã»ãDownloadãã®ãªã³ã¯ãã¯ãªãã¯ã
ã»Windowsç¨ã®ãã¤ããªã¼ãã¡ã¤ã«ãã¯ãªãã¯ã
Â
ã»ä»»æå ´æã¸é ç½®ãã解åãã¾ãã
Â
ã»è§£åãããã©ã«ãå
ã®ãGLFWãã移åããã¾ããã³ãã¼ã¾ãã¯åãåããã¾ãã
â»è§£åãããã£ã¬ã¯ããª(glfw-3.4.bin.WIN64)é
ä¸ã®ãglfw-3.4.bin.WIN64\include\GLFW
Â
ã»MSYS2ãã¤ã³ã¹ãã¼ã«ããå ´æã«ç§»åããincludeãã£ã¬ã¯ããªé
ä¸ã«è²¼ãã¤ã
â»{MSYS2ãã¤ã³ã¹ãã¼ã«ãããã¹}\ucrt64\include ã®é
ä¸
Â
ã»å度解åãããã©ã«ãã«æ»ãããlib-mingw-w64ãé
ä¸ã®dllã移åããã¾ããã³ãã¼ã¾ãã¯åãåããã¾ãã
â»è§£åãããã£ã¬ã¯ããª(glfw-3.4.bin.WIN64)é
ä¸ã®ãglfw-3.4.bin.WIN64\lib-mingw-w64é
ä¸ã®ãã¡ã¤ã«
Â
ã»MSYS2ãã¤ã³ã¹ãã¼ã«ããå ´æã«ç§»åããlibãã£ã¬ã¯ããªé
ä¸ã«è²¼ãã¤ã
â»{MSYS2ãã¤ã³ã¹ãã¼ã«ãããã¹}\ucrt64\lib ã®é
ä¸
Â
Â
ï¼ï¼gladããã¦ã³ãã¼ããã
å ¬å¼ã®GitHubã¸ã¢ã¯ã»ã¹ã
ã»Codeã¡ãã¥ã¼ã®ä¸é¨ã«ãã¸ã§ãã¬ã¼ã¿ã¼ã¸ã®ãªã³ã¯ãããã®ã§ãã¡ããã¯ãªãã¯ã
Â
ã»è¨èªï¼ä»åã¯C/C++)ãAPIã®ãã¼ã¸ã§ã³ãé¸æãããGENERATEããã¿ã³ãã¯ãªãã¯
Â
ã»gladå©ç¨ã«å¿ è¦ãªã¢ã¸ã¥ã¼ã«ãzipã«ãªãã®ã§ãã¯ãªãã¯ãã¦DL
Â
ã»DLå¾ãä»»æå ´æã¸é ç½®ãã解å
Â
ã»è§£åãããã©ã«ãå
ã®ãincludãã移åããã¾ããã³ãã¼ã¾ãã¯åãåããã¾ãã
â»è§£åãããã£ã¬ã¯ããª(glad)é
ä¸ã®ãincludeãã©ã«ãé
ä¸ä¸å¼
Â
ã»MSYS2ãã¤ã³ã¹ãã¼ã«ããå ´æã«ç§»åããincludeãã£ã¬ã¯ããªé
ä¸ã«è²¼ãã¤ã
â»{MSYS2ãã¤ã³ã¹ãã¼ã«ãããã¹}\ucrt64\include ã®é
ä¸ã
â»ãkhrplatform.hãã®ä¸æ¸ç¢ºèªãçºçããå ´åã¯ä¸æ¸ã
ã»å度解åãããã©ã«ãã«æ»ãããsrcãé
ä¸ã®cãã¡ã¤ã«ã移åããã¾ããã³ãã¼ã¾ãã¯åãåããã¾ãã
â»è§£åãããã£ã¬ã¯ããª(glad)é
ä¸ã®ãsrcãã©ã«ãé
ä¸ä¸å¼
Â
ã»MSYS2ãã¤ã³ã¹ãã¼ã«ããå ´æã«ç§»åããincludeãã£ã¬ã¯ããªé
ä¸ã«è²¼ãã¤ã
â»{MSYS2ãã¤ã³ã¹ãã¼ã«ãããã¹}\ucrt64\include ã®é
ä¸ã
ï¼ï¼ç°å¢å¤æ°ã®è¨å®
ãã®ç¶æ
ã§ã¯ã³ãã³ãããã³ãããªã©ã§ãgcc -vããªã©ã¨ãã£ã¦ãã¨ã©ã¼ã«ãªãã¯ãã§ãã
ä»åã®æé ã§ã¯ã{MSYS2ãã¤ã³ã¹ãã¼ã«ãããã¹}\ucrt64\binãã®é
ä¸ã«gcc.exeãé
ç½®ããã¦ããã¯ããªã®ã§ãããã«ãã¹ãéãã¾ãã
Â
ã»ã·ã¹ãã ç°å¢å¤æ°ã®ã¦ã£ã³ãã¦ãéãããç°å¢å¤æ°ããã¿ã³ãã¯ãªãã¯
Â
ã»ã·ã¹ãã ç°å¢å¤æ°ã®ãPathããé¸æãããç·¨éããã¿ã³ãã¯ãªãã¯
Â
ã»ãæ°è¦ããã¿ã³ãã¯ãªãã¯ããgcc.exeã®é
ç½®å ´æãè¨è¼ãã¦OKã
以éã®ã¦ã£ã³ãã¦ããã¹ã¦ãOKãã§éãã¦ãã
Â
ããã¾ã§çµãã£ãããã³ãã³ãããã³ãããªã©ãåèµ·åã㦠gcc -v ã§gccã®ãã¼ã¸ã§ã³ãåºåãããã確èªã
åºåãããã°gccå¨ãã®ã¤ã³ã¹ãã¼ã«ããã³ãã¹ã®è¨å®ã¯OKã§ãã
6ï¼VSCodeã®è¨å®
VSCodeãåèµ·åãã¾ãã
ãã®æç¹ã§Cã®ãã¡ã¤ã«ãç½®ãã¦ãããã©ã«ãã«ãã .vscodeã¯ç©º(task.jsonãªã©ãªã)ãsetting.jsonã«ãCã«é¢ããæ
å ±ã¯æªè¨è¼ã®ç¶æ
ã§ãã
ã»ä»»æã®Cããã°ã©ã ãã¡ã¤ã«ãé
ç½®
ä»»æã® .c ãã¡ã¤ã«ãä½æãããã®cãã¡ã¤ã«ãéããç¶æ
ã«ãã¾ãã
ä»åã¯ããC_Planner_001.cãã¨ãããã¡ã¤ã«ãä½ãã¾ããã
#include <stdio.h>
#include <GLFW/glfw3.h>
int main(int argc, char *argv[]) {
  Â
  GLFWwindow *window;  if(!glfwInit()){
    return -1;
  }  window = glfwCreateWindow( 640, 480, "Window OpenGL - Testing", NULL, NULL);
  if(!window){
    glfwTerminate();
    return -1;
  }  while(!glfwWindowShouldClose(window)){
    glClear(GL_COLOR_BUFFER_BIT);    glfwSwapBuffers(window);
    glfwPollEvents();
  }
  glfwTerminate();  return 0;
}
Â
ã».cãã¡ã¤ã«ãéããç¶æ ã§ãã¡ãã¥ã¼ãã¼ã®ãã¿ã¼ããã«ã->ãæ¢å®ã®ãã«ãã¿ã¹ã¯ã®æ§æããã¯ãªãã¯
Â
ã»ãC/C++:gcc.exe ã¢ã¯ãã£ããªãã¡ã¤ã«ã®ãã«ãããé¸æ
Â
ã»é¸æããã¨task.jsonãèªåçæããã¾ãã
â»å¾ã»ã©ãã®ãã¡ã¤ã«ã«è¿½è¨ãè¡ãã¾ã
Â
ã»æ¡å¼µæ©è½ã§ãC/C++ Extension Packãã®è¨å®ãéãããinclude Pathãã®è¨å®ç®æãéã
ããã«ãMSYS2ã®includeãã¹ãè¨å®ã
Â
ã»ä¸è¨ã§ãOKããæ¼ãã¨ãVSCodeã®setting.jsonã«include.pathãèªå追å ããã¾ãã
ã»task.jsonãå度éããå¼æ°ã«GLFWã®ä½¿ç¨ã®ããã®å¼æ°ã追å
追å å¾ã®task.json
(ãâ
ããã追å ãã®ç®æã追å ããã®æè¨ã¯å®ãã¡ã¤ã«ããã¯åé¤)
{
  "version": "2.0.0",
  "tasks": [
    {
      "type": "cppbuild",
      "label": "C/C++: gcc.exe ã¢ã¯ãã£ããªãã¡ã¤ã«ã®ãã«ã",
      "command": "C:\\msys64\\ucrt64\\bin\\gcc.exe",
      "args": [
        "-fdiagnostics-color=always",
        "-g",
        "${file}",
        "-o",
        "${fileDirname}\\${fileBasenameNoExtension}.exe",
        "-lglfw3", â ããã追å
        "-lopengl32", â ããã追å
        "-lgdi32" â ããã追å
      ],
      "options": {
        "cwd": "${fileDirname}"
      },
      "problemMatcher": [
        "$gcc"
      ],
      "group": {
        "kind": "build",
        "isDefault": true
      },
      "detail": "ã³ã³ãã¤ã©: C:\\msys64\\ucrt64\\bin\\gcc.exe"
    }
  ]
}
Â
ã»ä¸è¨ãè¨å®ããå®è¡ããéã¨ã©ã¼ãçºçããå ´åã¯setting.jsonã«ã以ä¸ã追å ã
 "code-runner.executorMap": {
     "c": "cd $dir && gcc -fdiagnostics-color=always $fileName -o $fileNameWithoutExt -fexec-charset=CP932 -lglfw3 -lopengl32 -lgdi32 && $dir$fileNameWithoutExt"
  }
Â
ï¼ï¼å®è¡
ããã¾ã§ã§ãããå®è¡ãã¾ãã
Â
ã¦ã£ã³ãã¦ãç«ã¡ä¸ããã¾ããï¼ï¼ï¼ï¼
åèã«ããã¦ããã ãããµã¤ã
以ä¸ã®ãµã¤ãæ§ã®æ å ±ãåèã«ããã¦ããã ãã¾ããã
ã»MSYS2ã®UCRT64ã«ã¤ãã¦
Â
ã»OpenGLã®æ¦è¦ãªã©
Â
ã»GLFWã®æ¦è¦ã«ã¤ãã¦
ã»è¨å®å¨ãå
¨è¬
以éã«è¿°ã¹ãè¿·å®®å ¥ããã¦ããæã«ãã®åç»ãå¶ç¶è¦ãã®ã§ãå人çã«ä»åä¸çªå©ããã¾ããã
Installing OpenGL in Visual Studio Code(2022/03/24)
https://www.youtube.com/watch?v=AJKf6tdWYME
Â
Â
ææ³ãªã©
å
¨ç¶ãã¾ããããªãã¦çµå±2æ¥ã»ã©ããã£ã¦ãã¾ãã¾ããã
æåããã¾ãã¾è¦ãããCã®ã°ã©ãã£ãã¯ã¹å¦çãæ¸ãã¦ããæ¹ããã#include <glib.h>ãã¨ããã³ã¼ããæ¸ãã¦ãããã§æç»ããâ¦ã¨ããã®ãè¦ããã¦ããã®ã§ãGLibã§æ¤ç´¢ãã¦ä»¥ä¸ãå
¥ãã¦è©¦è¡é¯èª¤ãã¦ãã¾ã£ã¦ãã¾ããã
ãã ããã®ã©ã¤ãã©ãªã¯ã¦ã¼ãã£ãªãã£ã©ã¤ãã©ãªã§ãWindowä½æãªã©ã®æ©è½ã¯ãªãæ§åãå
¨ç¶ãã¾ããããªãâ¦ã¨Glib.hã§æ¤ç´¢ãã¾ãã£ã¦ä¸è¿°ã®Youtubeã®åç»ããã¾ãã¾HITãããããã¿ã¦ããã®ã©ã¤ãã©ãªã§ããªãããGlibã§ããªãã¦ãOpenGL使ãã®ãæ£ããã¨æ°ã¥ããç´ãã¦ããã¾ããã
ã©ãããglib.hã¨ããã®ãç¬èªã©ã¤ãã©ãªã®ããã§ã河西æéæ°ã®ãCè¨èªã«ããã¯ããã¦ã®ã¢ã«ã´ãªãºã å
¥éãæ¹è¨ç¬¬3çãã«ãã®è¨è¿°ãããããã§ããã
æ ¹æ¬çãªè¨è¼ã®é¨åã¯å¤ãæ¸ç±ã§ããããªã«åé¡ããã¾ããããã©ã¤ãã©ãªå¨ãã«ã¤ãã¦ã¯ãã¯ãæ°ããæ
å ±ã§ç¢ºèªãã¦é©ç¨ããªãã¨ãããªããªãã¨å½ããåã®ãã¨ã§ããæ¹ãã¦å®æãã¾ããã
Â