Example #1
0
int main(void)
{
    GLFWwindow* window;

    glfwSetErrorCallback(error_callback);

    if (!glfwInit())
        exit(EXIT_FAILURE);

    window = glfwCreateWindow(400, 400, "English 日本語 русский язык 官話", NULL, NULL);
    if (!window)
    {
        glfwTerminate();
        exit(EXIT_FAILURE);
    }

    glfwMakeContextCurrent(window);
    gladLoadGL(glfwGetProcAddress);
    glfwSwapInterval(1);

    while (!glfwWindowShouldClose(window))
    {
        glClear(GL_COLOR_BUFFER_BIT);
        glfwSwapBuffers(window);
        glfwWaitEvents();
    }

    glfwTerminate();
    exit(EXIT_SUCCESS);
}
Example #2
0
GLFWwindow * initTest(int width, int height)
{
    // Create OpenGL window.
    glfwInit();
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
    glfwWindowHint(GLFW_RESIZABLE, GL_TRUE);
    glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
    
    GLFWwindow * window = glfwCreateWindow(width, height, "Robert learns OpenGL", nullptr, nullptr);
    if(window == nullptr)
    {
        std::cout << "Failed to create GLFW window" << std::endl;
        glfwTerminate();
        return nullptr;
    }
    
    glfwMakeContextCurrent(window);
    glfwSetKeyCallback(window, key_callback);
    glfwSetWindowSizeCallback(window, window_size_callback);
    
    // Glad library init.
    if(!gladLoadGL()) {
        std::cout << "Something went wrong!" << std::endl;
        return nullptr;
    }
    
    // Print OpenGL version.
    std::cout << "OpenGL version " << GLVersion.major << "." << GLVersion.minor << std::endl;
    // Set Viewport.
    glViewport(0, 0, width, height);
    
    return window;
}
Example #3
0
GLFWwindow* setupWindowing(const char* windowName, int width, int height) {
    
    // Load GLFW and Create a Window
    glfwInit();
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
    glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
    glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
    GLFWwindow* window = glfwCreateWindow(width, height, windowName, nullptr, nullptr);
    
    // Check for Valid Context
    if (window == nullptr) {
        fprintf(stderr, "Failed to Create OpenGL Context");
        return nullptr;
    }
    
    // Create Context and Load OpenGL Functions
    glfwMakeContextCurrent(window);
    gladLoadGL();
    
    // OpenGL configuration
    glEnable(GL_CULL_FACE);
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    // glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );

    return window;
}
Example #4
0
File: main.cpp Project: Velho/citra
bool GMainWindow::InitializeSystem() {
    // Shutdown previous session if the emu thread is still active...
    if (emu_thread != nullptr)
        ShutdownGame();

    render_window->InitRenderTarget();
    render_window->MakeCurrent();

    if (!gladLoadGL()) {
        QMessageBox::critical(this, tr("Error while starting Citra!"),
                              tr("Failed to initialize the video core!\n\n"
                                 "Please ensure that your GPU supports OpenGL 3.3 and that you have the latest graphics driver."));
        return false;
    }

    // Initialize the core emulation
    System::Result system_result = System::Init(render_window);
    if (System::Result::Success != system_result) {
        switch (system_result) {
        case System::Result::ErrorInitVideoCore:
            QMessageBox::critical(this, tr("Error while starting Citra!"),
                                  tr("Failed to initialize the video core!\n\n"
                                     "Please ensure that your GPU supports OpenGL 3.3 and that you have the latest graphics driver."));
            break;

        default:
            QMessageBox::critical(this, tr("Error while starting Citra!"),
                                  tr("Unknown error (please check the log)!"));
            break;
        }
        return false;
    }
    return true;
}
Example #5
0
void RasterizerGLES3::initialize() {

	if (OS::get_singleton()->is_stdout_verbose()) {
		print_line("Using GLES3 video driver");
	}

#ifdef GLEW_ENABLED
	GLuint res = glewInit();
	ERR_FAIL_COND(res != GLEW_OK);
	if (OS::get_singleton()->is_stdout_verbose()) {
		print_line(String("GLES2: Using GLEW ") + (const char *)glewGetString(GLEW_VERSION));
	}

	// Check for GL 2.1 compatibility, if not bail out
	if (!glewIsSupported("GL_VERSION_3_0")) {
		ERR_PRINT("Your system's graphic drivers seem not to support OpenGL 3.0+ / GLES 3.0, sorry :(\n"
				  "Try a drivers update, buy a new GPU or try software rendering on Linux; Godot will now crash with a segmentation fault.");
		OS::get_singleton()->alert("Your system's graphic drivers seem not to support OpenGL 3.0+ / GLES 3.0, sorry :(\n"
								   "Godot Engine will self-destruct as soon as you acknowledge this error message.",
				"Fatal error: Insufficient OpenGL / GLES drivers");
		// TODO: If it's even possible, we should stop the execution without segfault and memory leaks :)
	}
#endif

#ifdef GLAD_ENABLED

	if (!gladLoadGL()) {
		ERR_PRINT("Error initializing GLAD");
	}

#ifdef __APPLE__
// FIXME glDebugMessageCallbackARB does not seem to work on Mac OS X and opengl 3, this may be an issue with our opengl canvas..
#else
	glEnable(_EXT_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
	glDebugMessageCallbackARB(_gl_debug_print, NULL);
	glEnable(_EXT_DEBUG_OUTPUT);
#endif

#endif

	/*	glDebugMessageControlARB(GL_DEBUG_SOURCE_API_ARB,GL_DEBUG_TYPE_ERROR_ARB,GL_DEBUG_SEVERITY_HIGH_ARB,0,NULL,GL_TRUE);
	glDebugMessageControlARB(GL_DEBUG_SOURCE_API_ARB,GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB,GL_DEBUG_SEVERITY_HIGH_ARB,0,NULL,GL_TRUE);
	glDebugMessageControlARB(GL_DEBUG_SOURCE_API_ARB,GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB,GL_DEBUG_SEVERITY_HIGH_ARB,0,NULL,GL_TRUE);
	glDebugMessageControlARB(GL_DEBUG_SOURCE_API_ARB,GL_DEBUG_TYPE_PORTABILITY_ARB,GL_DEBUG_SEVERITY_HIGH_ARB,0,NULL,GL_TRUE);
	glDebugMessageControlARB(GL_DEBUG_SOURCE_API_ARB,GL_DEBUG_TYPE_PERFORMANCE_ARB,GL_DEBUG_SEVERITY_HIGH_ARB,0,NULL,GL_TRUE);
	glDebugMessageControlARB(GL_DEBUG_SOURCE_API_ARB,GL_DEBUG_TYPE_OTHER_ARB,GL_DEBUG_SEVERITY_HIGH_ARB,0,NULL,GL_TRUE);
	glDebugMessageInsertARB(

			GL_DEBUG_SOURCE_API_ARB,
			GL_DEBUG_TYPE_OTHER_ARB, 1,
			GL_DEBUG_SEVERITY_HIGH_ARB,5, "hello");

*/

	const GLubyte *renderer = glGetString(GL_RENDERER);
	print_line("OpenGL ES 3.0 Renderer: " + String((const char *)renderer));
	storage->initialize();
	canvas->initialize();
	scene->initialize();
}
Example #6
0
void Graphics::init(GLint width, GLint height)
{
    glfwSetErrorCallback(glutil::consoleErrorCallback);

    if (!glfwInit()) {
        glutil::fatal_error("Error initializing glfw.");
    }

    this->width = width;
    this->height = height;

    window = glfwCreateWindow(width, height, "Ray tracing using a Photon Map", NULL, NULL);
    glfwMakeContextCurrent(window);

    if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) {
        if (!gladLoadGL()) {
            glutil::fatal_error("Failed to initialize OpenGL context");
        }
    }
    
    // Define the positions for each of the three vertices of the triangle
    const float positions[] = {
         1.0f, -1.0f, 0.0f,
         1.0f,  1.0f, 0.0f,
        -1.0f, -1.0f, 0.0f,
        -1.0f,  1.0f, 0.0f
    };
    // Create a handle for the position vertex buffer object
    GLuint positionBuffer;
    glGenBuffers(1, &positionBuffer);
    // Set the newly created buffer as the current one
    glBindBuffer(GL_ARRAY_BUFFER, positionBuffer);
    // Send the vertex position data to the current buffer
    glBufferData(GL_ARRAY_BUFFER, sizeof(positions), positions, GL_STATIC_DRAW);

    //******* Connect triangle data with the vertex array object *******
    glGenVertexArrays(1, &vao);
    // Bind the vertex array object
    // The following calls will affect this vertex array object.
    glBindVertexArray(vao);
    // Makes positionBuffer the current array buffer for subsequent calls.
    glBindBuffer(GL_ARRAY_BUFFER, positionBuffer);
    // Attaches positionBuffer to vao, in the 0th attribute location
    glVertexAttribPointer(0, 3, GL_FLOAT, false/*normalized*/, 0/*stride*/, 0/*offset*/);
    glEnableVertexAttribArray(0); // Enable the vertex position attribute

    shaderProgram = glutil::loadShader(
        VERTEX_SHADER_PATH,
        FRAGMENT_SHADER_PATH
    );
    
    frontBuffer = std::vector<glm::vec3>();
    backBuffer = std::vector<glm::vec3>();


    gui.init(window);

    initialized = true;
}
Example #7
0
Error RasterizerGLES3::is_viable() {

#ifdef GLAD_ENABLED
	if (!gladLoadGL()) {
		ERR_PRINT("Error initializing GLAD");
		return ERR_UNAVAILABLE;
	}

// GLVersion seems to be used for both GL and GL ES, so we need different version checks for them
#ifdef OPENGL_ENABLED // OpenGL 3.3 Core Profile required
	if (GLVersion.major < 3 || (GLVersion.major == 3 && GLVersion.minor < 3)) {
#else // OpenGL ES 3.0
	if (GLVersion.major < 3) {
#endif
		return ERR_UNAVAILABLE;
	}

#endif // GLAD_ENABLED
	return OK;
}

void RasterizerGLES3::initialize() {

	print_verbose("Using GLES3 video driver");

#ifdef GLAD_ENABLED
	if (OS::get_singleton()->is_stdout_verbose()) {
		if (GLAD_GL_ARB_debug_output) {
			glEnable(_EXT_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
			glDebugMessageCallbackARB(_gl_debug_print, NULL);
			glEnable(_EXT_DEBUG_OUTPUT);
		} else {
			print_line("OpenGL debugging not supported!");
		}
	}
#endif // GLAD_ENABLED

	/* // For debugging
	if (GLAD_GL_ARB_debug_output) {
		glDebugMessageControlARB(GL_DEBUG_SOURCE_API_ARB,GL_DEBUG_TYPE_ERROR_ARB,GL_DEBUG_SEVERITY_HIGH_ARB,0,NULL,GL_TRUE);
		glDebugMessageControlARB(GL_DEBUG_SOURCE_API_ARB,GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB,GL_DEBUG_SEVERITY_HIGH_ARB,0,NULL,GL_TRUE);
		glDebugMessageControlARB(GL_DEBUG_SOURCE_API_ARB,GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB,GL_DEBUG_SEVERITY_HIGH_ARB,0,NULL,GL_TRUE);
		glDebugMessageControlARB(GL_DEBUG_SOURCE_API_ARB,GL_DEBUG_TYPE_PORTABILITY_ARB,GL_DEBUG_SEVERITY_HIGH_ARB,0,NULL,GL_TRUE);
		glDebugMessageControlARB(GL_DEBUG_SOURCE_API_ARB,GL_DEBUG_TYPE_PERFORMANCE_ARB,GL_DEBUG_SEVERITY_HIGH_ARB,0,NULL,GL_TRUE);
		glDebugMessageControlARB(GL_DEBUG_SOURCE_API_ARB,GL_DEBUG_TYPE_OTHER_ARB,GL_DEBUG_SEVERITY_HIGH_ARB,0,NULL,GL_TRUE);
		glDebugMessageInsertARB(
				GL_DEBUG_SOURCE_API_ARB,
				GL_DEBUG_TYPE_OTHER_ARB, 1,
				GL_DEBUG_SEVERITY_HIGH_ARB,5, "hello");
	}
	*/

	const GLubyte *renderer = glGetString(GL_RENDERER);
	print_line("OpenGL ES 3.0 Renderer: " + String((const char *)renderer));
	storage->initialize();
	canvas->initialize();
	scene->initialize();
}
Example #8
0
int main(int argc, char** argv)
{
    GLFWwindow* window;
    struct nk_context* nk;
    struct nk_font_atlas* atlas;

    glfwSetErrorCallback(error_callback);

    if (!glfwInit())
        exit(EXIT_FAILURE);

    glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE);

    window = glfwCreateWindow(400, 400, "Opacity", NULL, NULL);
    if (!window)
    {
        glfwTerminate();
        exit(EXIT_FAILURE);
    }

    glfwMakeContextCurrent(window);
    gladLoadGL(glfwGetProcAddress);
    glfwSwapInterval(1);

    nk = nk_glfw3_init(window, NK_GLFW3_INSTALL_CALLBACKS);
    nk_glfw3_font_stash_begin(&atlas);
    nk_glfw3_font_stash_end();

    while (!glfwWindowShouldClose(window))
    {
        int width, height;
        struct nk_rect area;

        glfwGetWindowSize(window, &width, &height);
        area = nk_rect(0.f, 0.f, (float) width, (float) height);

        glClear(GL_COLOR_BUFFER_BIT);
        nk_glfw3_new_frame();
        if (nk_begin(nk, "", area, 0))
        {
            float opacity = glfwGetWindowOpacity(window);
            nk_layout_row_dynamic(nk, 30, 2);
            if (nk_slider_float(nk, 0.f, &opacity, 1.f, 0.001f))
                glfwSetWindowOpacity(window, opacity);
            nk_labelf(nk, NK_TEXT_LEFT, "%0.3f", opacity);
        }

        nk_end(nk);
        nk_glfw3_render(NK_ANTI_ALIASING_ON);

        glfwSwapBuffers(window);
        glfwWaitEventsTimeout(1.0);
    }

    nk_glfw3_shutdown();
    glfwTerminate();
    exit(EXIT_SUCCESS);
}
Example #9
0
	void OpenGL::initContext()
	{
		if (!gladLoadGL())
		{
			Console::error << "[OpenGL] initialize OpenGL fail." << Console::endl;
		}
		glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
		glEnable(GL_BLEND);
	}
Example #10
0
extern struct gl_platform *gl_platform_create(gs_device_t *device,
		uint32_t adapter)
{
	/* There's some trickery here... we're mixing libX11, xcb, and GLX
	   For an explanation see here: http://xcb.freedesktop.org/MixingCalls/
	   Essentially, GLX requires Xlib. Everything else we use xcb. */
	struct gl_platform * plat = bmalloc(sizeof(struct gl_platform));
	Display * display = open_windowless_display();

	if (!display) {
		goto fail_display_open;
	}

	XSetEventQueueOwner(display, XCBOwnsEventQueue);
	XSetErrorHandler(x_error_handler);

	/* We assume later that cur_swap is already set. */
	device->plat = plat;

	plat->display = display;

	if (!gl_context_create(plat)) {
		blog(LOG_ERROR, "Failed to create context!");
		goto fail_context_create;
	}

	if (!glXMakeContextCurrent(plat->display, plat->pbuffer, plat->pbuffer,
				plat->context)) {
		blog(LOG_ERROR, "Failed to make context current.");
		goto fail_make_current;
	}

	if (!gladLoadGL()) {
		blog(LOG_ERROR, "Failed to load OpenGL entry functions.");
		goto fail_load_gl;
	}

	blog(LOG_INFO, "OpenGL version: %s\n", glGetString(GL_VERSION));

	goto success;

fail_make_current:
	gl_context_destroy(plat);
fail_context_create:
fail_load_gl:
	XCloseDisplay(display);
fail_display_open:
	bfree(plat);
	plat = NULL;
success:
	UNUSED_PARAMETER(adapter);
	return plat;
}
Example #11
0
bool initSDL(SDL_Window * &window, SDL_GLContext &context)
{
    // init sdl
    SDL_Init(SDL_INIT_VIDEO);

    // set requested opengl context params
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION,2);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION,1);
    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,1);

    // create a window
    window = SDL_CreateWindow(
                "OpenGL",100,100,800,480,SDL_WINDOW_OPENGL|SDL_WINDOW_RESIZABLE);

    if(!window) {
        std::cout << "Error: Failed to create window: "
                  << SDL_GetError() << std::endl;
        SDL_Quit();
        return false;
    }

    // get the opengl context
    context = SDL_GL_CreateContext(window);
    if(!context) {
        std::cout << "Error: Failed to create context: "
                  << SDL_GetError() << std::endl;
        SDL_Quit();
        return false;
    }

    // load opengl functions (must be done after
    // getting a valid context)
    if(!gladLoadGL()) {
        std::cout << "Error loading OpenGL functions!" << std::endl;
        SDL_GL_DeleteContext(context);
        SDL_Quit();
        return false;
    }

    int ok;
    SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER,&ok);
    std::cout << "OpenGL version: " << glGetString(GL_VERSION) << std::endl;
    std::cout << "Double buffering: " << ok << std::endl;

    // set vsync
    if(SDL_GL_SetSwapInterval(1) < 0) {
        std::cout << "Warn: Failed to set vsync: "
                  << SDL_GetError() << std::endl;
    }

    return true;
}
Example #12
0
int main(int argc, char** argv)
{
    // Setup GLFW
    glfwInit();

    // Load in OGL functions
    if (!gladLoadGL()) {
        std::cout << "Failed to initialize OpenGL context" << std::endl;
        return -1;
    }

    return 0;
}
Example #13
0
int main(){
    sf::Window window(sf::VideoMode(800, 600), "OpenGL");
    //glewInit();
    gladLoadGL(); 
    /*
    GLfloat vertices[] = {
       -0.5f, -0.5f, 0.0f,
        0.5f, -0.5f, 0.0f,
        0.0f, 0.5f, 0.0f
    };
    */ 


    auto program = ResourceManager::load_shader("vertex.glsl", "fragment.glsl", "default");

	SpriteBatch batch(800, 600);
	batch.set_shader(program);
	auto tex = ResourceManager::load_texture("man.png", "man");
	auto leaf = ResourceManager::load_texture("leaf.png", "leaf");
	Animation sprite(leaf, 0, 0, 34, 50, 200.f, 200.f);
	//sprite.add_frame(34, 0, 34, 50);
	//sprite.add_frame(68, 0, 34, 50);
	//sprite.add_frame(102, 0, 34, 50);
	sprite.set_updates_per_second(5.f);
	sprite.set_grid(34, 50);
	sprite.add_grid_frame(0, 1, 3);
	Sprite test(tex, 0, 0, 30, 40, 200.f, 200.f); 
	sf::Clock clock;
	float x = 100.f;
	float y = 100.f;
	double dt = 0;
    while (true){
		sf::Time dt = clock.restart();
        sf::Event event;
        while(window.pollEvent(event)){
            if (event.type == sf::Event::Closed)
                return 0;
        }

        glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
		batch.draw(sprite);
		y = y + (30 * dt.asSeconds());
		sprite.set_position(x, y);
		sprite.update(dt.asSeconds());
		batch.end();
        window.display();
    }

	ResourceManager::clear();
    return 0;
}
Example #14
0
/// Initialize the renderer
void RendererOpenGL::Init() {
    render_window->MakeCurrent();

    // TODO: Make frontends initialize this, so they can use gladLoadGLLoader with their own loaders
    if (!gladLoadGL()) {
        LOG_CRITICAL(Render_OpenGL, "Failed to initialize GL functions! Exiting...");
        exit(-1);
    }

    LOG_INFO(Render_OpenGL, "GL_VERSION: %s", glGetString(GL_VERSION));
    LOG_INFO(Render_OpenGL, "GL_VENDOR: %s", glGetString(GL_VENDOR));
    LOG_INFO(Render_OpenGL, "GL_RENDERER: %s", glGetString(GL_RENDERER));
    InitOpenGLObjects();
}
bool
ofxsLoadOpenGLOnce()
{
    // Ensure that OpenGL functions loading is thread-safe
    AutoMutex locker(&g_glLoadOnceMutex);

    if (g_glLoaded) {
        // Already loaded, don't do it again
        return true;
    }

    // Reasons for failure might be:
    // - opengl32.dll was not found, or libGL.so was not found or OpenGL.framework was not found
    // - glGetString does not return a valid version
    // Note: It does NOT check that required extensions and functions have actually been found
    bool glLoaded = gladLoadGL();

    g_glLoaded = glLoaded;

    // If only EXT_framebuffer is present and not ARB link functions
    if (glLoaded && GLAD_GL_EXT_framebuffer_object && !GLAD_GL_ARB_framebuffer_object) {
        glad_glIsRenderbuffer = glad_glIsRenderbufferEXT;
        glad_glBindRenderbuffer = glad_glBindRenderbufferEXT;
        glad_glDeleteRenderbuffers = glad_glDeleteRenderbuffersEXT;
        glad_glGenRenderbuffers = glad_glGenRenderbuffersEXT;
        glad_glRenderbufferStorage = glad_glRenderbufferStorageEXT;
        glad_glGetRenderbufferParameteriv = glad_glGetRenderbufferParameterivEXT;
        glad_glBindFramebuffer = glad_glBindFramebufferEXT;
        glad_glIsFramebuffer = glad_glIsFramebufferEXT;
        glad_glDeleteFramebuffers = glad_glDeleteFramebuffersEXT;
        glad_glGenFramebuffers = glad_glGenFramebuffersEXT;
        glad_glCheckFramebufferStatus = glad_glCheckFramebufferStatusEXT;
        glad_glFramebufferTexture1D = glad_glFramebufferTexture1DEXT;
        glad_glFramebufferTexture2D = glad_glFramebufferTexture2DEXT;
        glad_glFramebufferTexture3D = glad_glFramebufferTexture3DEXT;
        glad_glFramebufferRenderbuffer = glad_glFramebufferRenderbufferEXT;
        glad_glGetFramebufferAttachmentParameteriv = glad_glGetFramebufferAttachmentParameterivEXT;
        glad_glGenerateMipmap = glad_glGenerateMipmapEXT;
    }

    if (glLoaded && GLAD_GL_APPLE_vertex_array_object && !GLAD_GL_ARB_vertex_buffer_object) {
        glad_glBindVertexArray = glad_glBindVertexArrayAPPLE;
        glad_glDeleteVertexArrays = glad_glDeleteVertexArraysAPPLE;
        glad_glGenVertexArrays = glad_glGenVertexArraysAPPLE;
        glad_glIsVertexArray = glad_glIsVertexArrayAPPLE;
    }

    return g_glLoaded;
} // ofxsLoadGLOnce
Example #16
0
struct gl_platform *gl_platform_create(gs_device_t *device, uint32_t adapter)
{
	struct gl_platform *plat = bzalloc(sizeof(struct gl_platform));
	struct dummy_context dummy;
	struct gs_init_data info = {0};
	int pixel_format;
	PIXELFORMATDESCRIPTOR pfd;

	memset(&dummy, 0, sizeof(struct dummy_context));
	init_dummy_swap_info(&info);

	if (!gl_dummy_context_init(&dummy))
		goto fail;
	if (!gl_init_extensions(dummy.hdc))
		goto fail;
	if (!register_dummy_class())
		return false;
	if (!create_dummy_window(plat))
		return false;

	/* you have to have a dummy context open before you can actually
	 * use wglChoosePixelFormatARB */
	if (!gl_getpixelformat(dummy.hdc, &info, &pixel_format, &pfd))
		goto fail;

	gl_dummy_context_free(&dummy);

	if (!init_default_swap(plat, device, pixel_format, &pfd))
		goto fail;

	plat->hrc = gl_init_context(plat->window.hdc);
	if (!plat->hrc)
		goto fail;

	if (!gladLoadGL()) {
		blog(LOG_ERROR, "Failed to initialize OpenGL entry functions.");
		goto fail;
	}

	UNUSED_PARAMETER(adapter);
	return plat;

fail:
	blog(LOG_ERROR, "gl_platform_create failed");
	gl_platform_destroy(plat);
	gl_dummy_context_free(&dummy);
	return NULL;
}
Example #17
0
GLFWwindow* setupWindow(bool fullscreen) {
    GLFWwindow* window;
    
    if (!glfwInit()){
        fprintf(stderr, "Failed to initialize GLFW\n");
        return NULL;
    }
    
    doHints();
    
    const GLFWvidmode * mode = glfwGetVideoMode(glfwGetPrimaryMonitor());
    
    if (fullscreen) {
        window = glfwCreateWindow( mode->width, mode->height, "SLUMBER", glfwGetPrimaryMonitor(), NULL);
    }
    else {
        window = glfwCreateWindow( mode->width, mode->height, "SLUMBER", NULL, NULL);
    }
    
    set_window_width(mode->width);
    set_window_height(mode->height);
    
    if(window == NULL){
        fprintf(stderr, "Failed to initialize window\n");
        glfwTerminate();
        return NULL;
    }
    
    glfwMakeContextCurrent(window);
    
    // Initialize GLAD
    if (!gladLoadGL()) {
        printf("Couldn't initialize GLAD\n");
        glfwDestroyWindow(window); 
        glfwTerminate();
        return NULL;
    }
    
    
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_MULTISAMPLE);
    glEnable (GL_BLEND);
    glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//    glClearColor(.051f, .447f, .60f, 0.0f);
    glClearColor(.1f, .0, .0f, 0.0f);
    
    return window;
}
Example #18
0
void Init()
{
	// get application and renderer
	muggle::Application* app = muggle::GetApplication();
	renderer = app->getRenderer();
	renderer->setClearColor(muggle::vec4f(0.3f, 0.3f, 0.3f, 0.3f));

	// initialize glad
	if (!gladLoadGL())
	{
		MASSERT_MSG(0, "Failed in gladLoadGL");
		return;
	}

	PrepareData();
	PrepareShader();	
}
Example #19
0
int main()
{
    // init sdl
    SDL_Init(SDL_INIT_VIDEO);

    // set requested opengl context params
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION,2);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION,1);

    // create a window
    SDL_Window * window = SDL_CreateWindow("OpenGL",100,100,800,480,SDL_WINDOW_OPENGL);

    // get the opengl context
    SDL_GLContext context = SDL_GL_CreateContext(window);

    // load opengl functions (must be done after
    // getting a valid context)
    if(!gladLoadGL()) {
        std::cout << "Error loading OpenGL functions!" << std::endl;
        SDL_GL_DeleteContext(context);
        SDL_Quit();
        return -1;
    }


    std::cout << "OpenGL version: " << glGetString(GL_VERSION) << std::endl;

    // poll for events from the window
    SDL_Event windowEvent;
    while(true) {
        if(SDL_PollEvent(&windowEvent)) {
            if(windowEvent.type == SDL_QUIT) {
                break;
            }
        }

        // update window framebuffer for double
        // buffered context (default)
        SDL_GL_SwapWindow(window);
    }


    SDL_GL_DeleteContext(context);
    SDL_Quit();
	return 0;
}
Example #20
0
File: main.cpp Project: sliz1/ubw
int main(int argc, char *argv[]) {
  glfwSetErrorCallback(GLFWErrorCallback);
  if (!glfwInit()) {
    kLogger.Log("ERROR: Cannot init GLFW3");
    exit(EXIT_FAILURE);
  }

  glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
  glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
  glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
  glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
  glfwWindowHint(GLFW_RESIZABLE, GL_TRUE);

  auto window = glfwCreateWindow(kWindowSize.x, kWindowSize.y,
                                 kWindowTitle.c_str(), nullptr, nullptr);
  if (!window) {
    kLogger.Log("ERROR: Cannot create OpenGL window");
    exit(EXIT_FAILURE);
  }

  glfwMakeContextCurrent(window);
  glfwSetKeyCallback(window, GLFWKeyboardCallback);
  glfwSetMouseButtonCallback(window, GLFWMouseButtonCallback);
  glfwSetWindowSizeCallback(window, GLFWWindowReshapeCallback);

  if (!gladLoadGL()) {
    kLogger.Log("ERROR: Cannot init GLAD");
    glfwTerminate();
    exit(EXIT_FAILURE);
  }

  kLogger.Log(Kensei::GLInfoHelper::getGLParams().str());

  while (!glfwWindowShouldClose(window)) {
    glClearColor(0.25f, 0.25f, 0.25f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT);

    UpdateFPSCounter(window);

    glfwSwapBuffers(window);
    glfwPollEvents();
  }

  glfwTerminate();
  return EXIT_SUCCESS;
}
Example #21
0
Window::Window(const std::string& title, uint32_t width, uint32_t height)
    : window_(nullptr)
    , title_(title)
    , width_(width)
    , height_(height)
{
    std::call_once(sdl_init_video_, [] () {
        if(SDL_Init(SDL_INIT_VIDEO) != 0)
        {
            fprintf(stderr, "Failed to initialize SDL Video\n");
            assert(false);
        }
    });
    
    if(title.length() == 0)
    {
        title_ = PACKAGE_STRING;
    }
    
    window_ = SDL_CreateWindow(
        title_.c_str(),
        SDL_WINDOWPOS_CENTERED,
        SDL_WINDOWPOS_CENTERED,
        width_,
        height_,
        SDL_WINDOW_OPENGL
    );

    if(!window_)
    {
        fprintf(stderr, "Failed to create the SDL window\n");
        assert(false);
    }
    
    context_ = SDL_GL_CreateContext(window_);

    std::call_once(glad_init_, [] () {
        if(!gladLoadGL())
        {
            fprintf(stderr, "Failed to initialize OpenGL libraries\n");
            assert(false);
        }
    });
    
    SDL_GL_SetSwapInterval(1);
}
Example #22
0
int
main()
{
  SDL_Init(SDL_INIT_VIDEO); // Initialize SDL2

  SDL_Window* window; // Declare a pointer to an SDL_Window
  SDL_GLContext context;

  SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
  SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
  SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
  SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
  // Create an application window with the following settings:
  window = SDL_CreateWindow(
    "An SDL2 window",        //    const char* title
    SDL_WINDOWPOS_UNDEFINED, //    int x: initial x position
    SDL_WINDOWPOS_UNDEFINED, //    int y: initial y position
    640,                     //    int w: width, in pixels
    480,                     //    int h: height, in pixels
    SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN         //    Uint32 flags: window options, see docs
    );
  context = SDL_GL_CreateContext(window);
  gladLoadGL();
  // Check that the window was successfully made
  if (window == NULL) {
    // In the event that the window could not be made...
    std::cout << "Could not create window: " << SDL_GetError() << '\n';
    SDL_Quit();
    return 1;
  }
  std::cout << SDL_GetError() << '\n';
  /* This makes our buffer swap syncronized with the monitor's vertical refresh */
  SDL_GL_SetSwapInterval(1);

  /* Swap our back buffer to the front */
  RunGame(window);
  // The window is open: enter program loop (see SDL_PollEvent)
  // Close and destroy the window
  SDL_DestroyWindow(window);

  // Clean up SDL2 and exit the program
  SDL_Quit();
  return 0;
}
Example #23
0
void TRM_BeginRegistration( glconfig_t *config  ) {
	
	Com_Printf("================================================================\n");
	Com_Printf("Initializing Renderer\n");
	Com_Printf("================================\n");
	
	windowDesc_t windesc { GRAPHICS_API_OPENGL };
	tr.window = ri->WIN_Init(&windesc, config);
	
	if (!glad_initialized) { // TRM_BeginRegistration can be called more than once, but this only gets called once for the entire program lifetime
		gladLoadGL();
		glad_initialized = true;
	}
	
	config->vendor_string = (const char *) glGetString (GL_VENDOR);
	config->renderer_string = (const char *) glGetString (GL_RENDERER);
	config->version_string = (const char *) glGetString (GL_VERSION);
	config->extensions_string = (const char *) glGetString (GL_EXTENSIONS);
	
	Com_Printf("Vendor: %s\nRenderer: %s\nVersion: %s\n", config->vendor_string, config->renderer_string, config->version_string);
	
	glGetIntegerv(GL_MAX_TEXTURE_SIZE, &config->maxTextureSize);
	config->maxActiveTextures = 0; // old GL
	if (GLAD_GL_EXT_texture_filter_anisotropic)
		glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &config->maxTextureFilterAnisotropy);
	else config->maxTextureFilterAnisotropy = 0;
	
	glEnable(GL_SCISSOR_TEST);

	config->isFullscreen = qfalse;
	config->stereoEnabled = qfalse;
	
	glConfig = *config;
	
	TRM_Cvars();
	
	R_InitFonts();
	
	if (!rendm::init()) {
		srcprintf_fatal("Failed to initialize RendM (rd-modern)");
	}
	
	Com_Printf("================================================================\n");
}
Example #24
0
File: timeout.c Project: glfw/glfw
int main(void)
{
    GLFWwindow* window;

    srand((unsigned int) time(NULL));

    glfwSetErrorCallback(error_callback);

    if (!glfwInit())
        exit(EXIT_FAILURE);

    window = glfwCreateWindow(640, 480, "Event Wait Timeout Test", NULL, NULL);
    if (!window)
    {
        glfwTerminate();
        exit(EXIT_FAILURE);
    }

    glfwMakeContextCurrent(window);
    gladLoadGL(glfwGetProcAddress);
    glfwSetKeyCallback(window, key_callback);

    while (!glfwWindowShouldClose(window))
    {
        int width, height;
        float r = nrand(), g = nrand(), b = nrand();
        float l = (float) sqrt(r * r + g * g + b * b);

        glfwGetFramebufferSize(window, &width, &height);

        glViewport(0, 0, width, height);
        glClearColor(r / l, g / l, b / l, 1.f);
        glClear(GL_COLOR_BUFFER_BIT);
        glfwSwapBuffers(window);

        glfwWaitEventsTimeout(1.0);
    }

    glfwDestroyWindow(window);

    glfwTerminate();
    exit(EXIT_SUCCESS);
}
Example #25
0
int main(int argc, char * argv[]) {

    // Load GLFW and Create a Window
    glfwInit();
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
    glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
    glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
    auto mWindow = glfwCreateWindow(mWidth, mHeight, "OpenGL", nullptr, nullptr);

    // Create Context and Load OpenGL Functions
    glfwMakeContextCurrent(mWindow);
    gladLoadGL();
    fprintf(stderr, "OpenGL %s\n", glGetString(GL_VERSION));

	// DSARD initialization
	dsard::HelloWorld helloWorld;
	helloWorld.init();




    // Rendering Loop
    while (glfwWindowShouldClose(mWindow) == false) {
        if (glfwGetKey(mWindow, GLFW_KEY_ESCAPE) == GLFW_PRESS)
            glfwSetWindowShouldClose(mWindow, true);

        // Background Fill Color
        glClearColor(0.25f, 0.25f, 0.25f, 1.0f);
        glClear(GL_COLOR_BUFFER_BIT);


		// DSARD draw
		helloWorld.draw();

        // Flip Buffers and Draw
        glfwSwapBuffers(mWindow);
        glfwPollEvents();
    }   glfwTerminate();
    return EXIT_SUCCESS;
}
Example #26
0
void OpenGLRenderer::SetupOldGL(HWND hWnd)
{
	mHdc = GetDC(hWnd);

	PIXELFORMATDESCRIPTOR pfd;
	ZeroMemory(&pfd, sizeof(pfd));
	pfd.nSize = sizeof(pfd);
	pfd.nVersion = 1;
	pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
	pfd.iPixelType = PFD_TYPE_RGBA;
	pfd.cColorBits = 24;
	pfd.cDepthBits = 16;
	pfd.iLayerType = PFD_MAIN_PLANE;
	int iFormat = ChoosePixelFormat(mHdc, &pfd);
	SetPixelFormat(mHdc, iFormat, &pfd);

	mpDev = wglCreateContext(mHdc);
	wglMakeCurrent(mHdc, mpDev);

	gladLoadGL();
}
Example #27
0
void Init()
{
	// get application and renderer
	muggle::Application* app = muggle::GetApplication();
	renderer = app->getRenderer();
	renderer->setClearColor(muggle::vec4f(0.3f, 0.3f, 0.3f, 0.3f));

	// initialize glad
	if (!gladLoadGL())
	{
		MASSERT_MSG(0, "Failed in gladLoadGL");
		return;
	}

	PrepareShader();
	PrepareData();

	camera.setMoveSpeed(0.1f);
	camera.setPosition(muggle::vec3f(0.0f, 0.0f, -5.0f));

	// camera initialize
	camera.Update();
}
Example #28
0
File: tearing.c Project: glfw/glfw
int main(int argc, char** argv)
{
    unsigned long frame_count = 0;
    double last_time, current_time;
    GLFWwindow* window;
    GLuint vertex_buffer, vertex_shader, fragment_shader, program;
    GLint mvp_location, vpos_location;

    glfwSetErrorCallback(error_callback);

    if (!glfwInit())
        exit(EXIT_FAILURE);

    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);

    window = glfwCreateWindow(640, 480, "Tearing detector", NULL, NULL);
    if (!window)
    {
        glfwTerminate();
        exit(EXIT_FAILURE);
    }

    glfwMakeContextCurrent(window);
    gladLoadGL(glfwGetProcAddress);
    set_swap_interval(window, 0);

    last_time = glfwGetTime();
    frame_rate = 0.0;
    swap_tear = (glfwExtensionSupported("WGL_EXT_swap_control_tear") ||
                 glfwExtensionSupported("GLX_EXT_swap_control_tear"));

    glfwSetKeyCallback(window, key_callback);

    glGenBuffers(1, &vertex_buffer);
    glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer);
    glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);

    vertex_shader = glCreateShader(GL_VERTEX_SHADER);
    glShaderSource(vertex_shader, 1, &vertex_shader_text, NULL);
    glCompileShader(vertex_shader);

    fragment_shader = glCreateShader(GL_FRAGMENT_SHADER);
    glShaderSource(fragment_shader, 1, &fragment_shader_text, NULL);
    glCompileShader(fragment_shader);

    program = glCreateProgram();
    glAttachShader(program, vertex_shader);
    glAttachShader(program, fragment_shader);
    glLinkProgram(program);

    mvp_location = glGetUniformLocation(program, "MVP");
    vpos_location = glGetAttribLocation(program, "vPos");

    glEnableVertexAttribArray(vpos_location);
    glVertexAttribPointer(vpos_location, 2, GL_FLOAT, GL_FALSE,
                          sizeof(vertices[0]), (void*) 0);

    while (!glfwWindowShouldClose(window))
    {
        int width, height;
        mat4x4 m, p, mvp;
        float position = cosf((float) glfwGetTime() * 4.f) * 0.75f;

        glfwGetFramebufferSize(window, &width, &height);

        glViewport(0, 0, width, height);
        glClear(GL_COLOR_BUFFER_BIT);

        mat4x4_ortho(p, -1.f, 1.f, -1.f, 1.f, 0.f, 1.f);
        mat4x4_translate(m, position, 0.f, 0.f);
        mat4x4_mul(mvp, p, m);

        glUseProgram(program);
        glUniformMatrix4fv(mvp_location, 1, GL_FALSE, (const GLfloat*) mvp);
        glDrawArrays(GL_TRIANGLE_FAN, 0, 4);

        glfwSwapBuffers(window);
        glfwPollEvents();

        frame_count++;

        current_time = glfwGetTime();
        if (current_time - last_time > 1.0)
        {
            frame_rate = frame_count / (current_time - last_time);
            frame_count = 0;
            last_time = current_time;
            update_window_title(window);
        }
    }

    glfwTerminate();
    exit(EXIT_SUCCESS);
}
Example #29
0
File: gl2.cpp Project: seshbot/glpp
 void init() {
    if (!gladLoadGL()) {
       throw std::runtime_error("Cannot initialise GL");
    }
 }
Example #30
0
void OpenGLRenderer::SetupGLCore(HWND hWnd)
{
	HINSTANCE hInstance = reinterpret_cast<HINSTANCE>(GetWindowLong(hWnd, GWL_HINSTANCE));
	registerClass(hInstance);

	HWND fakeWND = CreateWindow(
		"Core", "Fake Window",      // window class, title
		WS_CLIPSIBLINGS | WS_CLIPCHILDREN, // style
		0, 0,                       // position x, y
		1, 1,                       // width, height
		NULL, NULL,                 // parent window, menu
		hInstance, NULL);           // instance, param

	HDC fakeDC = GetDC(fakeWND);        // Device Context

	PIXELFORMATDESCRIPTOR fakePFD;
	ZeroMemory(&fakePFD, sizeof(fakePFD));
	fakePFD.nSize = sizeof(fakePFD);
	fakePFD.nVersion = 1;
	fakePFD.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
	fakePFD.iPixelType = PFD_TYPE_RGBA;
	fakePFD.cColorBits = 32;
	fakePFD.cAlphaBits = 8;
	fakePFD.cDepthBits = 24;

	int fakePFDID = ChoosePixelFormat(fakeDC, &fakePFD);
	if (fakePFDID == 0) {
		OutputDebugString("Error choosing pixel format.");
	}

	if (SetPixelFormat(fakeDC, fakePFDID, &fakePFD) == false) {
		OutputDebugString("Error setting pixel format.");
	}

	HGLRC fakeRC = wglCreateContext(fakeDC);    // Rendering Contex

	if (fakeRC == 0) {
		OutputDebugString("Error creating initial gl context.");
	}

	if (wglMakeCurrent(fakeDC, fakeRC) == false) {
		OutputDebugString("Error setting initial gl context.");
	}

	const int pixelAttribs[] = {
		WGL_DRAW_TO_WINDOW_ARB, GL_TRUE,
		WGL_SUPPORT_OPENGL_ARB, GL_TRUE,
		WGL_DOUBLE_BUFFER_ARB, GL_TRUE,
		WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB,
		WGL_ACCELERATION_ARB, WGL_FULL_ACCELERATION_ARB,
		WGL_COLOR_BITS_ARB, 32,
		WGL_ALPHA_BITS_ARB, 8,
		WGL_DEPTH_BITS_ARB, 24,
		WGL_STENCIL_BITS_ARB, 8,
		WGL_SAMPLE_BUFFERS_ARB, GL_TRUE,
		WGL_SAMPLES_ARB, 4,
		0
	};

	PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB = nullptr;
	wglChoosePixelFormatARB = reinterpret_cast<PFNWGLCHOOSEPIXELFORMATARBPROC>(wglGetProcAddress("wglChoosePixelFormatARB"));
	if (wglChoosePixelFormatARB == nullptr) {

	}

	PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = nullptr;
	wglCreateContextAttribsARB = reinterpret_cast<PFNWGLCREATECONTEXTATTRIBSARBPROC>(wglGetProcAddress("wglCreateContextAttribsARB"));
	if (wglCreateContextAttribsARB == nullptr) {

	}

	mHdc = GetDC(hWnd);

	int pixelFormatID; UINT numFormats;
	bool status = wglChoosePixelFormatARB(mHdc, pixelAttribs, NULL, 1, &pixelFormatID, &numFormats);

	if (status == false || numFormats == 0) {

	}

	const int pixelAttribsModern[] = {
		WGL_DRAW_TO_WINDOW_ARB, GL_TRUE,
		WGL_SUPPORT_OPENGL_ARB, GL_TRUE,
		WGL_DOUBLE_BUFFER_ARB, GL_TRUE,
		WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB,
		WGL_ACCELERATION_ARB, WGL_FULL_ACCELERATION_ARB,
		WGL_COLOR_BITS_ARB, 32,
		WGL_ALPHA_BITS_ARB, 8,
		WGL_DEPTH_BITS_ARB, 24,
		WGL_STENCIL_BITS_ARB, 8,
		WGL_SAMPLE_BUFFERS_ARB, GL_TRUE,
		WGL_SAMPLES_ARB, 4,
		0
	};

	int pixelFormatIDModern; UINT numFormatsModern;
	status = wglChoosePixelFormatARB(mHdc, pixelAttribsModern, NULL, 1, &pixelFormatIDModern, &numFormatsModern);

	if (status == false || numFormats == 0) {

	}

	PIXELFORMATDESCRIPTOR PFD;
	DescribePixelFormat(mHdc, pixelFormatID, sizeof(PFD), &PFD);
	SetPixelFormat(mHdc, pixelFormatID, &PFD);

	const int major_min = 4, minor_min = 5;
	int  contextAttribs[] = {
		WGL_CONTEXT_MAJOR_VERSION_ARB, major_min,
		WGL_CONTEXT_MINOR_VERSION_ARB, minor_min,
		WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
		0
	};

	HGLRC RC = wglCreateContextAttribsARB(mHdc, 0, contextAttribs);
	if (RC == NULL) {

	}

	wglMakeCurrent(NULL, NULL);
	wglDeleteContext(fakeRC);
	ReleaseDC(fakeWND, fakeDC);
	DestroyWindow(fakeWND);
	if (!wglMakeCurrent(mHdc, RC)) {

	}

	gladLoadGL();
}