Top.Mail.Ru
Ответы
Аватар пользователя
Аватар пользователя
Аватар пользователя
Аватар пользователя
Программирование
+2

C++ VISUAL STUDIO

Люди помогите,использовал до этого vs code,пытался подключить библиотеку imgui,часа 3 ничего не получалась,постоянно выдает какие то ошибки по типу "imgui.h не найден" ,хотя он есть,куча всего перепробовал,потом уже отчаялся и пошел в Visual studio,там такая же ошибка,просто не находит файлы,которые подключаю ,на imgui.h больше всего ругалось

По дате
По рейтингу
Аватар пользователя
Просветленный
5мес

Убедись, что папка с хидерами библиотеки добавлена в Include Directories проекта

Аватар пользователя
Просветленный
5мес
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
 #include <iostream> 
#include "imgui.h" 
#include "imgui_impl_win32.h" 
#include "imgui_impl_opengl3.h" 
#include <GL/gl3w.h> 
 
 
#define GLEW_STATIC 
#include <GL/glew.h> 
 
#include <windows.h> 
 
#pragma comment(lib, "opengl32.lib") 
#pragma comment(lib, "glew32s.lib") 
 
 
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 
 
int main(int argc, char** argv) { 
    const char* CLASS_NAME = "ImGui"; 
 
    WNDCLASS wc = {}; 
 
    wc.lpfnWndProc = WindowProc; 
    wc.hInstance = GetModuleHandle(NULL); 
    wc.lpszClassName = CLASS_NAME; 
 
    RegisterClass(&wc); 
 
    HWND hwnd = CreateWindowEx( 
        0,                               
        CLASS_NAME,                      
        "Dear ImGui",                     
        WS_OVERLAPPEDWINDOW,             
        CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, 
        NULL,        
        NULL,        
        wc.hInstance,   
        NULL         
    ); 
     
    if (hwnd == NULL) { 
        return 1; 
    } 
 
    ShowWindow(hwnd, SW_SHOW); 
 
    if (glewInit() != GLEW_OK) { 
        return 1; 
    } 
 
 
    IMGUI_CHECKVERSION(); 
    ImGui::CreateContext(); 
    ImGuiIO& io = ImGui::GetIO();  
 
 
    ImGui_ImplWin32_Init(hwnd); 
    ImGui_ImplOpenGL3_Init("#version 130"); 
 
    MSG msg = {}; 
    while (GetMessage(&msg, NULL, 0, 0)) { 
        TranslateMessage(&msg); 
        DispatchMessage(&msg); 
 
        ImGui_ImplOpenGL3_NewFrame(); 
        ImGui_ImplWin32_NewFrame(); 
        ImGui::NewFrame(); 
 
        ImGui::Begin("Hello, world!"); 
        ImGui::Text("This is some useful text."); 
        ImGui::End(); 
 
        ImGui::Render(); 
        ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); 
    } 
 
    ImGui_ImplOpenGL3_Shutdown(); 
    ImGui_ImplWin32_Shutdown(); 
    ImGui::DestroyContext(); 
 
 
    return 0; 
} 
 
 
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { 
    if (ImGui_ImplWin32_WndProcHandler(hwnd, uMsg, wParam, lParam)) 
        return true; 
 
    switch (uMsg) { 
    case WM_DESTROY: 
        PostQuitMessage(0); 
        return 0; 
 
    case WM_SIZE: 
        if (wParam == SIZE_MINIMIZED) 
            return 0; 
 
        int width = LOWORD(lParam); 
        int height = HIWORD(lParam); 
        glViewport(0, 0, width, height); 
        return 0; 
    } 
    return DefWindowProc(hwnd, uMsg, wParam, lParam); 
}