Talk About Network

Google





Graphics > OpenGL 3D API > Re: About glutI...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 12 Topic 4791 of 5061
Post > Topic >>

Re: About glutInit

by pera <gomesbascoy@[EMAIL PROTECTED] > Jun 12, 2008 at 02:42 PM

On Jun 12, 5:04 am, Wolfgang Draxinger <wdraxin...@[EMAIL PROTECTED]
>
wrote:
> pera wrote:
> > Hello, I'm trying to make a tiny app with glut (cross-platform)
> > in C with gcc. I'm not using "int main(int argc, char **argv)"
> > instead that I'm setting the start point with "void
> > _start(void)" (and - nostartfiles in my makefile)... and works,
>
> Why are you dooing this? Specifying the program entry point
> yourself means, that you totally omit the runtime libraries
> initialisation code. This code does im****tant things: Set up
> dynamic memory management structures for malloc, set FPU
> registers, and in case of C++ calls static constructors.
>

first: thanks for your time =)
I'm doing this because I need space (I'm making a 4kb intro/
demoscene).

> > but the problem is that glutInit need argc and argv.
> > My question is, there is someway to use glut without real argc
> > and argv?
>
> Well, yes, but you will then be unable to set things like window
> geometry and stuff by command line parameters.
>

I dont need any parameter

> > if I define my own argc (=1) and argv pointer I get a
> > segmentation fault :S ("Program received signal SIGSEGV,
> > Segmentation fault. 0xb7270622 in strrchr () from
> > /lib/libc.so.6")
>
> Could it be due to the simple fact, that libc isn't initialized
> and thus any call in a function of it may hit uninitialized
> structures?
>
> Did you try those self defined glutInit parameters from within a
> ordinary main?
>
> Wolfgang Draxinger

Yes, look this:

/*** BEGIN ***/
#include <GL/glut.h>

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 display(void){
	glClear(GL_COLOR_BUFFER_BIT);

	glFlush();
}
int main(void){
	int argc=1;
	char **argv;
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
	glutInitWindowSize(500, 500);
	glutCreateWindow("Intro");
	init();
	glutDisplayFunc(display);
	glutMainLoop();
	return 0;
}
/*** END ***/

This works great, but if I set my own entry point "void _start(void)"
instead of main I get the segmentation fault :/

why?
 




 12 Posts in Topic:
About glutInit
pera <gomesbascoy@[EMA  2008-06-11 21:29:10 
Re: About glutInit
Wolfgang Draxinger <wd  2008-06-12 10:04:06 
Re: About glutInit
pera <gomesbascoy@[EMA  2008-06-12 14:42:08 
Re: About glutInit
"jbwest" <jb  2008-06-12 05:02:23 
Re: About glutInit
Wolfgang Draxinger <wd  2008-06-13 09:52:41 
Re: About glutInit
pan <spank@[EMAIL PROT  2008-06-15 11:18:46 
Re: About glutInit
fungus <openglMYSOCKS@  2008-06-13 00:06:25 
Re: About glutInit
pera <gomesbascoy@[EMA  2008-06-13 09:44:55 
Re: About glutInit
Wolfgang Draxinger <wd  2008-06-13 21:06:10 
Re: About glutInit
fungus <openglMYSOCKS@  2008-06-13 14:15:43 
Re: About glutInit
pera <gomesbascoy@[EMA  2008-06-13 19:39:10 
Re: About glutInit
fungus <openglMYSOCKS@  2008-06-14 05:17:38 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
localhost-V2008-12-19 Wed Jan 7 15:44:27 PST 2009.