Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: OpenGL issue

  1. #1
    Join Date
    Sep 2010
    Location
    Espoo, Finland
    Beans
    26
    Distro
    Ubuntu 11.04 Natty Narwhal

    OpenGL issue

    Hi,

    I've been trying to use this tutorial to learn some opengl.

    I got it to compile without much problem, but when I try to run it this error is displayed:

    Code:
    X Error of failed request:  BadAlloc (insufficient resources for operation)
      Major opcode of failed request:  136 (GLX)
      Minor opcode of failed request:  34 ()
      Serial number of failed request:  38
      Current serial number in output stream:  39
    I've spent a couple of hours googling this but I couldn't find a solution.

    Does anyone know how to fix this? Thank you.
    Acer M3203 6gb 1.5tb AMD Athlon II X4 NVIDIA GeForce GT320 1024MB

  2. #2
    Join Date
    May 2011
    Beans
    273

    Re: OpenGL issue

    Quote Originally Posted by mickeoliver View Post
    Hi,

    I've been trying to use this tutorial to learn some opengl.

    I got it to compile without much problem, but when I try to run it this error is displayed:

    Code:
    X Error of failed request:  BadAlloc (insufficient resources for operation)
      Major opcode of failed request:  136 (GLX)
      Minor opcode of failed request:  34 ()
      Serial number of failed request:  38
      Current serial number in output stream:  39
    I've spent a couple of hours googling this but I couldn't find a solution.

    Does anyone know how to fix this? Thank you.
    Maybe you're using malloc/calloc/realloc in a way that it grows very fast and takes all the memory up? It is a common error while doing this and it can cause a program to crash. But since it's OpenGL, the error might be something else (I'm not really familiar with it). But you can post the code and we'll see.
    Your left hand is touching your face.

  3. #3
    Join Date
    Sep 2010
    Location
    Espoo, Finland
    Beans
    26
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: OpenGL issue

    Here's the code:

    Code:
    #include <stdlib.h>
    #include <stdio.h>
    #include <string.h>
    #include <GL/glew.h>
    #include <GL/freeglut.h>
    #define WINDOW_TITLE_PREFIX "Chapter 1"
    
    int CurrentWidth = 800,
    	CurrentHeight = 600,
    	WindowHandle = 0;
    
    void Initialize(int, char*[]);
    void InitWindow(int, char*[]);
    void ResizeFunction(int, int);
    void RenderFunction(void);
    
    int main(int argc, char* argv[])
    {
    	Initialize(argc, argv);
    
    	glutMainLoop();
    
    	exit(EXIT_SUCCESS);
    }
    
    void Initialize(int argc, char* argv[])
    {
    	InitWindow(argc, argv);
    
    	fprintf(
    		stdout,
    		"INFO: OpenGL Version: %s\n",
    		glGetString(GL_VERSION)
    	);
    
    	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    }
    
    void InitWindow(int argc, char* argv[])
    {
    	glutInit(&argc, argv);
    
    	glutInitContextVersion(4, 0);
    	glutInitContextFlags(GLUT_FORWARD_COMPATIBLE);
    	glutInitContextProfile(GLUT_CORE_PROFILE);
    
    	glutSetOption(
    		GLUT_ACTION_ON_WINDOW_CLOSE,
    		GLUT_ACTION_GLUTMAINLOOP_RETURNS
    	);
    
    	glutInitWindowSize(CurrentWidth, CurrentHeight);
    
    	glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
    
    	WindowHandle = glutCreateWindow(WINDOW_TITLE_PREFIX);
    
    	if(WindowHandle < 1) {
    		fprintf(
    			stderr,
    			"ERROR: Could not create a new rendering window.\n"
    		);
    		exit(EXIT_FAILURE);
    	}
    
    	glutReshapeFunc(ResizeFunction);
    	glutDisplayFunc(RenderFunction);
    }
    
    void ResizeFunction(int Width, int Height)
    {
    	CurrentWidth = Width;
    	CurrentHeight = Height;
    	glViewport(0, 0, CurrentWidth, CurrentHeight);
    }
    
    void RenderFunction(void)
    {
    	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    
    	glutSwapBuffers();
    	glutPostRedisplay();
    }
    I've only really programmed in c++ before, but I did this in C because the tutorial was in C too. I might have forgotten something because of that
    Acer M3203 6gb 1.5tb AMD Athlon II X4 NVIDIA GeForce GT320 1024MB

  4. #4
    Join Date
    May 2011
    Beans
    273

    Re: OpenGL issue

    Quote Originally Posted by mickeoliver View Post
    Here's the code:

    Code:
    #include <stdlib.h>
    #include <stdio.h>
    #include <string.h>
    #include <GL/glew.h>
    #include <GL/freeglut.h>
    #define WINDOW_TITLE_PREFIX "Chapter 1"
    
    int CurrentWidth = 800,
    	CurrentHeight = 600,
    	WindowHandle = 0;
    
    void Initialize(int, char*[]);
    void InitWindow(int, char*[]);
    void ResizeFunction(int, int);
    void RenderFunction(void);
    
    int main(int argc, char* argv[])
    {
    	Initialize(argc, argv);
    
    	glutMainLoop();
    
    	exit(EXIT_SUCCESS);
    }
    
    void Initialize(int argc, char* argv[])
    {
    	InitWindow(argc, argv);
    
    	fprintf(
    		stdout,
    		"INFO: OpenGL Version: %s\n",
    		glGetString(GL_VERSION)
    	);
    
    	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    }
    
    void InitWindow(int argc, char* argv[])
    {
    	glutInit(&argc, argv);
    
    	glutInitContextVersion(4, 0);
    	glutInitContextFlags(GLUT_FORWARD_COMPATIBLE);
    	glutInitContextProfile(GLUT_CORE_PROFILE);
    
    	glutSetOption(
    		GLUT_ACTION_ON_WINDOW_CLOSE,
    		GLUT_ACTION_GLUTMAINLOOP_RETURNS
    	);
    
    	glutInitWindowSize(CurrentWidth, CurrentHeight);
    
    	glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
    
    	WindowHandle = glutCreateWindow(WINDOW_TITLE_PREFIX);
    
    	if(WindowHandle < 1) {
    		fprintf(
    			stderr,
    			"ERROR: Could not create a new rendering window.\n"
    		);
    		exit(EXIT_FAILURE);
    	}
    
    	glutReshapeFunc(ResizeFunction);
    	glutDisplayFunc(RenderFunction);
    }
    
    void ResizeFunction(int Width, int Height)
    {
    	CurrentWidth = Width;
    	CurrentHeight = Height;
    	glViewport(0, 0, CurrentWidth, CurrentHeight);
    }
    
    void RenderFunction(void)
    {
    	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    
    	glutSwapBuffers();
    	glutPostRedisplay();
    }
    I've only really programmed in c++ before, but I did this in C because the tutorial was in C too. I might have forgotten something because of that
    I don't think you googled enough.

    http://ubuntuforums.org/showthread.php?t=1762103

    This is the exact same problem, same tutorial, same example, same error, (hopefully the same fix).

    Took me 2 minutes.
    Your left hand is touching your face.

  5. #5
    Join Date
    Sep 2010
    Location
    Espoo, Finland
    Beans
    26
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: OpenGL issue

    Thanks, but if you actually read the post I think that he makes it pretty clear that those fixes did not help. And it seems like there is still no fix.
    Acer M3203 6gb 1.5tb AMD Athlon II X4 NVIDIA GeForce GT320 1024MB

  6. #6
    Join Date
    May 2011
    Beans
    273

    Re: OpenGL issue

    Quote Originally Posted by mickeoliver View Post
    Thanks, but if you actually read the post I think that he makes it pretty clear that those fixes did not help. And it seems like there is still no fix.
    I'm pretty sure that's the fix. I don't think there are any others.
    Your left hand is touching your face.

  7. #7
    Join Date
    Sep 2010
    Location
    Espoo, Finland
    Beans
    26
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: OpenGL issue

    Well then that's a bummer because it didn't work for me either.
    Acer M3203 6gb 1.5tb AMD Athlon II X4 NVIDIA GeForce GT320 1024MB

  8. #8
    Join Date
    Sep 2010
    Location
    Espoo, Finland
    Beans
    26
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: OpenGL issue

    I found the solution, I'll post it here for anyone who might have the same problem: my NVIDIA driver seemed to have some issues with opengl 4.0, so I just changed the version in the code to 3.3. Worked perfectly.
    Acer M3203 6gb 1.5tb AMD Athlon II X4 NVIDIA GeForce GT320 1024MB

  9. #9
    Join Date
    Nov 2010
    Location
    Down the rabbit hole
    Beans
    435
    Distro
    Ubuntu Development Release

    Re: OpenGL issue

    Nvidia released recently the 275 driver series, which fixes important OpenGL 4.x issues which might also solve your issue if you wanna use GL 4.x.
    Your ads here, just 9.99$/week !!

  10. #10
    Join Date
    Sep 2010
    Location
    Espoo, Finland
    Beans
    26
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: OpenGL issue

    Thanks, I'll give that a try!
    Acer M3203 6gb 1.5tb AMD Athlon II X4 NVIDIA GeForce GT320 1024MB

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •