472,338 Members | 1,669 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,338 software developers and data experts.

compling error in visual studio

Hello
I am now compling a project, but in one source file of this project, I met
this problem. It seems very strange.

Below is this source file:
----------------------------------------
#include "icarus_types.h"

#ifdef WIN32
#include <GL/glu.h>
#include <GL/glext.h>
extern PFNGLCONVOLUTIONFILTER2DPROC glConvolutionFilter2D;
extern PFNGLCONVOLUTIONPARAMETERIPROC glConvolutionParameteri;
#endif

extern Form *form;
extern Project *project;
extern psRand myrand;
extern int can_convolve;

SpecularPatch::SpecularPatch(Patch *patch, int i0, int i1, int i2)
{
this->index[0]= i0;
this->index[1]= i1;
this->index[2]= i2;

// sum radiance
this->L[0]= patch->E[0]+patch->B[0];
this->L[1]= patch->E[1]+patch->B[1];
this->L[2]= patch->E[2]+patch->B[2];
}

SpecularPatch::~SpecularPatch()
{
}

void Project::buildSpecularEnvironment()
{
Octree *octree;
OctreeVertex *ov;
Object *obj;
int face;
Patch *patch;
SpecularPatch *spatch;
int i,j,i0,i1,i2;

// count max vertices and patches
i= 0;
this->num_specular_patches= 0;
for (obj= this->objects; obj; obj= obj->next)
for (face= 0; face< obj->num_faces; face++)
{
this->num_specular_patches += obj->faces[face].num_patches;
i += 3*obj->faces[face].num_patches;
}

// initialise
this->specular_patches=
(SpecularPatch**)calloc(this->num_specular_patches,sizeof(SpecularPatch*));
this->specular_index_array= (unsigned
int*)calloc(this->num_specular_patches*3,sizeof(unsigned int));

// allocate octree vertex storage
octree= new Octree(this->bb.min,this->bb.max,i);

// place all patch vertices into an octree
this->num_specular_patches= 0;
int k= 0;
for (obj= this->objects; obj; obj= obj->next)
for (face= 0; face< obj->num_faces; face++)
for (i= 0; i< obj->faces[face].num_patches; i++)
{
patch= obj->faces[face].patches[i];

// insert vertices into the octree
i0= octree->addVertex(patch->vertex[0],patch->normal,0,0,0,0);
i1= octree->addVertex(patch->vertex[1],patch->normal,0,0,0,0);
i2= octree->addVertex(patch->vertex[2],patch->normal,0,0,0,0);

// make a new specular patch
spatch= new SpecularPatch(patch,i0,i1,i2);
this->specular_patches[this->num_specular_patches++]= spatch;

// store indices
this->specular_index_array[k++]= i0;
this->specular_index_array[k++]= i1;
this->specular_index_array[k++]= i2;
}

// allocate specular vertex storage
this->num_specular_vertices= octree->num_vertices;
this->specular_radiances=
(SpecularRadiance*)calloc(this->num_specular_vertices,sizeof(SpecularRadiance)) ;
this->specular_vertices=
(SpecularVertex*)calloc(this->num_specular_vertices,sizeof(SpecularVertex));

// store data
for (i= 0; i< this->num_specular_vertices; i++)
{
// fetch octree vertex
ov= octree->vertices[i];

// make a new specular vertex
this->specular_vertices[i].pos= VectorSet(ov->x,ov->y,ov->z);

this->specular_vertices[i].col[0]= (unsigned char)(myrand.rand(255));
this->specular_vertices[i].col[1]= (unsigned char)(myrand.rand(255));
this->specular_vertices[i].col[2]= (unsigned char)(myrand.rand(255));
this->specular_vertices[i].col[3]= 255;
}

// delete the octree
delete octree;

for (j= 0; j< this->num_specular_patches; j++)
{
spatch= this->specular_patches[j];

// average patch radiance at vertices
for (i= 0; i< 3; i++)
{
this->specular_radiances[spatch->index[i]].L[0] += spatch->L[0];
this->specular_radiances[spatch->index[i]].L[1] += spatch->L[1];
this->specular_radiances[spatch->index[i]].L[2] += spatch->L[2];
this->specular_radiances[spatch->index[i]].count++;
}

// calculate surface normal
spatch->normal=
VectorNormalize(VectorCrossProduct(VectorSub(this->specular_vertices[spatch->index[1]].pos,this->specular_vertices[spatch->index[0]].pos),VectorSub(this->specular_vertices[spatch->index[2]].pos,this->specular_vertices[spatch->index[0]].pos)));
}

for (i= 0; i< this->num_specular_vertices; i++)
if (this->specular_radiances[i].count > 0)
{
this->specular_radiances[i].L[0] /=
(float)(M_PI*this->specular_radiances[i].count);
this->specular_radiances[i].L[1] /=
(float)(M_PI*this->specular_radiances[i].count);
this->specular_radiances[i].L[2] /=
(float)(M_PI*this->specular_radiances[i].count);
}
}

