TheCherno / Sparky

Cross-Platform High Performance 2D/3D game engine for people like me who like to write code.
Apache License 2.0
1.1k stars 222 forks source link

Failed to create GLFW Window #8

Closed B1Q closed 9 years ago

B1Q commented 9 years ago

i watched the EP1 video and did exactly the same and i checked my code 3 times

and iam getting this error (in the cmd) "Failed to create GLFW Window"

here's my windows.h

pragma once

include

include <GLFW/glfw3.h>

namespace DFQEngine { namespace graphics {

    class Window
    {
    private:
        const char *m_Title;
        int m_Width, m_Height;
        GLFWwindow *m_Window;
        bool m_Closed;
    public:
        Window(const char *name, int width, int height);
        ~Window();
        bool closed() const;
        void update() const;
    private:
        bool init();
    };

}

}

and here's my windows.cpp

include "window.h"

namespace DFQEngine { 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 GLFW!" << std::endl;
        return false;
    }
    m_Window = glfwCreateWindow(m_Width, m_Height, m_Title, NULL, NULL);
    if (!m_Window)
    {
        std::cout << "Failed to create GLFW window!" << std::endl;
        return false;
    }
    glfwMakeContextCurrent(m_Window);
    return true;
}

bool Window::closed() const
{
    return glfwWindowShouldClose(m_Window) == 1;
}

void Window::update() const
{
    glfwPollEvents();
    glfwSwapBuffers(m_Window);
}

} }

and my main.cpp

include

include "src/graphics/window.h"

int main() { using namespace DFQEngine; using namespace graphics;

Window test("$engine", 800, 600);

while (!test.closed())
{
    test.update();
}

system("PAUSE");
return 0;

}

ncortiz commented 9 years ago

That is because:

B1Q commented 9 years ago

no it's not windows.h i called window.h i already paste the code

about the const char *name i changed it to title already but nothing new

downloaded the source code from github and same error occurs

On Mon, Apr 6, 2015 at 12:56 AM, ncortiz notifications@github.com wrote:

That is because:

  • You called the header ''windows.h" instead of "window.h" and then you put on "windows.cpp" which should also be called "window.cpp" "#include "window.h""
  • You put in the header "Window(const char name, int width, int height);" and in the "windows.cpp" you put "Window::Window(const char title, int width, int height)" in the constructor.

— Reply to this email directly or view it on GitHub https://github.com/TheCherno/Sparky/issues/8#issuecomment-89867735.

PistonMiner commented 9 years ago

Did you use the 32 bit version of GLFW or the 64 bit version? I found that the 64 bit version can sometimes cause trouble; so if you used the 64 bit version, try using the 32 bit version.

thebirk commented 9 years ago

Hi.

Usually GitHub issuses are used for the sourcecode in the Git repository itself.

For problems regarding TheCherno's series use his forums at http://thecherno.com/