Hello, I am new to C++ and Glut (I know some C), and I have made an attempt to add a camera to a basic Glut program. However, when I compile, I get these following errors:
C:\Users\drewtoby\Desktop\cube\main.cpp|25|error: stray '\221' in program|
C:\Users\drewtoby\Desktop\cube\main.cpp|25|error: stray '\222' in program|
C:\Users\drewtoby\Desktop\cube\main.cpp|31|error: stray '\221' in program|
C:\Users\drewtoby\Desktop\cube\main.cpp|31|error: stray '\222' in program|
C:\Users\drewtoby\Desktop\cube\main.cpp|37|error: stray '\221' in program|
C:\Users\drewtoby\Desktop\cube\main.cpp|37|error: stray '\222' in program|
C:\Users\drewtoby\Desktop\cube\main.cpp|47|error: stray '\221' in program|
C:\Users\drewtoby\Desktop\cube\main.cpp|47|error: stray '\222' in program|
C:\Users\drewtoby\Desktop\cube\main.cpp|57|error: stray '\221' in program|
C:\Users\drewtoby\Desktop\cube\main.cpp|57|error: stray '\222' in program|
C:\Users\drewtoby\Desktop\cube\main.cpp|63|error: stray '\221' in program|
C:\Users\drewtoby\Desktop\cube\main.cpp|63|error: stray '\222' in program|
C:\Users\drewtoby\Desktop\cube\main.cpp||In function 'void keyboard(unsigned char, int, int)':|
C:\Users\drewtoby\Desktop\cube\main.cpp|25|error: 'q' was not declared in this scope|
C:\Users\drewtoby\Desktop\cube\main.cpp|27|error: 'xrot' was not declared in this scope|
C:\Users\drewtoby\Desktop\cube\main.cpp|31|error: 'z' was not declared in this scope|
C:\Users\drewtoby\Desktop\cube\main.cpp|33|error: 'xrot' was not declared in this scope|
C:\Users\drewtoby\Desktop\cube\main.cpp|37|error: 'w' was not declared in this scope|
C:\Users\drewtoby\Desktop\cube\main.cpp|40|error: 'yrot' was not declared in this scope|
C:\Users\drewtoby\Desktop\cube\main.cpp|41|error: 'xrot' was not declared in this scope|
C:\Users\drewtoby\Desktop\cube\main.cpp|42|error: 'xpos' was not declared in this scope|
C:\Users\drewtoby\Desktop\cube\main.cpp|42|error: 'sin' was not declared in this scope|
C:\Users\drewtoby\Desktop\cube\main.cpp|43|error: 'zpos' was not declared in this scope|
C:\Users\drewtoby\Desktop\cube\main.cpp|43|error: 'cos' was not declared in this scope|
C:\Users\drewtoby\Desktop\cube\main.cpp|44|error: 'ypos' was not declared in this scope|
C:\Users\drewtoby\Desktop\cube\main.cpp|47|error: 's' was not declared in this scope|
C:\Users\drewtoby\Desktop\cube\main.cpp|50|error: 'yrot' was not declared in this scope|
C:\Users\drewtoby\Desktop\cube\main.cpp|51|error: 'xrot' was not declared in this scope|
C:\Users\drewtoby\Desktop\cube\main.cpp|52|error: 'xpos' was not declared in this scope|
C:\Users\drewtoby\Desktop\cube\main.cpp|52|error: 'sin' was not declared in this scope|
C:\Users\drewtoby\Desktop\cube\main.cpp|53|error: 'zpos' was not declared in this scope|
C:\Users\drewtoby\Desktop\cube\main.cpp|53|error: 'cos' was not declared in this scope|
C:\Users\drewtoby\Desktop\cube\main.cpp|54|error: 'ypos' was not declared in this scope|
C:\Users\drewtoby\Desktop\cube\main.cpp|57|error: 'd' was not declared in this scope|
C:\Users\drewtoby\Desktop\cube\main.cpp|59|error: 'yrot' was not declared in this scope|
C:\Users\drewtoby\Desktop\cube\main.cpp|63|error: 'a' was not declared in this scope|
C:\Users\drewtoby\Desktop\cube\main.cpp|65|error: 'yrot' was not declared in this scope|
C:\Users\drewtoby\Desktop\cube\main.cpp||In function 'int main(int, char**)':|
C:\Users\drewtoby\Desktop\cube\main.cpp|82|error: 'display' was not declared in this scope|
C:\Users\drewtoby\Desktop\cube\main.cpp|84|error: 'variables' was not declared in this scope|
C:\Users\drewtoby\Desktop\cube\main.cpp|84|error: expected ';' before 'to'|
C:\Users\drewtoby\Desktop\cube\main.cpp|85|error: 'reshape' was not declared in this scope|
||=== Build finished: 40 errors, 1 warnings ===|
with this code:
Code:
#include <GL/glut.h>
#include <iostream>
void enable (void) {
glEnable (GL_DEPTH_TEST); //enable the depth testing
glEnable (GL_LIGHTING); //enable the lighting
glEnable (GL_LIGHT0); //enable LIGHT0, our Diffuse Light
glShadeModel (GL_SMOOTH); //set the shader to smooth shader
}
void renderScene(void) {
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_TRIANGLES);
glColor3f(1,0,0);//Change the object color to red
glVertex3f(-2.0,-0.1,0.0);
glVertex3f(0.4,0.0,0.0);
glVertex3f(0.0,0.0,0.0);
glEnd();
glFlush();
}
void keyboard (unsigned char key, int x, int y) {
if (key==‘q’)
{
xrot += 1;
if (xrot >360) xrot -= 360;
}
if (key==‘z’)
{
xrot -= 1;
if (xrot < -360) xrot += 360;
}
if (key==‘w’)
{
float xrotrad, yrotrad;
yrotrad = (yrot / 180 * 3.141592654f);
xrotrad = (xrot / 180 * 3.141592654f);
xpos += float(sin(yrotrad)) ;
zpos -= float(cos(yrotrad)) ;
ypos -= float(sin(xrotrad)) ;
}
if (key==‘s’)
{
float xrotrad, yrotrad;
yrotrad = (yrot / 180 * 3.141592654f);
xrotrad = (xrot / 180 * 3.141592654f);
xpos -= float(sin(yrotrad));
zpos += float(cos(yrotrad)) ;
ypos += float(sin(xrotrad));
}
if (key==‘d’)
{
yrot += 1;
if (yrot >360) yrot -= 360;
}
if (key==‘a’)
{
yrot -= 1;
if (yrot < -360)yrot += 360;
}
if (key==27)
{
exit(0);
}
}
int main(int argc, char **argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_SINGLE | GLUT_RGBA);
glutInitWindowPosition(100,100);
glutInitWindowSize(800,800);
glutCreateWindow("MynDrawn: An Open Source Alternative to Minecraft");
glutDisplayFunc(renderScene);
glutIdleFunc (display); //update any variables in display,
//display can be changed to anyhing, as long as you move the
variables to be updated, in this case, angle++;
glutReshapeFunc (reshape); //reshape the window accordingly
glutKeyboardFunc (keyboard); //check the keyboard
glutMainLoop (); //call the main loop
return 0;
}
Could you let me know what I am doing wrong, and/or reccomend a glut camera tutorial? Thanks!!!!!