Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Developing U++ » Bugs (& fixes) » glut init-error.
glut init-error. [message #40047] Tue, 28 May 2013 16:32 Go to next message
witriol is currently offline  witriol
Messages: 8
Registered: November 2012
Promising Member
I tried to compile this short function.

struct OpenGLUT2 : GLCtrl 
{

void init(void) 
    {
    glClearColor(0.0, 0.0, 0.0, 0.0);
    glMatrixMode(GL_PROJECTION); 
    glLoadIdentity(); 
    glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0); 
    }

void RenderBitmapString(float x, float y, String a)
	{  
  	char c;
  	glColor3f(1.0, 1.0, 0.0);
  	glRasterPos2f(x, y);
	void * font = GLUT_BITMAP_TIMES_ROMAN_10;
  	int k=0;
  	for (c=a[k]; k<a.GetCount(); k++)
	   	glutBitmapCharacter(font, c);
	}

virtual void GLPaint() 
	{
        glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
        init(); 
        glutMainLoop(); 
	} 

};


............


	OpenGLExample2 gl;
	ldc app;
	
	gl.SetFrame(InsetFrame());
	
	app.Add(gl.HSizePos(10, 320).VSizePos(10, 200));
	app.Sizeable(true);
	app.Maximize(true);
	app.Run();



The translation is okay, but I try to use (Linux), this error message:
ek@programozas:~/upp/_out/MyApps/GCC4.Debug.Debug_Full.Gui.Shared.Sse2$ ./ldc
freeglut ERROR: Function <glutMainLoop> called without first calling 'glutInit'.

virtual void GLPaint() 
	{
	StdView();
	char fakeParam[] = "fake";
        char *fakeargv[] = { fakeParam, NULL };
        int fakeargc = 1;

        glutInit( &fakeargc, fakeargv );
        glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
        init();
        //glutDisplayFunc(display);
        //glutKeyboardFunc(keyboard); 
        glutMainLoop(); 
	} 



Heap leaks detected! Fatal IO error 11 on X server :0.0.
If you prepare the glutInit this is the error massage:
/GCC4.Debug.Debug_Full.Gui.Shared.Sse2$ ./ldc
Heap leaks detected!
ldc: Fatal IO error 11 on X server :0.0.

What am I doing wrong?

[Updated on: Tue, 28 May 2013 16:34]

Report message to a moderator

Re: glut init-error. [message #48924 is a reply to message #40047] Fri, 03 November 2017 10:58 Go to previous message
slashupp is currently offline  slashupp
Messages: 142
Registered: July 2009
Experienced Member

I know this is old, but I hit same problem and solved it like below,
putting this here for next guy Smile

give your class a ctor in which you do the following to let
glut initialize properly:


OpenGLUT2::OpenGLUT2()
{
	char *myargv[1];
	int myargc=1;
	myargv [0]=strdup(GetExeTitle().ToStd().c_str());
	glutInit(&myargc, myargv);
	//...whatever else you need in the ctor...
}


Fake parameters does not work - it must either be an exact copy of
what was passed to main, or at least supply correct data as above.

[Updated on: Fri, 03 November 2017 11:00]

Report message to a moderator

Previous Topic: int64 in JSON
Next Topic: DO NOT POST NEW TOPICS TO THIS FORUM!!!
Goto Forum:
  


Current Time: Thu Nov 22 11:32:36 CET 2018

Total time taken to generate the page: 0.00648 seconds