this is a pretty long code example but i just wanted to know if i’m doing something stupid/wrong. I just attempted to modify an example given from a book to include some other things. I get 3 errors:
C:\My Documents\glstuff emp2 ry.cpp(32) : error C2601: ‘mouse’ : local function definitions are illegal
C:\My Documents\glstuff emp2 ry.cpp(47) : error C2601: ‘main’ : local function definitions are illegal
C:\My Documents\glstuff emp2 ry.cpp(60) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
try.exe - 3 error(s), 0 warning(s)
if anyone sees something that really stands out wrong please point it out cuz i’m a real beginner trying to get a feel for this 2d stuff
#include <iostream.h>
#include <gl/glut.h>
static GLint vertices[] = {25, 25, 100, 325, 175, 25, 175, 325, 250, 25, 325, 325, };
static GLfloat colors[] = {1.0, 0.2, 0.2, 0.2, 0.2, 1.0, 0.8, 1.0, 0.2, 0.75, 0.75,
0.75, 0.35, 0.35 ,0.35 ,0.5, 0.5, 0.5,};
void init(void)
{
glClearColor(1.0, 1.0, 1.0, 1.0);
glShadeModel(GL_FLAT);
}
void display (void){
glEnableClientState(GL_COLOR_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);
glColorPointer(3, GL_FLOAT, 0, colors);
glVertexPointer(2, GL_INT, 0, vertices);
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_TRIANGLES);
glArrayElement(2);
glArrayElement(3);
glArrayElement(5);
glEnd();
void mouse(int button, int state, int x, int y){
switch (button) {
case GLUT_LEFT_BUTTON:
if (state == GLUT_DOWN)
glColor3f(0.5, 0.5, 0.5);
break;
default:
break;
}
}
int main (int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(250, 250);
glutInitWindowPosition(100, 100);
glutCreateWindow("Test");
init();
glutDisplayFunc(display);
glutMouseFunc(mouse);
glutMainLoop();
return 0;
}
thanx for any help