A small problem

Started by
7 comments, last by Kronos259 20 years, 11 months ago
I use void draw(){ //here i draw a cube starting with glbegin //finishing with glEnd; } When i compile the program i get the message "Local functions are illegal". Anyone knows why?
Advertisement
Where in your code have you put the function? is this function draw() inside another one?
Im guessing you missed a parenthesis above draw, or you typed a '')'' when you meant ''}'' - or vice versa.
It is right after this code (thereis nothing else drawn in the screen)
int DrawGLScene(GLvoid) // Here''s Where We Do All The Drawing
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer
glLoadIdentity(); // Reset The View

It doesn''t look like you''re ending the DrawGLScene function with a ''}''....
Thanks for your interest.
The whole code is fine, i use the required { or ( where it is needed and believe me there is no problem in that .When i do not use the statements void draw (){
and }(after the code that draw sthe cube)

everything works fine.The cube is correctly created.
What i actually want to do is add a function that will help me draw several cubes by calling it.
something like this?

int DrawGLScene(GLvoid)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
drawManyCubes();
}


void drawManyCubes(){
for(int i=0;i<100;i++){
glBegin(GL_QUADS);
..
...
glEnd();
}
}
That should be correct, but you would probably have to have the
DrawCube() function BEFORE DrawGLScene()
Not when it is declared....
PM Times change...Excuse my poor english!

This topic is closed to new replies.

Advertisement