Click here to Skip to main content
15,884,472 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
error c2373 : redefinition different type modifiers
that error occurs at Cube::displayCB', Cube::reshapeCB, 'Cube::timerCB', all the files end "~CB".
How can i solve them ?


C++
///////////////////////////////////////////////////////////////////////////////
// main.cpp
// ========
// OpenGL picking with GL_SELECT mode
//
//  AUTHOR: Song Ho Ahn (song.ahn@gmail.com)
// CREATED: 2013-04-08
// UPDATED: 2013-04-08
///////////////////////////////////////////////////////////////////////////////

#ifdef __APPLE__
#include 
#else
#include 
#endif
#include <windows.h>
#include 
#pragma comment(lib,"ws2_32.lib")
#pragma comment (lib, "opengl32.lib")
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <string>
#include <iomanip>
#include <vector>
#include "Vectors.h"
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define L 480	  //(110cm = 1.1m)
#define W 400    //pallet size is given! (mm)
#define H 1440



/*
// function declearations /////////////////////////////////////////////////////
void initGL();
int  initGLUT(int argc, char **argv);
bool initSharedMem();
void clearSharedMem();
void initLights();
void setCamera(float posX, float posY, float posZ, float targetX, float targetY, float targetZ);
void drawString(const char *str, int x, int y, float color[4], void *font);
void drawString3D(const char *str, float pos[3], float color[4], void *font);
void showInfo();
void toOrtho();
void toPerspective();
void drawCubes();
int  selectCube();
int  processHits(int hitCount, GLuint* buffer);
*/
// constants
const int   SCREEN_WIDTH    = 400;
const int   SCREEN_HEIGHT   = 300;
const int   TEXT_WIDTH      = 8;
const int   TEXT_HEIGHT     = 13;
const float FOV_Y           = 60.0f;
const int   CUBE_ROWS       = 2;
const int   CUBE_COLS       = 4;
const int   CUBE_SLICES     = 1;
const float CAMERA_DISTANCE = 17.0f;
const float x = 0.0;
const float y = 0.0;
const float z = 0.0;


// global variables
void *font = GLUT_BITMAP_8_BY_13;
int screenWidth;
int screenHeight;
bool mouseLeftDown;
bool mouseRightDown;
float mouseX, mouseY;
float cameraDistance;
float cameraAngleX, cameraAngleY;
int drawMode;
int hitId;
std::vector<vector3> cubePositions; 

//////////////////////////////////////////////////////////////////////////////////
// 
/////////////////////////////////////////////////////////////////////////////////

// normal array
GLfloat normals[]  = { 0, 0, 1,   0, 0, 1,   0, 0, 1,   0, 0, 1,   // v0,v1,v2,v3 (front)
                       1, 0, 0,   1, 0, 0,   1, 0, 0,   1, 0, 0,   // v0,v3,v4,v5 (right)
                       0, 1, 0,   0, 1, 0,   0, 1, 0,   0, 1, 0,   // v0,v5,v6,v1 (top)
                      -1, 0, 0,  -1, 0, 0,  -1, 0, 0,  -1, 0, 0,   // v1,v6,v7,v2 (left)
                       0,-1, 0,   0,-1, 0,   0,-1, 0,   0,-1, 0,   // v7,v4,v3,v2 (bottom)
                       0, 0,-1,   0, 0,-1,   0, 0,-1,   0, 0,-1 }; // v4,v7,v6,v5 (back)

// index array of vertex array for glDrawElements() & glDrawRangeElement()
GLubyte indices[]  = { 0, 1, 2,   2, 3, 0,      // front
                       4, 5, 6,   6, 7, 4,      // right
                       8, 9,10,  10,11, 8,      // top
                      12,13,14,  14,15,12,      // left
                      16,17,18,  18,19,16,      // bottom
                      20,21,22,  22,23,20 };    // back


GLfloat Start_vertices[] = {0,0,0 , 1,1,1};










