| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1620 人关注过本帖
标题:有错误,如何解决呢
只看楼主 加入收藏
chenchen0318
Rank: 1
等 级:新手上路
帖 子:23
专家分:0
注 册:2015-9-16
收藏
得分:0 
@jklqwe111 这个是 DisplayListPrimitive.h的源代码


#include <opencsg.h>

namespace OpenCSG {

    class DisplayListPrimitive: public Primitive  {
    public:
        /// An object of this class contains the OpenGL id of a display
        /// list that is compiled by the application. render() just invokes
        /// this display list.
        /// Operation and convexity are just forwarded to the base Primitive class.
        DisplayListPrimitive(unsigned int displayListId_, Operation, unsigned int convexity);

        /// Sets the display list id
        void setDisplayListId(unsigned int);
        /// Returns the display list id
        unsigned int getDisplayListId() const;

        /// Calls the display list.
        virtual void render();

    private:
        unsigned int mDisplayListId;
    };

} // namespace OpenCSG

这个是DisplayListPrimitive.cpp的源代码

#include <GL/glew.h>
#include "displaylistPrimitive.h"
#include <OpenCSG.h>



namespace OpenCSG {

    DisplayListPrimitive::DisplayListPrimitive(unsigned int i , Operation o, unsigned int c)
        : Primitive(o, c)
    {
        mDisplayListId = i;
    }

    void DisplayListPrimitive::setDisplayListId(unsigned int i) {
        mDisplayListId = i;
    }

    unsigned int DisplayListPrimitive::getDisplayListId() const {
        return mDisplayListId;
    }

    void DisplayListPrimitive::render() {
        glCallList(mDisplayListId);
    }

}
2015-09-17 23:41
chenchen0318
Rank: 1
等 级:新手上路
帖 子:23
专家分:0
注 册:2015-9-16
收藏
得分:0 
@jklqwe111 这是displaylistPrimitive.cpp的源代码

#include <GL/glew.h>
#include "displaylistPrimitive.h"
#include <OpenCSG.h>



namespace OpenCSG {

    DisplayListPrimitive::DisplayListPrimitive(unsigned int i , Operation o, unsigned int c)
        : Primitive(o, c)
    {
        mDisplayListId = i;
    }

    void DisplayListPrimitive::setDisplayListId(unsigned int i) {
        mDisplayListId = i;
    }

    unsigned int DisplayListPrimitive::getDisplayListId() const {
        return mDisplayListId;
    }

    void DisplayListPrimitive::render() {
        glCallList(mDisplayListId);
    }

}

这是DisplayListPrimitive.h的源代码
#include <opencsg.h>

namespace OpenCSG {

    class DisplayListPrimitive: public Primitive  {
    public:
        /// An object of this class contains the OpenGL id of a display
        /// list that is compiled by the application. render() just invokes
        /// this display list.
        /// Operation and convexity are just forwarded to the base Primitive class.
        DisplayListPrimitive(unsigned int displayListId_, Operation, unsigned int convexity);

        /// Sets the display list id
        void setDisplayListId(unsigned int);
        /// Returns the display list id
        unsigned int getDisplayListId() const;

        /// Calls the display list.
        virtual void render();

    private:
        unsigned int mDisplayListId;
    };

} // namespace OpenCSG
2015-09-18 02:50
TonyDeng
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:304
帖 子:25859
专家分:48889
注 册:2011-6-22
收藏
得分:0 
#include <GL/glew.h>
 #include "displaylistPrimitive.h"
 #include <OpenCSG.h>



 namespace OpenCSG {

     DisplayListPrimitive::DisplayListPrimitive(unsigned int i , Operation o, unsigned int c)
         : Primitive(o, c)
     {
         mDisplayListId = i;
     }

     void DisplayListPrimitive::setDisplayListId(unsigned int i) {
         mDisplayListId = i;
     }

     unsigned int DisplayListPrimitive::getDisplayListId() const {
         return mDisplayListId;
     }

     void DisplayListPrimitive::render() {
         glCallList(mDisplayListId);
     }

 }

描红的构造函数在哪里定义?

