Archived

This topic is now archived and is closed to further replies.

Errors in Quadric program which draws a 3D sphere on a background

This topic is 5537 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

These are the errors... anyone see any recognized errors? --------------------Configuration: fggfg - Win32 Debug-------------------- Compiling... QQ.c C:\NEW\Quartics\QQ.c(12) : error C2061: syntax error : identifier ''keys'' C:\NEW\Quartics\QQ.c(12) : error C2059: syntax error : '';'' C:\NEW\Quartics\QQ.c(12) : error C2059: syntax error : ''['' C:\NEW\Quartics\QQ.c(13) : error C2061: syntax error : identifier ''active'' C:\NEW\Quartics\QQ.c(13) : error C2059: syntax error : '';'' C:\NEW\Quartics\QQ.c(13) : error C2513: ''/*global*/ '' : no variable declared before ''='' C:\NEW\Quartics\QQ.c(14) : error C2061: syntax error : identifier ''fullscreen'' C:\NEW\Quartics\QQ.c(14) : error C2059: syntax error : '';'' C:\NEW\Quartics\QQ.c(14) : error C2513: ''/*global*/ '' : no variable declared before ''='' C:\NEW\Quartics\QQ.c(15) : error C2061: syntax error : identifier ''light'' C:\NEW\Quartics\QQ.c(15) : error C2059: syntax error : '';'' C:\NEW\Quartics\QQ.c(16) : error C2061: syntax error : identifier ''lp'' C:\NEW\Quartics\QQ.c(16) : error C2059: syntax error : '';'' C:\NEW\Quartics\QQ.c(17) : error C2061: syntax error : identifier ''fp'' C:\NEW\Quartics\QQ.c(17) : error C2059: syntax error : '';'' C:\NEW\Quartics\QQ.c(18) : error C2061: syntax error : identifier ''sp'' C:\NEW\Quartics\QQ.c(18) : error C2059: syntax error : '';'' C:\NEW\Quartics\QQ.c(44) : error C2040: ''quadratic'' : ''int '' differs in levels of indirection from ''struct GLUquadric *'' C:\NEW\Quartics\QQ.c(44) : error C2099: initializer is not a constant C:\NEW\Quartics\QQ.c(45) : error C2059: syntax error : '','' C:\NEW\Quartics\QQ.c(45) : error C2143: syntax error : missing '')'' before ''constant'' C:\NEW\Quartics\QQ.c(45) : error C2143: syntax error : missing ''{'' before ''constant'' C:\NEW\Quartics\QQ.c(45) : error C2059: syntax error : '''' C:\NEW\Quartics\QQ.c(45) : error C2059: syntax error : '')'' C:\NEW\Quartics\QQ.c(46) : error C2059: syntax error : '','' C:\NEW\Quartics\QQ.c(46) : error C2143: syntax error : missing '')'' before ''constant'' C:\NEW\Quartics\QQ.c(46) : error C2143: syntax error : missing ''{'' before ''constant'' C:\NEW\Quartics\QQ.c(46) : error C2059: syntax error : '''' C:\NEW\Quartics\QQ.c(46) : error C2059: syntax error : '')'' C:\NEW\Quartics\QQ.c(57) : warning C4013: ''LoadBMP'' undefined; assuming extern returning int C:\NEW\Quartics\QQ.c(57) : warning C4047: ''='' : ''struct _AUX_RGBImageRec *'' differs in levels of indirection from ''int '' C:\NEW\Quartics\QQ.c(58) : warning C4047: ''='' : ''struct _AUX_RGBImageRec *'' differs in levels of indirection from ''int '' C:\NEW\Quartics\QQ.c(64) : error C2143: syntax error : missing '';'' before ''type'' C:\NEW\Quartics\QQ.c(64) : error C2143: syntax error : missing '';'' before ''type'' C:\NEW\Quartics\QQ.c(64) : error C2143: syntax error : missing '')'' before ''type'' C:\NEW\Quartics\QQ.c(64) : error C2143: syntax error : missing '';'' before ''type'' C:\NEW\Quartics\QQ.c(64) : error C2065: ''loop'' : undeclared identifier C:\NEW\Quartics\QQ.c(64) : warning C4552: ''<='' : operator has no effect; expected operator with side-effect C:\NEW\Quartics\QQ.c(64) : error C2059: syntax error : '')'' C:\NEW\Quartics\QQ.c(65) : error C2143: syntax error : missing '';'' before ''{'' C:\NEW\Quartics\QQ.c(146) : error C2143: syntax error : missing '')'' before ''constant'' C:\NEW\Quartics\QQ.c(146) : error C2143: syntax error : missing ''{'' before ''constant'' C:\NEW\Quartics\QQ.c(146) : error C2059: syntax error : '''' C:\NEW\Quartics\QQ.c(146) : error C2059: syntax error : '')'' C:\NEW\Quartics\QQ.c(147) : error C2143: syntax error : missing '')'' before ''constant'' C:\NEW\Quartics\QQ.c(147) : error C2143: syntax error : missing ''{'' before ''constant'' C:\NEW\Quartics\QQ.c(147) : error C2059: syntax error : '''' C:\NEW\Quartics\QQ.c(147) : error C2059: syntax error : '')'' C:\NEW\Quartics\QQ.c(203) : error C2059: syntax error : ''if'' C:\NEW\Quartics\QQ.c(211) : error C2059: syntax error : ''}'' Error executing cl.exe.

Share this post


Link to post
Share on other sites
#include <windows.h> // Header File For Windows
#include <stdio.h> // Header File For Standard Input/Output
#include <gl\gl.h> // Header File For The OpenGL32 Library
#include <gl\glu.h> // Header File For The GLu32 Library
#include <gl\glaux.h> // Header File For The GLaux Library

HDC hDC=NULL; // Private GDI Device Context
HGLRC hRC=NULL; // Permanent Rendering Context
HWND hWnd=NULL; // Holds Our Window Handle
HINSTANCE hInstance; // Holds The Instance Of The Application

bool keys[256]; // Array Used For The Keyboard Routine
bool active=TRUE; //Window Active Flag set to TRUE by Default
bool fullscreen=TRUE; //Fullscreen Flag Set To Fullscreen Mode by Deffault
bool light; // Lighting ON/OFF
bool lp; // L Pressed?
bool fp; // F Pressed?
bool sp; // Spacebar Pressed? ( NEW )

int part1; // Start Of Disc ( NEW )
int part2; // End Of Disc ( NEW )
int p1=0; // Increase 1 ( NEW )
int p2=1; // Increase 2 ( NEW )

GLfloat xrot; // X Rotation
GLfloat yrot; // Y Rotation
GLfloat xspeed; // X Rotation Speed
GLfloat yspeed; // Y Rotation Speed

GLfloat z=-5.0f; // Depth Into The Screen

GLUquadricObj *quadratic; // Storage For Our Quadratic Objects ( void )

GLfloat LightAmbient[]= { 0.5f, 0.5f, 0.5f, 1.0f }; // Ambient Light Values
GLfloat LightDiffuse[]= { 1.0f, 1.0f, 1.0f, 1.0f }; // Diffuse Light Values
GLfloat LightPosition[]= { 0.0f, 0.0f, 2.0f, 1.0f }; // Light Position

GLuint filter; // Which Filter To Use
GLuint texture[6]; // Storage For 6 Textures
GLuint object=0; // Which Object To Draw ( NEW )

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); // Declaration For WndProc

