• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
polyfrag

Ubuntu SDL_GL_CreateContext failing

6 posts in this topic

Somebody ported my code to linux using cmake. They got it to run, but when I tried to compile it with cmake it complained that libGL.so was missing DSO or something.

I fixed it (correctly or not) like this:

CMakeLists.txt

...

ADD_DEFINITIONS("-std=c++0x"
    -lGL
    -lGLU
    -lGLEW)

...

FIND_PACKAGE(OpenGL REQUIRED)
FIND_PACKAGE(GLEW REQUIRED)

...

TARGET_LINK_LIBRARIES(
...
        ${GL_LIBRARIES}
        ${GLU_LIBRARIES}
...
  ${OPENGL_LIBRARIES}
        )

That was enough to compile the program. But it complained about "Couldn't create GL context" at the end here:

g_log<<"samw0"<<endl;
  g_log.flush();

  g_log<<"GL_VERSION: "<<(char*)glGetString(GL_VERSION)<<endl;
  g_log.flush();

  g_log<<"sa"<<endl;
  g_log.flush();

  // Request compatibility because GLEW doesn't play well with core contexts.
#if 1
  SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY);
  SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); 
  SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2); 
  SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);
  SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
  SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); 
#endif

  unsigned int flags;
  int startx;
  int starty;

  if(g_fullscreen)
  {
    startx = SDL_WINDOWPOS_UNDEFINED;
    starty = SDL_WINDOWPOS_UNDEFINED;
    flags = SDL_WINDOW_OPENGL | SDL_WINDOW_FULLSCREEN;
  }
  else
  {
    startx = SDL_WINDOWPOS_UNDEFINED;
    starty = SDL_WINDOWPOS_UNDEFINED;

    flags = SDL_WINDOW_OPENGL;
  }

  // Create an application window with the following settings:
    g_window = SDL_CreateWindow(
        title,                  // window title
        startx,           // initial x position
        starty,           // initial y position
        g_selectedRes.width,                               // width, in pixels
        g_selectedRes.height,                               // height, in pixels
        flags                  // flags - see below
    );
   ...
  g_glcontext = SDL_GL_CreateContext(g_window);
  //SDL_GL_SetSwapInterval(1);

  g_log<<"GL_VERSION: "<<glGetString(GL_VERSION)<<endl;

  if(!g_glcontext)
  {
    DestroyWindow(title);
    ErrorMessage("Error", "Couldn't create GL context");
    return false;
  }

You can see at the very beginning there I try to check GL version:

 g_log<<"GL_VERSION: "<<(char*)glGetString(GL_VERSION)<<endl;

But there's some kind of problem because all I see in the log is:

 

 

samw0
GL_VERSION:

 

 

And after that there's nothing, even though the program doesn't stop there. So it seems like I'm linking to GL wrong or something.

How do I diagnose the problem? Do I walk through the dependencies or something (how)?

Should it be red when make says:

 

 

Linking CXX executable corpstatesc

 

?

0

Share this post


Link to post
Share on other sites

Seems the problem is it can't get an OpenGL 3.2 context, but returns a 3.0 fine if I don't specify which one to get.

 

glxinfo says I have 3.3 core and 3.0

 

 

name of display: :0
display: :0 screen: 0
direct rendering: Yes
server glx vendor string: SGI
server glx version string: 1.4

OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Intel(R) Ivybridge Mobile
OpenGL core profile version string: 3.3 (Core Profile) Mesa 10.3.0-devel (git-96a95f4 saucy-oibaf-ppa)
OpenGL core profile shading language version string: 3.30
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile


OpenGL version string: 3.0 Mesa 10.3.0-devel (git-96a95f4 saucy-oibaf-ppa)
OpenGL shading language version string: 1.30
OpenGL context flags: (none)

 

I can get a 3.3 core context but not a 3.2 one, compatibility or core.

 

 

Is 3.2 not supported on linux? Maybe not for my integrated Intel videocard? Can I programmatically switch to the NVidia Quadro high-performance card I have?

