0
게임 엔진 튜토리얼을 따르려고합니다. 비디오가이 코드를 실행하면 창을 엽니 다. 내가 할 때, 그것은 창문이 만들어지지 않은 경우를 대비해서 내가 가진 오류 메시지를 준다. 이 window.cpp 내 코드입니다GLFW는 내 창을 초기화하지 않을 것입니다.
#include "window.h"
namespace sparky {
namespace graphics {
Window::Window(const char *title, int width, int height) {
m_Title = title;
m_Width = width;
m_Height = height;
if (!init())
glfwTerminate();
}
Window::~Window()
{
glfwTerminate();
}
bool Window::init()
{
if (!glfwInit) {
std::cout << "Failed To Initialize" << std::endl;
return false;
}
m_Window = glfwCreateWindow(m_Width, m_Height, m_Title, NULL, NULL);
if (!m_Window)
{
std::cout << "Window Not Created" << std::endl;
return false;
}
glfwMakeContextCurrent(m_Window);
return true;
}
bool Window::closed() const
{
return glfwWindowShouldClose(m_Window);
}
void Window::update() const
{
glfwPollEvents();
glfwSwapBuffers(m_Window);
}
}
}
, 나는 여기에 내 window.h
#pragma once
#include <GLFW/glfw3.h>
#include <iostream>
namespace sparky {
namespace graphics {
class Window {
private:
const char* m_Title;
int m_Width, m_Height;
GLFWwindow *m_Window;
bool m_Closed;
public:
Window(const char* title, int width, int height);
~Window();
bool closed() const;
void update() const;
private:
bool init();
};
}
}
내 주요 클래스, 윈도우가 오류 라인을 작성하지 얻을
#include <GLFW/glfw3.h>
#include <iostream>
#include "src/graphics/window.h"
int main() {
using namespace sparky;
using namespace graphics;
Window window("Sparks Fly", 800, 600);
while (!window.closed()) {
window.update();
}
system("PAUSE");
return 0;
}
가 sooo를 감사, 나는 한혜진 오랫동안이 문제를 해결하려고했다! – NYBoss00
문제 없습니다! :디 – InternetAussie