Em mới học OpenGL, em làm theo y chang tut trên Youtube nhưng vẫn không được :’(
#include "window.h"
#include <iostream>
using namespace std;
namespace hoangtrung1999 {
namespace graphics{
Window::Window(const char *name , int width , int height)
{
m_Name = name;
m_Width = width;
m_Height = height;
if(!init())
{
glfwTerminate();
}
}
Window::~Window()
{
glfwTerminate();
}
bool Window::init()
{
if(!glfwInit())
{
cout<<"Fail to initialize GLFW!\n";
return false;
}
m_window = glfwCreateWindow (m_Width , m_Height, m_Name , NULL , NULL);
if(!m_window)
{
cout<<"Fail create window";
return false;
}
glfwMakeContextCurrent(m_window);
return true;
}
bool Window::closed() const
{
return glfwWindowShouldClose(m_window);
}
void Window::Update() const
{
glfwSwapBuffers(m_window);
glfwPollEvents();
}
}
}`
#include <Windows.h>
#include <GL\glew.h>
#include <GL\freeglut.h>
#include <iostream>
#include <GLFW\glfw3.h>
#include "src\graphics\window.h"
using namespace std;
int main ()
{
using namespace hoangtrung1999;
using namespace graphics;
Window window ("hoangtrung1999" , 800 , 600);
while (!window.closed())
{
window.Update();
}
return 0;
}`
`#pragma once
#include <GLFW\glfw3.h>
namespace hoangtrung1999 {
namespace graphics{
class Window
{
private:
const char *m_Name;
int m_Width, m_Height;
GLFWwindow *m_window;
bool m_Close;
public:
Window (const char *name , int width , int height);
~Window ();
bool closed() const;
void Update() const;
private:
bool init();
};
}
}`
@nguyenchiemminhvu , @Giay_Nhap
Khi chạy nó chỉ hiện “Fail to create window” chứ không báo lỗi @@