class Cube {
	public:
			float box_l;
			float box_w;
			float box_h;
			GLfloat vertices[];
			private : static Cube*  thisCube;

public: Cube(float x,float y,float z);
		void Sets_Vertices();
		void Draw_Cube();
		int initGLUT(int argc, char **argv);
		void initGL();
		void drawString(const char *str, int x, int y, float color[4], void *font);
		void drawString3D(const char *str, float pos[3], float color[4], void *font);
		bool initSharedMem();
		void clearSharedMem();
		void initLights();
		void setCamera(float posX, float posY, float posZ, float targetX, float targetY, float targetZ);
		void showInfo();
		void toOrtho();
		void toPerspective();
		void drawCubes();
		int selectCube();
		int processHits(int hitCount, GLuint* buffer);
		// GLUT CALLBACK functions ////////////////////////////////////////////////////
		static void displayCB();
		static void reshapeCB(int w, int h);
		static void timerCB(int millisec);
		static void idleCB();
		static void keyboardCB(unsigned char key, int x, int y);
		static void mouseCB(int button, int stat, int x, int y);
		static void mouseMotionCB(int x, int y);
		static void mousePassiveMotionCB(int x, int y);

		// CALLBACK function when exit() called ///////////////////////////////////////
		static 	void exitCB();

};


Cube::Cube(float x, float y, float z){
			box_l=x;
			box_w=y;
			box_h=z;
			thisCube=this;

}
Cube* Cube::thisCube = NULL;


void Cube::Sets_Vertices(){
	GLfloat vertices[] = { x-box_l, y-box_w, z+box_h,   x+box_l, y-box_w, z+box_h,   x+box_l, y+box_w, z+box_h,  x-box_l, y+box_w, z+box_h,   // v0,v1,v2,v3 (front)
                           x+box_l, y-box_w, z-box_h,   x+box_l, y+box_w, z-box_h,   x+box_l, y+box_w, z+box_h,  x+box_l, y-box_w, z+box_h,   // v0,v3,v4,v5 (right)
                           x-box_l, y+box_w, z+box_h,   x+box_l, y+box_w, z+box_h,   x+box_l, y+box_w, z-box_h,  x-box_l, y+box_w, z-box_h,       // v0,v5,v6,v1 (top)
                           x-box_l, y-box_w, z+box_h,   x-box_l, y+box_w, z+box_h,   x-box_l, y+box_w, z-box_h,  x-box_l, y-box_w, z-box_h,   // v1,v6,v7,v2 (left)
                           x-box_l, y-box_w, z+box_h,   x-box_l, y-box_w, z-box_h,   x+box_l, y-box_w, z-box_h,  x+box_l, y-box_w, z+box_h,   // v7,v4,v3,v2 (bottom)
                           x-box_l, y-box_w, z-box_h,   x-box_l, y+box_w, z-box_h,   x+box_l, y+box_w, z-box_h,  x+box_l, y-box_w, z-box_h }; // v4,v7,v6,v5 (back) 
}
///////////////////////////////////////////////////////////////////////////////
// initialize GLUT for windowing
///////////////////////////////////////////////////////////////////////////////

int Cube::initGLUT(int argc, char **argv)
{
    // GLUT stuff for windowing
    // initialization openGL window.
    // It must be called before any other GLUT routine.
    glutInit(&argc, argv);

    glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH | GLUT_STENCIL);   // display mode

    glutInitWindowSize(screenWidth, screenHeight);              // window size

    glutInitWindowPosition(100, 100);                           // window location

    // finally, create a window with openGL context
    // Window will not displayed until glutMainLoop() is called
    // It returns a unique ID.
    int handle = glutCreateWindow(argv[0]);     // param is the title of window

    // register GLUT callback functions
    glutDisplayFunc(displayCB);
    glutTimerFunc(33, timerCB, 33);             // redraw only every given millisec
    //glutIdleFunc(idleCB);                       // redraw whenever system is idle
    glutReshapeFunc(reshapeCB);
    glutKeyboardFunc(keyboardCB);
    glutMouseFunc(mouseCB);
    glutMotionFunc(mouseMotionCB);
    glutPassiveMotionFunc(mousePassiveMotionCB);
	                                                                            
    return handle;
}
///////////////////////////////////////////////////////////////////////////////
// initialize OpenGL
// disable unused features
///////////////////////////////////////////////////////////////////////////////
void Cube::initGL()
{
    glShadeModel(GL_SMOOTH);                    // shading mathod: GL_SMOOTH or GL_FLAT
    glPixelStorei(GL_UNPACK_ALIGNMENT, 4);      // 4-byte pixel alignment

    // enable /disable features
    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
    //glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
    //glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_LIGHTING);
    glEnable(GL_TEXTURE_2D);
    glEnable(GL_CULL_FACE);
    glEnable(GL_BLEND);

    // track material ambient and diffuse from surface color, call it before glEnable(GL_COLOR_MATERIAL)
    glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
    //glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
    glEnable(GL_COLOR_MATERIAL);

    glClearColor(0, 0, 0, 0);                   // background color
    glClearStencil(0);                          // clear stencil buffer
    glClearDepth(1.0f);                         // 0 is near, 1 is far
    glDepthFunc(GL_LEQUAL);

    initLights();

    float white[] = {1,1,1,1};
    glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 128);
    glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, white);
}
///////////////////////////////////////////////////////////////////////////////
// write 2d text using GLUT
// The projection matrix must be set to orthogonal before call this function.
///////////////////////////////////////////////////////////////////////////////
void Cube::drawString(const char *str, int x, int y, float color[4], void *font)
{
    glPushAttrib(GL_LIGHTING_BIT | GL_CURRENT_BIT); // lighting and color mask
    glDisable(GL_LIGHTING);     // need to disable lighting for proper text color
    glDisable(GL_TEXTURE_2D);
    glDepthFunc(GL_ALWAYS);

    glColor4fv(color);          // set text color
    glRasterPos2i(x, y);        // place text position

    // loop all characters in the string
    while(*str)
    {
        glutBitmapCharacter(font, *str);
        ++str;
    }

    glEnable(GL_TEXTURE_2D);
    glEnable(GL_LIGHTING);
    glDepthFunc(GL_LEQUAL);
    glPopAttrib();
}



///////////////////////////////////////////////////////////////////////////////
// draw a string in 3D space 
///////////////////////////////////////////////////////////////////////////////
void Cube::drawString3D(const char *str, float pos[3], float color[4], void *font)
{
    glPushAttrib(GL_LIGHTING_BIT | GL_CURRENT_BIT); // lighting and color mask
    glDisable(GL_LIGHTING);     // need to disable lighting for proper text color
    glDisable(GL_TEXTURE_2D);

    glColor4fv(color);          // set text color
    glRasterPos3fv(pos);        // place text position

    // loop all characters in the string
    while(*str)
    {
        glutBitmapCharacter(font, *str);
        ++str;
    }

    glDisable(GL_TEXTURE_2D);
    glEnable(GL_LIGHTING);
    glPopAttrib();
}

///////////////////////////////////////////////////////////////////////////////
// initialize global variables
///////////////////////////////////////////////////////////////////////////////
bool Cube::initSharedMem()
{
    screenWidth = SCREEN_WIDTH;
    screenHeight = SCREEN_HEIGHT;

    cameraAngleX = cameraAngleY = 0.0f;
    cameraDistance = CAMERA_DISTANCE;

    mouseLeftDown = mouseRightDown = false;
    mouseX = mouseY = 0;

    drawMode = 0;
    hitId = -1;

	


    // init cube positions  2.4 / 2 / 0.5
   const float STEP  = 4.0f;
	float startX[] = {0,0,0,4.8,4.8,4.8,9.6,9.6};
	float startY[] = {0,4,0,0,4,0,0,4,0};
	float startZ[]=  {0,0,1,0,0,1,0,0,1};
	int cur=0;
	int maxbox=CUBE_COLS*CUBE_ROWS*CUBE_SLICES;
	/* float startX = -STEP * (CUBE_COLS - 1) / 2.0f;
    float startY = STEP * (CUBE_COLSS - 1) / 2.0f;
    float startZ = STEP * (CUBE_SLICES - 1) / 2.0f;*/
	

    Vector3 position;

    for(int k = 0; k < maxbox; k++,cur++)        // z-direction
    {
       
                position.set(startX[cur],startY[cur],startZ[cur]);
                cubePositions.push_back(position);
      
    }




    return true;
}



///////////////////////////////////////////////////////////////////////////////
// clean up shared memory
///////////////////////////////////////////////////////////////////////////////
void Cube::clearSharedMem()
{
}



///////////////////////////////////////////////////////////////////////////////
// initialize lights
///////////////////////////////////////////////////////////////////////////////
void Cube::initLights()
{
    // set up light colors (ambient, diffuse, specular)
    GLfloat lightKa[] = {0.0f, 0.0f, 0.0f, 1.0f};  // ambient light
    GLfloat lightKd[] = {1.0f, 1.0f, 1.0f, 1.0f};  // diffuse light
    GLfloat lightKs[] = {1, 1, 1, 1};           // specular light
    glLightfv(GL_LIGHT0, GL_AMBIENT, lightKa);
    glLightfv(GL_LIGHT0, GL_DIFFUSE, lightKd);
    glLightfv(GL_LIGHT0, GL_SPECULAR, lightKs);

    // position the light
    float lightPos[4] = {0, 1, 1, 0};
    glLightfv(GL_LIGHT0, GL_POSITION, lightPos);

    glEnable(GL_LIGHT0);                        // MUST enable each light source after configuration
}



///////////////////////////////////////////////////////////////////////////////
// set camera position and lookat direction
///////////////////////////////////////////////////////////////////////////////
void Cube::setCamera(float posX, float posY, float posZ, float targetX, float targetY, float targetZ)
{
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    gluLookAt(posX, posY, posZ, targetX, targetY, targetZ, 0, 1, 0); // eye(x,y,z), focal(x,y,z), up(x,y,z)
}



///////////////////////////////////////////////////////////////////////////////
// display info messages
///////////////////////////////////////////////////////////////////////////////
void Cube::showInfo()
{
    // backup current model-view matrix
    glPushMatrix();                     // save current modelview matrix
    glLoadIdentity();                   // reset modelview matrix

    // set to 2D orthogonal projection
    glMatrixMode(GL_PROJECTION);        // switch to projection matrix
    glPushMatrix();                     // save current projection matrix
    glLoadIdentity();                   // reset projection matrix
    gluOrtho2D(0, screenWidth, 0, screenHeight);  // set to orthogonal projection

    float color[4] = {1, 1, 0, 1};

    // for print infos
    std::stringstream ss;
    ss << "Mouse: (" << mouseX << ", " << mouseY << ")";
    drawString(ss.str().c_str(), 2, screenHeight-TEXT_HEIGHT, color, font);
    ss.str("");

    ss << "Hit Cube ID: " << hitId;
    drawString(ss.str().c_str(), 2, screenHeight-(TEXT_HEIGHT*2), color, font);
    ss.str("");

    ss << "Move the mouse over a cube.";
    drawString(ss.str().c_str(), 2, 2, color, font);
    ss.str("");

    // unset floating format
    ss << std::resetiosflags(std::ios_base::fixed | std::ios_base::floatfield);

    // restore projection matrix
    glPopMatrix();                   // restore to previous projection matrix

    // restore modelview matrix
    glMatrixMode(GL_MODELVIEW);      // switch to modelview matrix
    glPopMatrix();                   // restore to previous modelview matrix
}



///////////////////////////////////////////////////////////////////////////////
// set projection matrix as orthogonal
///////////////////////////////////////////////////////////////////////////////
void Cube::toOrtho()
{
    // set viewport to be the entire window
    glViewport(0, 0, (GLsizei)screenWidth, (GLsizei)screenHeight);

    // set orthographic viewing frustum
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0, screenWidth, 0, screenHeight, -1, 1);

    // switch to modelview matrix in order to set scene
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
}



///////////////////////////////////////////////////////////////////////////////
// set the projection matrix as perspective
///////////////////////////////////////////////////////////////////////////////
void Cube::toPerspective()
{
    // set viewport to be the entire window
    glViewport(0, 0, (GLsizei)screenWidth, (GLsizei)screenHeight);

    // set perspective viewing frustum
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(FOV_Y, (float)(screenWidth)/screenHeight, 1.0f, 10000.0f); // FOV, AspectRatio, NearClip, FarClip

    // switch to modelview matrix in order to set scene
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
}



///////////////////////////////////////////////////////////////////////////////
// draw cubes  
///////////////////////////////////////////////////////////////////////////////
void Cube::drawCubes()
{
    // enable and specify pointers to vertex arrays
    glEnableClientState(GL_NORMAL_ARRAY);
    glEnableClientState(GL_VERTEX_ARRAY);
    glNormalPointer(GL_FLOAT, 0, normals);
    glVertexPointer(3, GL_FLOAT, 0, vertices);

    Vector3 pos;
    for(int i = 0; i < (int)cubePositions.size(); ++i)
    {
        glPushMatrix();
        glPushName(i);  // ignored if no GL_SELECT mode

        // get position from array and transform the cube
        pos = cubePositions.at(i);
        glTranslatef(pos.x, pos.y, pos.z);

        // set colour of cube
        if(i == hitId)
            glColor3f(1.0f, 0.0f, 0.0f);
        else
            glColor3f(0.7f, 0.7f, 0.7f);

        // draw a cube
        glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_BYTE, indices);

        glPopName();    // ignored if no GL_SELECT mode
        glPopMatrix();
    }



    glDisableClientState(GL_VERTEX_ARRAY);  // disable vertex arrays
    glDisableClientState(GL_NORMAL_ARRAY);

}



///////////////////////////////////////////////////////////////////////// //////
// draw cubes with GL_SELECT mode, and return the ID of the hit cube     
///////////////////////////////////////////////////////////////////////////////
int Cube::selectCube()
{
    const int BUFFER_SIZE = 512;
    GLuint selectionBuffer[BUFFER_SIZE];
    memset(selectionBuffer, 0, sizeof(int) * BUFFER_SIZE);
    int viewport[4] = {0, 0, screenWidth, screenHeight};

    // tell OpenGL to use selection buffer
    glSelectBuffer(BUFFER_SIZE, selectionBuffer);

    // enter selection mode
    glRenderMode(GL_SELECT);

    // init name stack
    glInitNames();

    // set matrix
    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    glLoadIdentity();
    gluPickMatrix(mouseX, screenHeight - mouseY, 3, 3, viewport);
    gluPerspective(FOV_Y,  (float)screenWidth / screenHeight, 0.1f, 1000.0f);

    // view transform
    glMatrixMode(GL_MODELVIEW);
    glPushMatrix();
    glTranslatef(0, 0, -cameraDistance);
    glRotatef(cameraAngleX, 1, 0, 0);   // pitch
    glRotatef(cameraAngleY, 0, 1, 0);   // heading

    glDisable(GL_BLEND);
    glDisable(GL_LIGHTING);
    glShadeModel(GL_FLAT);

    // draw cubes
    drawCubes();

    glEnable(GL_BLEND);
    glEnable(GL_LIGHTING);
    glShadeModel(GL_SMOOTH);

    glMatrixMode(GL_PROJECTION);
    glPopMatrix();
    glMatrixMode(GL_MODELVIEW);
    glPopMatrix();
    glFlush();

    // leave selection mode
    int hitCount = glRenderMode(GL_RENDER);

    // process hits
    if(hitCount > 0)
    {
        return processHits(hitCount, selectionBuffer);
    }
    else
    {
        return -1; // not hit
    }
}



///////////////////////////////////////////////////////////////////////////////
// 
///////////////////////////////////////////////////////////////////////////////
int Cube::processHits(int hitCount, GLuint* buffer)
{
    if(hitCount <= 0 || !buffer)
        return -1;

    GLuint nameCount, minZ, maxZ;
    GLuint hitZ = 0xffffffff;   // init with biggest value

    int hitId = 0;
    for(int i = 0; i < hitCount; ++i)
    {
        nameCount = *buffer++;
        minZ = *buffer++;
        maxZ = *buffer++;

        if(minZ < hitZ)
        {
            hitZ = minZ;
            hitId = (int)*buffer;
        }
        // consume other entries in the buffer
        for(int j = 0; j < (int)nameCount; ++j, ++buffer)
        {
            //cout << "Name: " << *buffer << endl;
            ;
        }
    }
    //DEBUG
    //std::cout << "HIT ID: " << hitId << std::endl;

    return hitId;
}

//=============================================================================
// CALLBACKS
//=============================================================================

void CALLBACK Cube::displayCB()
{
    // clear framebuffer
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

    // save the initial ModelView matrix before modifying ModelView matrix
    glPushMatrix();

    // tramsform camera
    glTranslatef(0, 0, -cameraDistance);
    glRotatef(cameraAngleX, 1, 0, 0);   // pitch
    glRotatef(cameraAngleY, 0, 1, 0);   // heading
	
    thisCube->drawCubes();
    thisCube->showInfo(); // print text

    glPopMatrix();
    glutSwapBuffers();
}


void CALLBACK Cube::reshapeCB(int width, int height)
{
    screenWidth = width;
    screenHeight = height;
    thisCube->toPerspective();
}


void CALLBACK Cube::timerCB(int millisec)
{
    glutTimerFunc(millisec, timerCB, millisec);
    glutPostRedisplay();
}


void CALLBACK Cube::idleCB()
{
    glutPostRedisplay();
}


void CALLBACK Cube::keyboardCB(unsigned char key, int x, int y)
{
    switch(key)
    {
    case 27: // ESCAPE
        exit(0);
        break;

    case 'd': // switch rendering modes (fill -> wire -> point)
    case 'D':
        drawMode = ++drawMode % 3;
        if(drawMode == 0)        // fill mode
        {
            glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
            glEnable(GL_DEPTH_TEST);
            glEnable(GL_CULL_FACE);
        }
        else if(drawMode == 1)  // wireframe mode
        {
            glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
            glDisable(GL_DEPTH_TEST);
            glDisable(GL_CULL_FACE);
        }
        else                    // point mode
        {
            glPolygonMode(GL_FRONT_AND_BACK, GL_POINT);
            glDisable(GL_DEPTH_TEST);
            glDisable(GL_CULL_FACE);
        }
        break;

    case 'r':
    case 'R':
        break;

    case ' ':
        break;

    default:
        ;
    }
}


void CALLBACK Cube::mouseCB(int button, int state, int x, int y)
{
    mouseX = x;
    mouseY = y;

    if(button == GLUT_LEFT_BUTTON)
    {
        if(state == GLUT_DOWN)
            mouseLeftDown = true;
        else if(state == GLUT_UP)
            mouseLeftDown = false;
    }

    else if(button == GLUT_RIGHT_BUTTON)
    {
        if(state == GLUT_DOWN)
            mouseRightDown = true;
        else if(state == GLUT_UP)
            mouseRightDown = false;
    }
}
void CALLBACK Cube:: mouseMotionCB(int x, int y){
    if(mouseLeftDown)
    {
        cameraAngleY += (x - mouseX);
        cameraAngleX += (y - mouseY);
        mouseX = x;
        mouseY = y;
    }
    if(mouseRightDown)
    {
        cameraDistance -= (y - mouseY) * 0.2f;
        mouseY = y;
    }
}


void CALLBACK Cube::mousePassiveMotionCB(int x, int y)
{
    mouseX = x;
    mouseY = y;

    // draw cubes with GL_SELECT mode and select a cube
    if(!mouseLeftDown && !mouseRightDown)
    {
        hitId = thisCube->selectCube();
    }
}



 void CALLBACK Cube::exitCB()
{
    thisCube->clearSharedMem();
}

void main(int argc, char **argv)
{
//	float x,y;
	Cube box1={2.0,1.0,1.0};


	box1.initSharedMem();
	box1.initGLUT(argc, argv);           
    box1.initGL();
	glutMainLoop();

	//  atexit(exitCB);

  //  initSharedMem();               

    // register exit callback
    //atexit(exitCB);

    // init GLUT and GL
   // initGLUT(argc, argv);           
   // initGL();
//	glutDisplayFunc(DoDisplay);
    // the last GLUT call (LOOP)
    // window will be shown and display callback is triggered by events
    // NOTE: this call never return main().
    glutMainLoop(); /* Start GLUT event-processing loop */

  //  return 0;
}</vector3></math.h></string.h></stdlib.h></stdio.h></vector></iomanip></string></sstream></iostream></cstdlib></windows.h>
Posted
Updated 27-Mar-15 2:32am
v3
Comments
Suvendu Shekhar Giri 27-Mar-15 8:30am    
Is this all you have? What is the problemaic portion? have you tried debuging?

See Compiler error C2373[^].

Use the search option to find all occurences of the mentioned identifiers in your project and the include files. Check for duplicate definitions with different modifiers.

You may also check the web site from where you got the code for help and optionally contact the author.
 
Share this answer
 
Your class declaration is missing the CALLBACK modifier.
C++
static void displayCB();

And then later the method is defined as;
C++
void CALLBACK Cube::displayCB()

Change the top declaration of the top one to
C++
static void CALLBACK displayCB();

(obviously do this for all methods affected).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900