static void setMat(Vector right, Vector up, Vector view, Vector eye)
{
float mat[16];

mat[0]= right.x;
mat[1]= up.x;
mat[2]= view.x;
mat[3]= 0.0;

mat[4]= right.y;
mat[5]= up.y;
mat[6]= view.y;
mat[7]= 0.0;

mat[8]= right.z;
mat[9]= up.z;
mat[10]= view.z;
mat[11]= 0.0;

mat[12]= 0.0;
mat[13]= 0.0;
mat[14]= 0.0;
mat[15]= 1.0;

glLoadMatrixf(mat);
glTranslatef(-eye.x, -eye.y, -eye.z);
}

//#define __DUMP

void Frame::buildEnvMaps()
{
if (project->model_type!=MODEL_ILLUMINATION &&
project->model_type!=MODEL_RTT_ILL) return;

Material *mat;
int i,j;
float mvm[16];
Instance *inst;

// loop over each instance
for (j= 0, inst= project->instances; inst; j++, inst= inst->next)
if (inst->bti)
{
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
glDisable(GL_LIGHTING);
glClearColor(0,0,0,0);

// prepare projection
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluPerspective(90.0, 1.0, 0.01, 100.0);

glMatrixMode(GL_MODELVIEW);
glPushMatrix();

glPushAttrib(GL_VIEWPORT_BIT);
glViewport(0,0, _ENVMAP_SIZE,_ENVMAP_SIZE);

// loop over each specular material
for (i= 0; i< inst->prim->num_materials; i++)
if (inst->bti[i] > 0)
{
mat= inst->prim->materials[i];

glMatrixMode(GL_MODELVIEW);
glGetFloatv(GL_MODELVIEW_MATRIX, mvm);
Vector right= VectorSet(mvm[0], mvm[4], mvm[8]);
Vector up= VectorSet(mvm[1], mvm[5], mvm[9]);
Vector view= VectorSet(mvm[2], mvm[6], mvm[10]);
Vector eye= inst->material_centres[i];
glLoadIdentity();

// tone-map the scene to match this material
project->toneMapSpecular(this,mat);

// bind this texture map
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, inst->bti[i]);

#define MAX_BLUR 8

// what's the filter size?
int filter_size;
if (mat->shi == 256.0)
filter_size= 0;
else
filter_size= (int)(MAX_BLUR*(1.0-mat->shi/256.0));

if (filter_size > 0)
{
if (filter_size > MAX_BLUR)
filter_size= MAX_BLUR;

// build an NxN convolution filter
int sz= filter_size*filter_size;
float *filter= (float*)malloc(sz*sizeof(float));
for (int n= 0; n< sz; n++)
filter[n]= 1.0/(float)sz;

if (can_convolve)
{
glConvolutionFilter2D(GL_CONVOLUTION_2D,GL_LUMINAN CE,filter_size,filter_size,GL_LUMINANCE,GL_FLOAT,f ilter);
glConvolutionParameteri(GL_CONVOLUTION_2D,GL_CONVO LUTION_BORDER_MODE,GL_REPLICATE_BORDER_HP);
}
glEnable(GL_CONVOLUTION_2D);

free(filter);
}

// draw each face
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
setMat(right, VectorScalar(up,-1), VectorScalar(view,-1), eye);
project->drawSpecular(inst,mat);
glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z _ARB, 0, 0, 0, 0,
0, _ENVMAP_SIZE,_ENVMAP_SIZE);

#ifdef __DUMP
{
glDisable(GL_CONVOLUTION_2D);
unsigned char buf[4*_ENVMAP_SIZE*_ENVMAP_SIZE];
glReadPixels(0,0,_ENVMAP_SIZE,_ENVMAP_SIZE,GL_RGBA ,GL_UNSIGNED_BYTE,buf);
FILE *f= fopen("m1.ppm","w");
fprintf(f,"P6\n%d %d\n255\n",_ENVMAP_SIZE,_ENVMAP_SIZE);
for (int j= 0; j< _ENVMAP_SIZE*_ENVMAP_SIZE; j++)
{
unsigned char c= buf[4*j+0];
fwrite(&c,1,1,f);
c= buf[4*j+1];
fwrite(&c,1,1,f);
c= buf[4*j+2];
fwrite(&c,1,1,f);
}
fclose(f);
glEnable(GL_CONVOLUTION_2D);
}
#endif

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
setMat(VectorScalar(right,-1), VectorScalar(up,-1), view, eye);
project->drawSpecular(inst,mat);
glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z _ARB, 0, 0, 0, 0,
0, _ENVMAP_SIZE,_ENVMAP_SIZE);

#ifdef __DUMP
{
glDisable(GL_CONVOLUTION_2D);
unsigned char buf[4*_ENVMAP_SIZE*_ENVMAP_SIZE];
glReadPixels(0,0,_ENVMAP_SIZE,_ENVMAP_SIZE,GL_RGBA ,GL_UNSIGNED_BYTE,buf);
FILE *f= fopen("m2.ppm","w");
fprintf(f,"P6\n%d %d\n255\n",_ENVMAP_SIZE,_ENVMAP_SIZE);
for (int j= 0; j< _ENVMAP_SIZE*_ENVMAP_SIZE; j++)
{
unsigned char c= buf[4*j+0];
fwrite(&c,1,1,f);
c= buf[4*j+1];
fwrite(&c,1,1,f);
c= buf[4*j+2];
fwrite(&c,1,1,f);
}
fclose(f);
glEnable(GL_CONVOLUTION_2D);
}
#endif

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
setMat(view, VectorScalar(up,-1), right, eye);
project->drawSpecular(inst,mat);
glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X _ARB, 0, 0, 0, 0,
0, _ENVMAP_SIZE,_ENVMAP_SIZE);

#ifdef __DUMP
{
glDisable(GL_CONVOLUTION_2D);
unsigned char buf[4*_ENVMAP_SIZE*_ENVMAP_SIZE];
glReadPixels(0,0,_ENVMAP_SIZE,_ENVMAP_SIZE,GL_RGBA ,GL_UNSIGNED_BYTE,buf);
FILE *f= fopen("m3.ppm","w");
fprintf(f,"P6\n%d %d\n255\n",_ENVMAP_SIZE,_ENVMAP_SIZE);
for (int j= 0; j< _ENVMAP_SIZE*_ENVMAP_SIZE; j++)
{
unsigned char c= buf[4*j+0];
fwrite(&c,1,1,f);
c= buf[4*j+1];
fwrite(&c,1,1,f);
c= buf[4*j+2];
fwrite(&c,1,1,f);
}
fclose(f);
glEnable(GL_CONVOLUTION_2D);
}
#endif

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
setMat(VectorScalar(view,-1), VectorScalar(up,-1),
VectorScalar(right,-1), eye);
project->drawSpecular(inst,mat);
glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X _ARB, 0, 0, 0, 0,
0, _ENVMAP_SIZE,_ENVMAP_SIZE);

#ifdef __DUMP
{
glDisable(GL_CONVOLUTION_2D);
unsigned char buf[4*_ENVMAP_SIZE*_ENVMAP_SIZE];
glReadPixels(0,0,_ENVMAP_SIZE,_ENVMAP_SIZE,GL_RGBA ,GL_UNSIGNED_BYTE,buf);
FILE *f= fopen("m4.ppm","w");
fprintf(f,"P6\n%d %d\n255\n",_ENVMAP_SIZE,_ENVMAP_SIZE);
for (int j= 0; j< _ENVMAP_SIZE*_ENVMAP_SIZE; j++)
{
unsigned char c= buf[4*j+0];
fwrite(&c,1,1,f);
c= buf[4*j+1];
fwrite(&c,1,1,f);
c= buf[4*j+2];
fwrite(&c,1,1,f);
}
fclose(f);
glEnable(GL_CONVOLUTION_2D);
}
#endif

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
setMat(right, VectorScalar(view,-1), up, eye);
project->drawSpecular(inst,mat);
glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y _ARB, 0, 0, 0, 0,
0, _ENVMAP_SIZE,_ENVMAP_SIZE);

#ifdef __DUMP
{
glDisable(GL_CONVOLUTION_2D);
unsigned char buf[4*_ENVMAP_SIZE*_ENVMAP_SIZE];
glReadPixels(0,0,_ENVMAP_SIZE,_ENVMAP_SIZE,GL_RGBA ,GL_UNSIGNED_BYTE,buf);
FILE *f= fopen("m5.ppm","w");
fprintf(f,"P6\n%d %d\n255\n",_ENVMAP_SIZE,_ENVMAP_SIZE);
for (int j= 0; j< _ENVMAP_SIZE*_ENVMAP_SIZE; j++)
{
unsigned char c= buf[4*j+0];
fwrite(&c,1,1,f);
c= buf[4*j+1];
fwrite(&c,1,1,f);
c= buf[4*j+2];
fwrite(&c,1,1,f);
}
fclose(f);
glEnable(GL_CONVOLUTION_2D);
}
#endif

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
setMat(right, view, VectorScalar(up,-1), eye);
project->drawSpecular(inst,mat);
glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y _ARB, 0, 0, 0, 0,
0, _ENVMAP_SIZE,_ENVMAP_SIZE);

#ifdef __DUMP
{
glDisable(GL_CONVOLUTION_2D);
unsigned char buf[4*_ENVMAP_SIZE*_ENVMAP_SIZE];
glReadPixels(0,0,_ENVMAP_SIZE,_ENVMAP_SIZE,GL_RGBA ,GL_UNSIGNED_BYTE,buf);
FILE *f= fopen("m6.ppm","w");
fprintf(f,"P6\n%d %d\n255\n",_ENVMAP_SIZE,_ENVMAP_SIZE);
for (int j= 0; j< _ENVMAP_SIZE*_ENVMAP_SIZE; j++)
{
unsigned char c= buf[4*j+0];
fwrite(&c,1,1,f);
c= buf[4*j+1];
fwrite(&c,1,1,f);
c= buf[4*j+2];
fwrite(&c,1,1,f);
}
fclose(f);
glEnable(GL_CONVOLUTION_2D);
}
#endif

if (filter_size > 0)
glDisable(GL_CONVOLUTION_2D);
}

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

glPopAttrib();
}
}

void Project::toneMapSpecular(Frame *fr, Material *mat)
{
int i;
float L[3];
float k;

// find specular scaling factor
k= 1.0/M_PI;

for (i= 0; i< this->num_specular_vertices; i++)
{
// reflect radiance at the surface
L[0]= mat->spe[0]*k*this->specular_radiances[i].L[0];
L[1]= mat->spe[1]*k*this->specular_radiances[i].L[1];
L[2]= mat->spe[2]*k*this->specular_radiances[i].L[2];

// tone-map
fr->img->toneMap(fr->img->method,fr->img->exptime,L,this->specular_vertices[i].col,true);

// gamma correct
this->specular_vertices[i].col[0]=
this->gamma[this->specular_vertices[i].col[0]];
this->specular_vertices[i].col[1]=
this->gamma[this->specular_vertices[i].col[1]];
this->specular_vertices[i].col[2]=
this->gamma[this->specular_vertices[i].col[2]];
}
}

----------------------------------------------------------------
It seems very well in linux complie enivronment(Told by my friends). But in
Visual Studio, after build it, it appears:
--------------------------------
Compiling...
icarus_specular.cpp
D:\cvs\icarus\render\icarus_specular.cpp(8) : error C2146: syntax error :
missing ';' before identifier 'glConvolutionFilter2D'
D:\cvs\icarus\render\icarus_specular.cpp(8) : fatal error C1004: unexpected
end of file found
Error executing cl.exe.

icarus_specular.obj - 2 error(s), 0 warning(s)
-------------------------------------------------------

And after I add a header file "# include <GL/glew.h> "
the error appears as:
-------------------------------------
Compiling...
icarus_specular.cpp
D:\cvs\icarus\render\icarus_specular.cpp(8) : warning C4273:
'__glewConvolutionFilter2D' : inconsistent dll linkage. dllexport assumed.
D:\cvs\icarus\render\icarus_specular.cpp(9) : warning C4273:
'__glewConvolutionParameteri' : inconsistent dll linkage. dllexport
assumed.
D:\cvs\icarus\render\icarus_specular.cpp(236) : error C2065:
'GL_REPLICATE_BORDER_HP' : undeclared identifier
Error executing cl.exe.

icarus_specular.obj - 1 error(s), 2 warning(s)
-----------------------------------------------------

It is strange, becuase 'GL_REPLICATE_BORDER_HP' has been defined in file
"GL/glext.h". And I have also included this header file.
I don't know why. Is it becuase the opengl library I added was not proper?
Or because something else? Something similar also happens in the other file.
I hope someone can give me some advice.

Cheers
yanwan

Jul 22 '05 #1
1 3299
yanwan wrote:
I am now compling a project, but in one source file of this project, I met
this problem. It seems very strange.

Below is this source file:
----------------------------------------
#include "icarus_types.h"

#ifdef WIN32
#include <GL/glu.h>
#include <GL/glext.h>
Both headers are not standard C++ headers, you should consider the OpenGL
newsgroup if you want some clarity on those: comp.graphics.api.opengl.
extern PFNGLCONVOLUTIONFILTER2DPROC glConvolutionFilter2D;
extern PFNGLCONVOLUTIONPARAMETERIPROC glConvolutionParameteri;
#endif
[...]
----------------------------------------------------------------
It seems very well in linux complie enivronment(Told by my friends). But in
Visual Studio, after build it, it appears:
--------------------------------
Compiling...
icarus_specular.cpp
D:\cvs\icarus\render\icarus_specular.cpp(8) : error C2146: syntax error :
missing ';' before identifier 'glConvolutionFilter2D'
It seems that PFNGLCONVOLUTIONFILTER2DPROC is not defined here.
D:\cvs\icarus\render\icarus_specular.cpp(8) : fatal error C1004: unexpected
end of file found
Error executing cl.exe.

icarus_specular.obj - 2 error(s), 0 warning(s)
-------------------------------------------------------

And after I add a header file "# include <GL/glew.h> "
Again, just a note: C++ has no idea what that file is for or what it
contains.
the error appears as:
-------------------------------------
Compiling...
icarus_specular.cpp
D:\cvs\icarus\render\icarus_specular.cpp(8) : warning C4273:
'__glewConvolutionFilter2D' : inconsistent dll linkage. dllexport assumed.
D:\cvs\icarus\render\icarus_specular.cpp(9) : warning C4273:
'__glewConvolutionParameteri' : inconsistent dll linkage. dllexport
assumed.
D:\cvs\icarus\render\icarus_specular.cpp(236) : error C2065:
'GL_REPLICATE_BORDER_HP' : undeclared identifier
So, what's unclear? Undeclared identifier. You need to declare it or to
include the header that declares it.
Error executing cl.exe.

icarus_specular.obj - 1 error(s), 2 warning(s)
-----------------------------------------------------

It is strange, becuase 'GL_REPLICATE_BORDER_HP' has been defined in file
"GL/glext.h". And I have also included this header file.
If it's a macro it could be simple 'undef'ed in the other header you added
after that (<GL/glew.h>).
I don't know why. Is it becuase the opengl library I added was not proper?
C++ has no answer to that.
Or because something else? Something similar also happens in the other file.
I hope someone can give me some advice.


Try the OpenGL newsgroup I mentioned. If they don't know, try MS Windows
programming newsgroup (there is a slew of those).

V
Jul 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Tom Lee | last post by:
Hi, I'm new to .NET 2003 compiler. When I tried to compile my program using DEBUG mode, I got the following errors in the C:\Program...
3
by: Andrew Luke | last post by:
Hi all you C++ guru's! I'm 'very, very' new to C++ and I'm having a little trouble configuring my VS environment I think - when I try and compile...
4
by: yanwan | last post by:
Hello I am now compling a project, but in one source file of this project, I met this problem. It seems very strange. Below is this source file:...
1
by: Minh | last post by:
I've just installed VS.NET 2003 on my Athlon XP 1800+. However I couldn't get any project with STL includes to compile even if I create a new empty...
2
by: Qiao Yun | last post by:
I used vc++.net (visual studio .net ) to open a project which can work well in vc++6.0. I succeeded in compiling the project in vc++.net in...
7
by: p | last post by:
WE had a Crystal 8 WebApp using vs 2002 which we upgraded to VS2003. I also have Crystal 9 pro on my development machine. The web app runs fine on...
0
by: Herman Jones | last post by:
I'm getting the following error when I build a Class Library project: Embedding manifest... Project : error PRJ0002 : Error result 1 returned from...
9
by: Prasad | last post by:
HI, I am a beginner in VC++.. I am trying to write a Win32 console application in visual studio.. I am using following header files.. #include...
2
by: yalbizu | last post by:
#include <iostream> #include <string> #include <fstream> #include <iomanip> using namespace std; const int NO_OF_STUDENTS=20; struct...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.