quadratic = gluNewQuadric(); // Create A Pointer To The Quadric Object ( NEW )
gluQuadricNormals(quadratic, GLU_SMOOTH); // Create Smooth Normals ( NEW )
gluQuadricTexture(quadratic, GL_TRUE); // Create Texture Coords ( NEW )

int LoadGLTextures() // Load Bitmaps And Convert To Textures
{
int Status=FALSE; // Status Indicator

AUX_RGBImageRec *TextureImage[2]; // Create Storage Space For The Texture

memset(TextureImage,0,sizeof(void *)*2); // Set The Pointer To NULL

// Load The Bitmap, Check For Errors, If Bitmap''s Not Found Quit
if ((TextureImage[0]=LoadBMP("Backgrd.bmp")) && // Background Texture
(TextureImage[1]=LoadBMP("Ducky"))) // Reflection Texture (Spheremap)
{
Status=TRUE; // Set The Status To TRUE

glGenTextures(6, &texture[0]); // Create Three Textures

for (int loop=0; loop<=1; loop++)
{
// Create Nearest Filtered Texture
glBindTexture(GL_TEXTURE_2D, texture[loop]); // Gen Tex 0 And 1
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[loop]->sizeX, TextureImage[loop]->sizeY,
0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[loop]->data);

// Create Linear Filtered Texture
glBindTexture(GL_TEXTURE_2D, texture[loop+2]); // Gen Tex 2, 3 And 4
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[loop]->sizeX, TextureImage[loop]->sizeY,
0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[loop]->data);

// Create MipMapped Texture
glBindTexture(GL_TEXTURE_2D, texture[loop+4]); // Gen Tex 4 and 5
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, TextureImage[loop]->sizeX, TextureImage[loop]->sizeY,
GL_RGB, GL_UNSIGNED_BYTE, TextureImage[loop]->data);
}
for (loop=0; loop<=1; loop++)
{
if (TextureImage[loop]) // If Texture Exists
{
if (TextureImage[loop]->data) // If Texture Image Exists
{
free(TextureImage[loop]->data); // Free The Texture Image Memory
}
free(TextureImage[loop]); // Free The Image Structure
}
}
}