授人以渔,不授人以鱼。
2015-09-18 12:10
chenchen0318
Rank: 1
等 级:新手上路
帖 子:23
专家分:0
注 册:2015-9-16
收藏
得分:0 
谁能帮帮我,我真的很着急很上火,很无助!
2015-09-18 12:11
chenchen0318
Rank: 1
等 级:新手上路
帖 子:23
专家分:0
注 册:2015-9-16
收藏
得分:0 
@TonyDeng  你好!谢谢你!描红的构造函数在主程序里这里出现了

/*  chen.cpp   Copyright (c) 2015 by T.  */
/*                                     */
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <glut.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <opencsg.h>
#include <math.h>
//#include <windows.h>
//#include <memory.h>
#include "myShape.h"
#include "displaylistPrimitive.h"
#define KEY_ESC 27
#define PI 3.1415
#define N 4

//#pragma comment(lib,"C:\\OpenGL包\\opengl32.lib")
//#pragma comment(lib,"C:\\OpenGL包\\glu32.lib")
//#pragma comment(lib,"C:\\OpenGL包\\glaux.lib")
//#pragma comment(lib,"C:\\OpenGL包\\glut.lib")
//#pragma comment(lib,"C:\\OpenGL包\\glut32.lib")
//#pragma comment(lib,"C:\\OpenGL包\\OpenCSG.lib")

//#pragma comment(lib,"C:\\OpenGL包\\glew32.lib")



typedef struct  {
    float x;
    float y;
    float z;
    float shita;
    float alpha;
} US_POS;

typedef struct  {
    float x;
    float y;
    float z;
} SH_POS;

const int shoe_point = 25433;
const int us_point_left = 4;
const int us_point_right = 4;
char *file_left="3.txt";
char *file_right="4.txt";
float theta = 0.0;
float dis=200.0, tws=0.0, ele=0.0, azi=0.0;
FILE *fp_left;
FILE *fp_right;
FILE *fp_us_left;
FILE *fp_us_right;
FILE *fp;
FILE *input_0;
//FILE *input_1;
//FILE *input_2;
//FILE *input_3;
//FILE *input_4;
//FILE *input_5;
FILE *input_right;
//float x[25433],y[25433],z[25433];
SH_POS sh_left[25433];
SH_POS sh_right[25433];
US_POS us_left[us_point_left];
US_POS us_right[us_point_right];
US_POS in_us_left[us_point_left];
US_POS in_us_right[us_point_right];
SH_POS sh_left4cm[88];
SH_POS sh_right4cm[97];
SH_POS full_sh_left4cm[10000];
SH_POS full_sh_right4cm[10000];
double left_us_matrix[us_point_left][4][4];
double right_us_matrix[us_point_right][4][4];
double left_gl_matrix[us_point_left][16];
double right_gl_matrix[us_point_right][16];
int us_flag_left=1;
int us_flag_right=1;
int camera_flag = 0;
float lx=0.0, ly=-170.0, lz=0.0;
float dx=0.0, dy=0.0, dz=0.0;
float sx=0.0, sy=0.0, sz=1.0;
float left_sh_angle=0.0;
float left_sh_height=0.0;
//US_POS right_sh_pos={51.5, 51.5, 0.0, 0.0, 0.0};
US_POS left_sh_pos={0.0, 0.0, 0.0, 0.0, 0.0};
US_POS right_sh_pos={10.0, 0.0, 0.0,-90.0, 0.0};
char ss[10];
int mot_flag=0;
int stop_mot=0;
int roop_flag=0;
int solid_flag=1;
float S1,S2;
SH_POS cone_point[18772];
//double length;
int left_count_4cm = 0;
int right_count_4cm = 0;
int p_us_left=0;
int p_us_right=0;

std::vector<OpenCSG::Primitive*> primitives;

void polarview(float distance, float twist, float elevation, float azimuth);
void CreateDisplayList(void);
void SetLight( GLenum light );
void SetMaterial( GLfloat R, GLfloat G, GLfloat B , GLfloat Alpha);
void display(void);
void idle(void);
void myKbd( unsigned char key, int x, int y );
void myInit (char *progname);
void camera_pos_reset();
void shoe_pos_reset();
void DrawString( char *string, GLfloat x, GLfloat y );
void Motion(void);
void Cone(void);
void matrixmultiply(double a[N][N],double b[N][N],double c[N][N]);
void transmatrix(double a[N][N],US_POS us,double c[4]);
void para2matrix(double x, double y, double z, double shita, double c[4][4], int para);
void inverseMatrix(double a[N][N], double inv_a[N][N]);
double msr_length(US_POS point1, SH_POS point2);

void polarview(float distance, float twist, float elevation, float azimuth){
    glTranslatef(0.0, 0.0, -distance);
    glRotatef(-twist, 0.0, 0.0, 1.0);
    glRotatef(-elevation, 1.0, 0.0, 0.0);
    glRotatef(-azimuth, 0.0, 1.0, 0.0);
}



void CreateDisplayList()
{
        GLuint id1 = glGenLists(1);
        glNewList(id1, GL_COMPILE);
            glPushMatrix();
                ////glColor3f(0.0, 0.0, 1.0);
                glTranslatef(4.5,7.0,4.0);
                glRotatef(-30.0, 0.0,0.0,1.0);
                //mySolidCylinder(0.5, 0.7,10);
                glRotatef(90.0, 1.0,0.0,0.0);
                glTranslatef(0.0,0.0,-141.0);
                glutSolidCone(51.3,141.0,10,10);
                //glutSolidCone(51.3,141,20,10);
            glPopMatrix();
        glEndList();

        GLuint id2 = glGenLists(1);
        glNewList(id2, GL_COMPILE);
        glPushMatrix();
        glTranslatef(51.5,51.5,51.5);
        glutSolidCube(103.0);
        glPopMatrix();
        glEndList();

        primitives.push_back(new OpenCSG::DisplayListPrimitive(id1, OpenCSG::Intersection, 1));
        primitives.push_back(new OpenCSG::DisplayListPrimitive(id2, OpenCSG::Subtraction, 1));

}
2015-09-18 12:16
TonyDeng
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:304
帖 子:25859
专家分:48889
注 册:2011-6-22
收藏
得分:0 
在哪里?你描出来我看看。

授人以渔,不授人以鱼。
2015-09-18 12:19
chenchen0318
Rank: 1
等 级:新手上路
帖 子:23
专家分:0
注 册:2015-9-16
收藏
得分:0 
/*  chen.cpp   Copyright (c) 2015 by T.  */
/*                                     */
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <glut.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <opencsg.h>
#include <math.h>
//#include <windows.h>
//#include <memory.h>
#include "myShape.h"
#include "displaylistPrimitive.h"
#define KEY_ESC 27
#define PI 3.1415
#define N 4

//#pragma comment(lib,"C:\\OpenGL包\\opengl32.lib")
//#pragma comment(lib,"C:\\OpenGL包\\glu32.lib")
//#pragma comment(lib,"C:\\OpenGL包\\glaux.lib")
//#pragma comment(lib,"C:\\OpenGL包\\glut.lib")
//#pragma comment(lib,"C:\\OpenGL包\\glut32.lib")
//#pragma comment(lib,"C:\\OpenGL包\\OpenCSG.lib")

//#pragma comment(lib,"C:\\OpenGL包\\glew32.lib")



typedef struct  {
    float x;
    float y;
    float z;
    float shita;
    float alpha;
} US_POS;

typedef struct  {
    float x;
    float y;
    float z;
} SH_POS;