Edited by polyfrag
0

Share this post


Link to post
Share on other sites

With mesa drivers, you cannot create compatybility context past version 3.0( according to http://cgit.freedesktop.org/mesa/mesa/tree/docs/GL3.txt at least):

 

 

OpenGL Core and Compatibility context support

OpenGL 3.1 and later versions are only supported with the Core profile.
There are no plans to support GL_ARB_compatibility. The last supported OpenGL
version with all deprecated features is 3.0. Some of the later GL features
are exposed in the 3.0 context as extensions.  

 

That's for radeon, nouveau and intel drivers. But proprietary nvidia(https://developer.nvidia.com/opengl-driver) (and probably catalyst too?)drivers seems to support compatibility profiles up to opengl4.4.

 

So it seams that only options are:

1. use 3.0 context and load >=3.1 features as extensions

2. use core 3.3 context

 

As of switching to nvidia card: http://bumblebee-project.org/

0

Share this post


Link to post
Share on other sites

I'm now optimizing for an older Inspiron 530 with an integrated videocard that only supports OpenGL 1.4. Really annoying. I'll look into bumblebee. If I install nvidia drivers, will that let me use the high-performance card?

0

Share this post


Link to post
Share on other sites

Bumblebee daemon doesn't detect the discrete videocard. I searched around and that might mean I need to update my BIOS. I tried booting FreeDOS from USB and CD but it just freezes at the Dell screen when I try USB. My laptop boots it fine.

 

The exact error messages happens here:

 

https://github.com/Bumblebee-Project/Bumblebee/blob/master/src/bumblebeed.c

int main(int argc, char* argv[]) {

...

pci_bus_id_discrete = pci_find_gfx_by_vendor(PCI_VENDOR_ID_NVIDIA, 0);
  if (!pci_bus_id_discrete) {
    bb_log(LOG_ERR, "No discrete video card found, quitting\n");
    return (EXIT_FAILURE);
  }

That function is defined in:

 

https://github.com/Bumblebee-Project/Bumblebee/blob/master/src/pci.c

struct pci_bus_id *pci_find_gfx_by_vendor(unsigned int vendor_id, unsigned int idx) {
...

fp = fopen("/proc/bus/pci/devices", "r");
  if (!fp) {
    return NULL;
  }

  result = malloc(sizeof (struct pci_bus_id));
  if (!result) {
    return NULL;
  }

  while (fgets(buf, sizeof(buf) - 1, fp)) {
    if (sscanf(buf, "%x %x", &bus_id_numeric, &vendor_device) != 2) {
      continue;
    }
    /* VVVVDDDD becomes VVVV */
    if (vendor_device >> 0x10 == vendor_id) {
      if (pci_parse_bus_id(result, bus_id_numeric)) {
        int pci_class = pci_get_class(result);
        if (pci_class == PCI_CLASS_DISPLAY_VGA ||
                pci_class == PCI_CLASS_DISPLAY_3D) {
          /* yay, found device. Now get next, or clean up and return */
          if (idx--) {
            /* It's not yet our device */
            continue;
          }
          fclose(fp);
          return result;
        }
      }
    }
  }

https://github.com/Bumblebee-Project/Bumblebee/blob/master/src/pci.h

#define PCI_VENDOR_ID_NVIDIA  0x10de 
#define PCI_VENDOR_ID_INTEL  0x8086 
#define PCI_CLASS_DISPLAY_VGA 0x0300 
#define PCI_CLASS_DISPLAY_3D  0x0302

I checked that file /proc/bus/pci/devices

0000  808629c0  0                 0                 0                 0                 0                 0                 0                 0                 0                 0                 0                 0                 0                 0                 0  agpgart-intel
0008  808629c1  28                 0                 0                 0                 0                 0                 0                 0                 0                 0                 0                 0                 0                 0                 0  pcieport
0010  808629c2  2c          fdf00000              ff01          d0000008          fd800000                 0                 0                 2             80000                 8          10000000            100000                 0                 0                 0  i915
00c8  808610c0  2b          fdfc0000          fdfff000              fe01                 0                 0                 0                 0             20000              1000                20                 0                 0                 0                 0  e1000e
00d0  80862937  10                 0                 0                 0                 0              fd01                 0                 0                 0                 0                 0                 0                20                 0                 0  uhci_hcd
00d1  80862938  15                 0                 0                 0                 0              fc01                 0                 0                 0                 0                 0                 0                20                 0                 0  uhci_hcd
00d2  80862939  13                 0                 0                 0                 0              fb01                 0                 0                 0                 0                 0                 0                20                 0                 0  uhci_hcd
00d7  8086293c  12          fdffe000                 0                 0                 0                 0                 0                 0               400                 0                 0                 0                 0                 0                 0  ehci-pci
00d8  8086293e  2d          fdff4004                 0                 0                 0                 0                 0                 0              4000                 0                 0                 0                 0                 0                 0  snd_hda_intel
00e0  80862940  29                 0                 0                 0                 0                 0                 0                 0                 0                 0                 0                 0                 0                 0                 0  pcieport
00e3  80862946  2a                 0                 0                 0                 0                 0                 0                 0                 0                 0                 0                 0                 0                 0                 0  pcieport
00e8  80862934  17                 0                 0                 0                 0              fa01                 0                 0                 0                 0                 0                 0                20                 0                 0  uhci_hcd
00e9  80862935  13                 0                 0                 0                 0              f901                 0                 0                 0                 0                 0                 0                20                 0                 0  uhci_hcd
00ea  80862936  12                 0                 0                 0                 0              f801                 0                 0                 0                 0                 0                 0                20                 0                 0  uhci_hcd
00ef  8086293a  17          fdffd000                 0                 0                 0                 0                 0                 0               400                 0                 0                 0                 0                 0                 0  ehci-pci
00f0  8086244e  0                 0                 0                 0                 0                 0                 0                 0                 0                 0                 0                 0                 0                 0                 0  
00f8  80862916  0                 0                 0                 0                 0                 0                 0                 0                 0                 0                 0                 0                 0                 0                 0  lpc_ich
00fa  80862920  13              f701              f601              f501              f401              f301              f201                 0                 8                 4                 8                 4                10                10                 0  ata_piix
00fb  80862930  b          fdffc004                 0                 0                 0               501                 0                 0               100                 0                 0                 0                20                 0                 0  
00fd  80862926  13              f001              ef01              ee01              ed01              ec01              eb01                 0                 8                 4                 8                 4                10                10                 0  ata_piix
0300  10024d51  b          fdc00004                 0          fa00000c                 0                 0                 0                 0            100000                 0           2000000                 0                 0                 0                 0  

Like it says in the code, it looks for a line where the second hexadecimal number is less than 2159 (in decimals).

Does sscanf(buf, "%x %x", &bus_id_numeric, &vendor_device) read ints or unsigned ints? bus_id_numeric and vendor_device are unsigned int.

The hex 10024d51 is 268,586,321 decimal. The highest unsigned int is 4,294,967,295 and signed int 2,147,483,647. Hex number 80862926 is 2,156,276,006 decimal, which is 8,792,359 higher than signed int max.

But I am not sure if bumblebee is for my desktop. It says my GL_RENDERER is Intel G33 Express if I don't specify which OpenGL version I need, so I assume I have an integrated videocard in addition to NVidia. 

I tried installing the NVidia driver like so

sudo apt-get install nvidia-current

Following http://www.dedoimedo.com/computers/ubuntu-ringtail-nvidia.html

 

But

sudo /sbin/lsmod | grep nvidia

Didn't show anything. I then followed

sudo depmod -a
sudo modprobe nvidia_current

But it couldn't find nvidia_current. I then rebooted and my GUI wouldn't work so I had to remove the NVidia driver from command line mode by

sudo apt-get remove nvidia-*
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0