return Status; // Return The Status
}


GLvoid glDrawCube()
{
glBegin(GL_QUADS);
// Front Face
glNormal3f( 0.0f, 0.0f, 0.5f);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f);
// Back Face
glNormal3f( 0.0f, 0.0f,-0.5f);
glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f);
// Top Face
glNormal3f( 0.0f, 0.5f, 0.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, 1.0f, 1.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, 1.0f, 1.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f);
// Bottom Face
glNormal3f( 0.0f,-0.5f, 0.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, -1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, -1.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f);
// Right Face
glNormal3f( 0.5f, 0.0f, 0.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f);
// Left Face
glNormal3f(-0.5f, 0.0f, 0.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f);
glEnd();
}

glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); // Set The Texture Generation Mode For S To Sphere Mapping ( NEW )
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); // Set The Texture Generation Mode For T To Sphere Mapping ( NEW )

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

glTranslatef(0.0f,0.0f,z);

glEnable(GL_TEXTURE_GEN_S); // Enable Texture Coord Generation For S ( NEW )
glEnable(GL_TEXTURE_GEN_T); // Enable Texture Coord Generation For T ( NEW )

glBindTexture(GL_TEXTURE_2D, texture[filter+(filter+1)]); // This Will Select A Sphere Map
glPushMatrix();
glRotatef(xrot,1.0f,0.0f,0.0f);
glRotatef(yrot,0.0f,1.0f,0.0f);
switch(object)
{
case 0:
glDrawCube();
break;
case 1:
glTranslatef(0.0f,0.0f,-1.5f); // Center The Cylinder
gluCylinder(quadratic,1.0f,1.0f,3.0f,32,32); // A Cylinder With A Radius Of 0.5 And A Height Of 2
break;
case 2:
gluSphere(quadratic,1.3f,32,32); // Sphere With A Radius Of 1 And 16 Longitude/Latitude Segments
break;
case 3:
glTranslatef(0.0f,0.0f,-1.5f); // Center The Cone
gluCylinder(quadratic,1.0f,0.0f,3.0f,32,32); // Cone With A Bottom Radius Of .5 And Height Of 2
break;
};

glPopMatrix();
glDisable(GL_TEXTURE_GEN_S); // Disable Texture Coord Generation ( NEW )
glDisable(GL_TEXTURE_GEN_T); // Disable Texture Coord Generation ( NEW )

glBindTexture(GL_TEXTURE_2D, texture[filter*2]); // This Will Select The BG Texture ( NEW )
glPushMatrix();
glTranslatef(0.0f, 0.0f, -24.0f);
glBegin(GL_QUADS);
glNormal3f( 0.0f, 0.0f, 1.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-13.3f, -10.0f, 10.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f( 13.3f, -10.0f, 10.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f( 13.3f, 10.0f, 10.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-13.3f, 10.0f, 10.0f);
glEnd();

glPopMatrix();

xrot+=xspeed;
yrot+=yspeed;
return TRUE; // Keep Going
}

if (keys['' ''] && !sp)
{
sp=TRUE;
object++;
if(object>3)
object=0;
}

}

Share this post


Link to post
Share on other sites