News for hackers. Stuff that matters.
Re:SDL 2.0.0 is out after many years in development by angersock on Tuesday August 13, 2013 @04:46AM (#6204651)

  #include <GLFW/glfw3.h>

  int main(void)
  {
    GLFWwindow* window;

    if (!glfwInit())
        return -1;

    window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
    if (!window) {
        glfwTerminate();
        return -1;
    }

    glfwMakeContextCurrent(window);

    while (!glfwWindowShouldClose(window)) {
        /* Render here */


        glfwSwapBuffers(window);
        glfwPollEvents();
    }

    glfwTerminate();
    return 0;
  }
VS

   #include <GL3/gl3.h>
   #include <SDL.h>

  /* Our program's entry point */
  int main(int argc, char *argv[])
  {
    SDL_Window *mainwindow;
    SDL_GLContext maincontext;
    SDL_Event event;
    int running = 1;

    if (SDL_Init(SDL_INIT_VIDEO) < 0)
        exit(1);

    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
    SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
 
    mainwindow = SDL_CreateWindow(PROGRAM_NAME, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
        512, 512, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN);
    if (!mainwindow)
      exit(1);
 
    maincontext = SDL_GL_CreateContext(mainwindow); 
 
    SDL_GL_SetSwapInterval(1);
 
    
    while (running) {
        while (SDL_PollEvent(&event) {
            if ( event == SDL_WINDOWEVENT_CLOSE ) {
                running = 0;
                break;
            }

            /* render */

        }
        SDL_GL_SwapWindow(mainwindow);
    }
  
    SDL_GL_DeleteContext(maincontext);
    SDL_DestroyWindow(mainwindow);
    SDL_Quit();
 
    return 0;
  }

It's got SDL beat a bit in simplicity for OpenGL, sorry dude.
Re:SDL 2.0.0 is out after many years in development by caf on Tuesday August 13, 2013 @05:01AM (#6204697)
As someone who's used neither, I'd call that a draw. Neither of that boilerplate looks particularly scary or insane.
Re:SDL 2.0.0 is out after many years in development by mahmud on Tuesday August 13, 2013 @04:58AM (#6204687)
Yep, because main-loop boilerplate is all one ever does with graphics programming.
Re:SDL 2.0.0 is out after many years in development by angersock on Tuesday August 13, 2013 @05:10AM (#6204716)
Hey, no reason to get snippy--you asked "Isn't SDL the simplest, most portable way to use OpenGL?", and asserted that it's a smaller library. I showed you a still-smaller alternative, and even dug up code to substantiate that point.

There's nothing wrong with using SDL for making a game (well, maybe a couple of things, but that's not relevant here), but it simply isn't the smallest GL scaffolding library out there.

Re:SDL 2.0.0 is out after many years in development by mahmud on Tuesday August 13, 2013 @05:20AM (#6204748)
Heh, you're right, I got a little snarky. Sorry :-P

But I got bit by half-assed "GL" ways of doing things before. SDL has everything, in layers, so you can grow into it. Unlike "portable GL" libraries which are discrete, isolate dead-ends.

Re:SDL 2.0.0 is out after many years in development by eropple on Tuesday August 13, 2013 @08:21PM (#6209231)
Calling GLFW a "dead end" is misleading and unfair.

GLFW does not attempt to handle OpenGL for you, it handles windowing and input for you. I personally really don't want SDL anywhere near my projects because it imposes its own structure upon me. (I don't use Allegro, even for 2D code, for similar reasons.) I am simply not all that fussed by writing up a VBO handler and some pretty simple OpenAL code myself--it isn't difficult enough for me to warrant the huge blob of extraneous SDL stuff.

Re:SDL 2.0.0 is out after many years in development by wtallis on Tuesday August 13, 2013 @12:31PM (#6206706)
That doesn't show that GLFW is simpler than SDL. It just shows that GLFW has some simple defaults. How much complexity is added to the GLFW code if you want to require a minimum GL version and depth buffer size? Or a fulllscreen window?
Re:SDL 2.0.0 is out after many years in development by angersock on Tuesday August 13, 2013 @01:38PM (#6207053)
Sure. Fullscreen mode:

      window = glfwCreateWindow(640, 480, "Hello World", glfwGetPrimaryMonitor(), NULL);
Requesting a specific version with a particular depth:

  glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
  glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 2);
  glfwOpenWindowHint(GLFW_DEPTH_BIT, 24);
There you go.