Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Developing U++ » UppHub » GLFW Package
GLFW Package [message #55703] Tue, 01 December 2020 19:51 Go to previous message
Xemuth is currently offline  Xemuth
Messages: 387
Registered: August 2018
Location: France
Senior Member
Here is a GLFW package compatible Windows and Linux.

No flag have to be set to make it compatible with your operating system.

Default POSIX/LINUX implementation use X11. If you want to use Wayland or Mesa instead use flag MESA or WAYLAND

UPDATE : The package present in this post is up to date (at least until UppHub have been released)

A simple example code :
#include <Core/Core.h>
#include <GLFW/glfw.h>

const unsigned int SCR_WIDTH = 800;
const unsigned int SCR_HEIGHT = 600;

CONSOLE_APP_MAIN{
    // glfw: initialize and configure
    glfwInit();
    //Major and Minor stand (in this case) for OpenGL 3.2
    //Make sure your OpenGL implemntation is compatible with the version exaplained here
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
    
    //If you OpenGL version is higher than 3.2 :
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
    //else if it's below :
    //glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_ANY_PROFILE);
#ifdef __APPLE__
    glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
#endif
    // glfw window creation
    GLFWwindow* window = glfwCreateWindow(SCR_WIDTH, SCR_HEIGHT, "Ultimate++", NULL, NULL);
    if (window == NULL)
    {
        Upp::Cout() << "Failed to create GLFW window\n";
        glfwTerminate();
        Upp::Exit(-1);
    }
    glfwMakeContextCurrent(window);
    
    // Glew: load all OpenGL function pointers
    glewExperimental=true;
	if (glewInit() != GLEW_OK){
		Upp::Cout() << "Failed to initialize GLEW\n";
	    Upp::Exit(-1);
	}
	
	//the game loop
	glViewport(0,0, SCR_WIDTH, SCR_HEIGHT);
    while (!glfwWindowShouldClose(window)){
        glfwSwapBuffers(window);
        glfwPollEvents();
    }
    glfwTerminate();
}


EDIT: at the moment LINUX version have been tested on X11. Some Memory leaks have been reported. (probably due to a AMD driver bug)
EDIT2: Cocoa (MacOS) and Wayland and Mesa have not been tested yet.
  • Attachment: GLFW.7z
    (Size: 353.00KB, Downloaded 154 times)

[Updated on: Sun, 13 December 2020 03:18]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: bazaar -> UppHub
Next Topic: Flatbuffers package
Goto Forum:
  


Current Time: Fri Apr 26 12:09:36 CEST 2024

Total time taken to generate the page: 0.04176 seconds