const int shoe_point = 25433;
const int us_point_left = 4;
const int us_point_right = 4;
char *file_left="3.txt";
char *file_right="4.txt";
float theta = 0.0;
float dis=200.0, tws=0.0, ele=0.0, azi=0.0;
FILE *fp_left;
FILE *fp_right;
FILE *fp_us_left;
FILE *fp_us_right;
FILE *fp;
FILE *input_0;
//FILE *input_1;
//FILE *input_2;
//FILE *input_3;
//FILE *input_4;
//FILE *input_5;
FILE *input_right;
//float x[25433],y[25433],z[25433];
SH_POS sh_left[25433];
SH_POS sh_right[25433];
US_POS us_left[us_point_left];
US_POS us_right[us_point_right];
US_POS in_us_left[us_point_left];
US_POS in_us_right[us_point_right];
SH_POS sh_left4cm[88];
SH_POS sh_right4cm[97];
SH_POS full_sh_left4cm[10000];
SH_POS full_sh_right4cm[10000];
double left_us_matrix[us_point_left][4][4];
double right_us_matrix[us_point_right][4][4];
double left_gl_matrix[us_point_left][16];
double right_gl_matrix[us_point_right][16];
int us_flag_left=1;
int us_flag_right=1;
int camera_flag = 0;
float lx=0.0, ly=-170.0, lz=0.0;
float dx=0.0, dy=0.0, dz=0.0;
float sx=0.0, sy=0.0, sz=1.0;
float left_sh_angle=0.0;
float left_sh_height=0.0;
//US_POS right_sh_pos={51.5, 51.5, 0.0, 0.0, 0.0};
US_POS left_sh_pos={0.0, 0.0, 0.0, 0.0, 0.0};
US_POS right_sh_pos={10.0, 0.0, 0.0,-90.0, 0.0};
char ss[10];
int mot_flag=0;
int stop_mot=0;
int roop_flag=0;
int solid_flag=1;
float S1,S2;
SH_POS cone_point[18772];
//double length;
int left_count_4cm = 0;
int right_count_4cm = 0;
int p_us_left=0;
int p_us_right=0;

std::vector<OpenCSG::Primitive*> primitives;

void polarview(float distance, float twist, float elevation, float azimuth);
void CreateDisplayList(void);
void SetLight( GLenum light );
void SetMaterial( GLfloat R, GLfloat G, GLfloat B , GLfloat Alpha);
void display(void);
void idle(void);
void myKbd( unsigned char key, int x, int y );
void myInit (char *progname);
void camera_pos_reset();
void shoe_pos_reset();
void DrawString( char *string, GLfloat x, GLfloat y );
void Motion(void);
void Cone(void);
void matrixmultiply(double a[N][N],double b[N][N],double c[N][N]);
void transmatrix(double a[N][N],US_POS us,double c[4]);
void para2matrix(double x, double y, double z, double shita, double c[4][4], int para);
void inverseMatrix(double a[N][N], double inv_a[N][N]);
double msr_length(US_POS point1, SH_POS point2);

void polarview(float distance, float twist, float elevation, float azimuth){
    glTranslatef(0.0, 0.0, -distance);
    glRotatef(-twist, 0.0, 0.0, 1.0);
    glRotatef(-elevation, 1.0, 0.0, 0.0);
    glRotatef(-azimuth, 0.0, 1.0, 0.0);
}



void CreateDisplayList()
{
        GLuint id1 = glGenLists(1);
        glNewList(id1, GL_COMPILE);
            glPushMatrix();
                ////glColor3f(0.0, 0.0, 1.0);
                glTranslatef(4.5,7.0,4.0);
                glRotatef(-30.0, 0.0,0.0,1.0);
                //mySolidCylinder(0.5, 0.7,10);
                glRotatef(90.0, 1.0,0.0,0.0);
                glTranslatef(0.0,0.0,-141.0);
                glutSolidCone(51.3,141.0,10,10);
                //glutSolidCone(51.3,141,20,10);
            glPopMatrix();
        glEndList();

        GLuint id2 = glGenLists(1);
        glNewList(id2, GL_COMPILE);
        glPushMatrix();
        glTranslatef(51.5,51.5,51.5);
        glutSolidCube(103.0);
        glPopMatrix();
        glEndList();

        primitives.push_back(new OpenCSG::DisplayListPrimitive(id1, OpenCSG::Intersection, 1));
        primitives.push_back(new OpenCSG::DisplayListPrimitive(id2, OpenCSG::Subtraction, 1));

}
2015-09-18 12:25
TonyDeng
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:304
帖 子:25859
专家分:48889
注 册:2011-6-22
收藏
得分:0 
你这些是使用,不是定义。

授人以渔,不授人以鱼。
2015-09-18 12:28
chenchen0318
Rank: 1
等 级:新手上路
帖 子:23
专家分:0
注 册:2015-9-16
收藏
得分:0 
那应该就没有定义过!接下来我应该怎么定义是正确呢?谢谢你!
2015-09-18 12:31
TonyDeng
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:304
帖 子:25859
专家分:48889
注 册:2011-6-22
收藏
得分:0 
写一个带那两个参数的构造函数。

授人以渔,不授人以鱼。
2015-09-18 12:36
快速回复:有错误,如何解决呢
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.027727 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved