Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <GLFW\glfw3.h>
- #include <GLES2\gl2.h>
- #include <iostream>
- using std::cout;
- using std::endl;
- void printInfo(GLFWwindow *window) {
- const GLubyte *version = glGetString(GL_VERSION);
- const GLubyte *vendor = glGetString(GL_VENDOR);
- const GLubyte *renderer = glGetString(GL_RENDERER);
- const GLubyte *extensions = glGetString(GL_EXTENSIONS);
- cout << "Version: " << version << endl;
- cout << "Vendor: " << vendor << endl;
- cout << "Renderer: " << renderer << endl;
- cout << "Extensions: " << extensions << endl;
- int api = glfwGetWindowAttrib(window, GLFW_CLIENT_API);
- int major = glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MAJOR);
- int minor = glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MINOR);
- int revision = glfwGetWindowAttrib(window, GLFW_CONTEXT_REVISION);
- if(api == GLFW_OPENGL_API) {
- cout << "OpenGL" << endl;
- }
- else if(api == GLFW_OPENGL_ES_API) {
- cout << "OpenGL ES" << endl;
- }
- cout << "Major version: " << major << endl;
- cout << "Minor version: " << minor << endl;
- }
- void errorHandler(int code, const char *description) {
- cout << "GLFW error reported." << endl;
- cout << "\tCode: " << code << endl;
- cout << "\tDescription: " << description << endl;
- }
- int main(void)
- {
- GLFWwindow* window;
- /* Initialize the library */
- glfwSetErrorCallback(errorHandler);
- if (!glfwInit())
- return -1;
- /* Create a windowed mode window and its OpenGL context */
- glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
- window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
- if (!window)
- {
- glfwTerminate();
- return -1;
- }
- /* Make the window's context current */
- glfwMakeContextCurrent(window);
- // Set up the shaders
- printInfo(window);
- GLuint handle = glCreateProgram();
- if(handle == 0) {
- cout << "Could not create a shader program handle." << endl;
- }
- /* Loop until the user closes the window */
- while (!glfwWindowShouldClose(window))
- {
- /* Render here */
- /* Swap front and back buffers */
- glfwSwapBuffers(window);
- /* Poll for and process events */
- glfwPollEvents();
- }
- glfwTerminate();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement