error C2653: 'CColorView' : is not a class or namespace name
答案:1 悬赏:80 手机版
解决时间 2021-02-07 21:05
- 提问者网友:呐年旧曙光
- 2021-02-07 15:16
一个应用程序,运行后在用户区绘一个圆,单击鼠标颜色变化
最佳答案
- 五星知识达人网友:狂恋
- 2021-02-07 15:39
#ifdef struc_h
#define struc_h
class create
{
public:
void dramobj();
};
#endif
cpp文件:
#include <windows.h>
#include <stdio.h>
#include <gl/gl.h>
#include "struct.h"
typedef struct
{
float x,y,z,p;
}vertex;
typedef struct
{
int verts;
vertex *points;
}object;
void objallocate(object *k,int n) // 申请内存空间
{
k->points=(vertex*)malloc(sizeof(vertex)*n);
}
void objfree(object *k)
{
free(k->points);
}
object m;
void readstr(FILE *f,char *strings)
{
do
{
fgets(strings, 255, f);
} while ((strings[0] == '/') || (strings[0] == '\n'));
return;
}
void objload(char *name,object *k)
{
int ver;
float rx,ry,rz,rp;
FILE *filein;
char oneline[255];
filein = fopen("in1t.txt", "rt");
readstr(filein,oneline);
sscanf(oneline, "Vertices: %d\n", &ver);
k->verts=ver;
objallocate(k,ver); // 申请内存空间
for (int i=0;i<ver;i++)
{
readstr(filein,oneline);
sscanf(oneline, "%f %f %f", &rx, &ry, &rz,&rp);
k->points[i].x = rx;
k->points[i].y = ry;
k->points[i].z = rz;
k->points[i].p=rz;
}
fclose(filein);
}
void create::dramobj ()
{
GLfloat tx,ty,tz,tp;
vertex q;
objload("in5t",&m);//导入模型
glBegin (GL_POINTS);
for(int s=0;s<m.verts;s++)
{
tx=q.x;
ty=q.y;
tz=q.z;
tp=q.p;
glColor3f(tp/350,tp/350,tp/350);
glVertex3f (tx,ty,tz);
}
glEnd();
#define struc_h
class create
{
public:
void dramobj();
};
#endif
cpp文件:
#include <windows.h>
#include <stdio.h>
#include <gl/gl.h>
#include "struct.h"
typedef struct
{
float x,y,z,p;
}vertex;
typedef struct
{
int verts;
vertex *points;
}object;
void objallocate(object *k,int n) // 申请内存空间
{
k->points=(vertex*)malloc(sizeof(vertex)*n);
}
void objfree(object *k)
{
free(k->points);
}
object m;
void readstr(FILE *f,char *strings)
{
do
{
fgets(strings, 255, f);
} while ((strings[0] == '/') || (strings[0] == '\n'));
return;
}
void objload(char *name,object *k)
{
int ver;
float rx,ry,rz,rp;
FILE *filein;
char oneline[255];
filein = fopen("in1t.txt", "rt");
readstr(filein,oneline);
sscanf(oneline, "Vertices: %d\n", &ver);
k->verts=ver;
objallocate(k,ver); // 申请内存空间
for (int i=0;i<ver;i++)
{
readstr(filein,oneline);
sscanf(oneline, "%f %f %f", &rx, &ry, &rz,&rp);
k->points[i].x = rx;
k->points[i].y = ry;
k->points[i].z = rz;
k->points[i].p=rz;
}
fclose(filein);
}
void create::dramobj ()
{
GLfloat tx,ty,tz,tp;
vertex q;
objload("in5t",&m);//导入模型
glBegin (GL_POINTS);
for(int s=0;s<m.verts;s++)
{
tx=q.x;
ty=q.y;
tz=q.z;
tp=q.p;
glColor3f(tp/350,tp/350,tp/350);
glVertex3f (tx,ty,tz);
}
glEnd();
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