Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. OpenGL integration with SDL, problem

OpenGL integration with SDL, problem

Scheduled Pinned Locked Moved C / C++ / MFC
game-devhelpcomgraphics
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    James_722
    wrote on last edited by
    #1

    I am trying to create a simple game framework that covers all the boilerplate code involved with initializing a opengl/sdl window. I am having a problem getting it to work properly though. I know for sure that I initialized the screen SDL_surface properly but that is about it (the screen goes black); none of the opengl commands work properly. I added code to check to make sure the loop is working (it is). I'm well versed in Opengl but am an SDL noob. Its probably something small I screwed up or overlooked but I cannot figure it out, help on the topic of opengl integration with SDL is scarce. Here is a link to my code. http://pastebay.com/106583[^] If anyone knows what the problem is, I would greatly appreciate some help with this problem.

    L C 2 Replies Last reply
    0
    • J James_722

      I am trying to create a simple game framework that covers all the boilerplate code involved with initializing a opengl/sdl window. I am having a problem getting it to work properly though. I know for sure that I initialized the screen SDL_surface properly but that is about it (the screen goes black); none of the opengl commands work properly. I added code to check to make sure the loop is working (it is). I'm well versed in Opengl but am an SDL noob. Its probably something small I screwed up or overlooked but I cannot figure it out, help on the topic of opengl integration with SDL is scarce. Here is a link to my code. http://pastebay.com/106583[^] If anyone knows what the problem is, I would greatly appreciate some help with this problem.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      I haven't looked at the code, but... Try specifying a non-black glClearColor value and then call glClear (with the GL_COLOR_BUFFER_BIT flag set, along with, probably, GL_DEPTH_BUFFER_BIT) at the beginning of your rendering loop (comment out any other rendering calls, so you don't overwrite the intialized contents of the buffer). If the GL window changes color, then you probably have it initialized correctly. If that's the case, double and triple check your camera orientation and the location of any test object you're trying to render. Very often, if you have a black screen and can't see anything you're rendering, it's because the camera is pointing in the wrong direction.

      L u n a t i c F r i n g e

      J 1 Reply Last reply
      0
      • L Lost User

        I haven't looked at the code, but... Try specifying a non-black glClearColor value and then call glClear (with the GL_COLOR_BUFFER_BIT flag set, along with, probably, GL_DEPTH_BUFFER_BIT) at the beginning of your rendering loop (comment out any other rendering calls, so you don't overwrite the intialized contents of the buffer). If the GL window changes color, then you probably have it initialized correctly. If that's the case, double and triple check your camera orientation and the location of any test object you're trying to render. Very often, if you have a black screen and can't see anything you're rendering, it's because the camera is pointing in the wrong direction.

        L u n a t i c F r i n g e

        J Offline
        J Offline
        James_722
        wrote on last edited by
        #3

        I tried that, and I get nothing. I've based this on a port of the NeHe basecode to SDL, and even though I can see no differences in the method of either code, mine doesn't work. I tried calling gluLookat(), I tried translating the geometry to be in front of the camera, i tried making the backcolor something other than black, nothing works.

        1 Reply Last reply
        0
        • J James_722

          I am trying to create a simple game framework that covers all the boilerplate code involved with initializing a opengl/sdl window. I am having a problem getting it to work properly though. I know for sure that I initialized the screen SDL_surface properly but that is about it (the screen goes black); none of the opengl commands work properly. I added code to check to make sure the loop is working (it is). I'm well versed in Opengl but am an SDL noob. Its probably something small I screwed up or overlooked but I cannot figure it out, help on the topic of opengl integration with SDL is scarce. Here is a link to my code. http://pastebay.com/106583[^] If anyone knows what the problem is, I would greatly appreciate some help with this problem.

          C Offline
          C Offline
          Cedric Moonen
          wrote on last edited by
          #4

          I didn't really looked at your code but I just want to let you know that there is probably a better alternative to SDL: take a look at SFML[^]. It's a more modern library which is similar to SDL but is fully object oriented (and much more efficient too). I suggest you take a look at the features page.

          Cédric Moonen Software developer
          Charting control [v3.0] OpenGL game tutorial in C++

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups