version 1.1, 2009/02/08 04:56:59 |
version 1.4, 2009/03/17 17:04:14 |
Line 8 License: This software is distributed under the 2-clua |
|
Line 8 License: This software is distributed under the 2-clua |
|
#ifdef MAC_OS_X |
#ifdef MAC_OS_X |
#include <GLUT/glut.h> |
#include <GLUT/glut.h> |
#else |
#else |
|
#if defined (_MSC_VER) |
|
#include <windows.h> |
|
#endif |
#include<GL/gl.h> |
#include<GL/gl.h> |
#include<GL/glu.h> |
#include<GL/glu.h> |
#include<GL/glut.h> |
#include<GL/glut.h> |
Line 152 GLboolean lightSwitch = GL_FALSE; |
|
Line 155 GLboolean lightSwitch = GL_FALSE; |
|
GLboolean textureSwitch = GL_FALSE; |
GLboolean textureSwitch = GL_FALSE; |
GLboolean blendSwitch = GL_FALSE; |
GLboolean blendSwitch = GL_FALSE; |
|
|
/* for bitfont */ |
|
int str_position = 500; |
|
|
|
void makeTexture(void) |
void makeTexture(void) |
{ |
{ |
FILE *fp; |
FILE *fp; |
int x, z; |
int x, z; |
|
char *oxhome; |
|
char fname[1024]; |
|
|
/* texture file open (file name is "inobuta.tga")*/ |
/* texture file open (file name is "inobuta.tga")*/ |
if((fp=fopen("inobuta.tga", "rb"))==NULL){ |
oxhome = getenv("OpenXM_HOME"); |
fprintf(stderr, "texture file cannot be open\n"); |
if (oxhome != NULL) { |
return; |
sprintf(fname,"%s/share/oxmgraph/inobuta.tga",oxhome); |
|
}else{ |
|
sprintf(fname,"/usr/local/share/oxmgraph/inobuta.tgz"); |
} |
} |
|
if((fp=fopen(fname, "rb"))==NULL){ |
|
if ((fp = fopen("inobuta.tgz","rb")) == NULL) { |
|
fprintf(stderr, "texture file cannot be open\n"); |
|
return; |
|
} |
|
} |
fseek(fp, 18, SEEK_SET); |
fseek(fp, 18, SEEK_SET); |
for (x=0; x<TEX_HEIGHT; x++) { |
for (x=0; x<TEX_HEIGHT; x++) { |
for (z=0; z<TEX_WIDTH; z++) { |
for (z=0; z<TEX_WIDTH; z++) { |
Line 248 static void graph(void) |
|
Line 258 static void graph(void) |
|
glEnd(); |
glEnd(); |
|
|
if ( exNet ) { |
if ( exNet ) { |
glColor3f(0.0,0.0,0.0); |
glColor3f(1.0,1.0,1.0); |
|
if(!blendSwitch) { |
|
glDisable(GL_LIGHTING); |
|
glDisable(GL_TEXTURE_2D); |
|
glColor3f(0.0,0.0,0.0); |
|
} |
glBegin(GL_LINE_LOOP); |
glBegin(GL_LINE_LOOP); |
glVertex3f(x, y, polynomial(x,y)); |
glVertex3f(x, y, polynomial(x,y)); |
glVertex3f(x+DIV, y, polynomial(x+DIV, y)); |
glVertex3f(x+DIV, y, polynomial(x+DIV, y)); |
Line 259 static void graph(void) |
|
Line 274 static void graph(void) |
|
glVertex3f(x, y, polynomial(x, y)); |
glVertex3f(x, y, polynomial(x, y)); |
glVertex3f(x+DIV, y+DIV, polynomial(x+DIV, y+DIV)); |
glVertex3f(x+DIV, y+DIV, polynomial(x+DIV, y+DIV)); |
glEnd(); |
glEnd(); |
|
if(lightSwitch) |
|
glEnable(GL_LIGHTING); |
|
if(textureSwitch) |
|
glEnable(GL_TEXTURE_2D); |
} |
} |
} |
} |
} |
} |
Line 314 void triangle(void) |
|
Line 333 void triangle(void) |
|
glEnd(); |
glEnd(); |
|
|
if( exNet ) { |
if( exNet ) { |
glColor3f(0.0,0.0,0.0); |
glColor3f(1.0,1.0,1.0); |
glBegin(GL_LINE_LOOP); |
if(!blendSwitch) { |
glVertex3f(triangles[j][0],triangles[j][1],triangles[j][2]); |
glDisable(GL_LIGHTING); |
glVertex3f(triangles[j][3],triangles[j][4],triangles[j][5]); |
glDisable(GL_TEXTURE_2D); |
glVertex3f(triangles[j][6],triangles[j][7],triangles[j][8]); |
glColor3f(0.0,0.0,0.0); |
glEnd(); |
} |
|
glBegin(GL_LINE_LOOP); |
|
glVertex3f(triangles[j][0],triangles[j][1],triangles[j][2]); |
|
glVertex3f(triangles[j][3],triangles[j][4],triangles[j][5]); |
|
glVertex3f(triangles[j][6],triangles[j][7],triangles[j][8]); |
|
glEnd(); |
|
if(lightSwitch) |
|
glEnable(GL_LIGHTING); |
|
if(textureSwitch) |
|
glEnable(GL_TEXTURE_2D); |
} |
} |
} |
} |
} |
} |
Line 390 static void box(void) |
|
Line 418 static void box(void) |
|
static void axis(void) |
static void axis(void) |
{ |
{ |
double i; |
double i; |
/* glLineWidth(2.0); */ |
|
glBegin(GL_LINES); |
glBegin(GL_LINES); |
glColor3f(1.0, 0.0, 0.0); |
glColor3f(1.0, 0.0, 0.0); |
glVertex3f(-size, 0, 0); glVertex3f(size, 0, 0); |
glVertex3f(-size, 0, 0); glVertex3f(size, 0, 0); |
Line 415 static void axis(void) |
|
Line 442 static void axis(void) |
|
glRasterPos3i(0,0,size+1); |
glRasterPos3i(0,0,size+1); |
glBitmap (10, 12, 0.0, 0.0, 11.0, 0.0, raster_Z); |
glBitmap (10, 12, 0.0, 0.0, 11.0, 0.0, raster_Z); |
|
|
/* glColor3f(1.0, 1.0, 1.0); |
|
glRasterPos3i(5,1,0); |
|
glBitmap (10, 12, 0.0, 0.0, 11.0, 0.0, raster_5);*/ |
|
|
|
glColor3f(1.0, 1.0, 1.0); |
glColor3f(1.0, 1.0, 1.0); |
glRasterPos3i(5,1,0); |
glRasterPos3i(5,1,0); |
glBitmap (10, 22, 0.0, 0.0, 11.0, 0.0, raster_$); |
glBitmap (10, 22, 0.0, 0.0, 11.0, 0.0, raster_$); |
Line 474 static void recalcGraph(void) |
|
Line 497 static void recalcGraph(void) |
|
triangle(); |
triangle(); |
glEndList(); |
glEndList(); |
|
|
/* Axis and Box */ |
|
/* theWhole = glGenLists(1); |
glCallList(theAxis); |
glNewList(theWhole, GL_COMPILE); */ |
glCallList(theBox); |
glCallList(theAxis); |
|
glCallList(theBox); |
|
/* glEndList(); */ |
|
newGraph = 0; |
newGraph = 0; |
} |
} |
|
|
Line 491 static void init(void) |
|
Line 512 static void init(void) |
|
glClearColor(0.2, 0.2, 0.2, 0.0); |
glClearColor(0.2, 0.2, 0.2, 0.0); |
glShadeModel(GL_FLAT); |
glShadeModel(GL_FLAT); |
glPixelStorei (GL_UNPACK_ALIGNMENT, 1); |
glPixelStorei (GL_UNPACK_ALIGNMENT, 1); |
/* |
/* |
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, model_ambient); |
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, model_ambient); |
*/ |
*/ |
glMatrixMode(GL_PROJECTION); |
glMatrixMode(GL_PROJECTION); |
Line 570 void display(void) |
|
Line 591 void display(void) |
|
|
|
void reshape(int w, int h) |
void reshape(int w, int h) |
{ |
{ |
str_position = h; |
|
glViewport(0,0, (GLsizei)w, (GLsizei)h); |
glViewport(0,0, (GLsizei)w, (GLsizei)h); |
glMatrixMode(GL_PROJECTION); |
glMatrixMode(GL_PROJECTION); |
glLoadIdentity(); |
glLoadIdentity(); |
Line 695 void controlExpression(int value) |
|
Line 715 void controlExpression(int value) |
|
glDisable(GL_LIGHTING); |
glDisable(GL_LIGHTING); |
glDisable(GL_TEXTURE_2D); |
glDisable(GL_TEXTURE_2D); |
newModel = 1; |
newModel = 1; |
|
newGraph = 1; |
glutPostRedisplay(); |
glutPostRedisplay(); |
break; |
break; |
case 2: |
case 2: |
Line 703 void controlExpression(int value) |
|
Line 724 void controlExpression(int value) |
|
glEnable(GL_LIGHTING); |
glEnable(GL_LIGHTING); |
glDisable(GL_TEXTURE_2D); |
glDisable(GL_TEXTURE_2D); |
newModel = 1; |
newModel = 1; |
|
newGraph = 1; |
glutPostRedisplay(); |
glutPostRedisplay(); |
break; |
break; |
case 3: |
case 3: |
Line 711 void controlExpression(int value) |
|
Line 733 void controlExpression(int value) |
|
glEnable(GL_TEXTURE_2D); |
glEnable(GL_TEXTURE_2D); |
glDisable(GL_LIGHTING); |
glDisable(GL_LIGHTING); |
newModel = 1; |
newModel = 1; |
|
newGraph = 1; |
glutPostRedisplay(); |
glutPostRedisplay(); |
break; |
break; |
case 4: |
case 4: |
Line 723 void controlExpression(int value) |
|
Line 746 void controlExpression(int value) |
|
glDisable(GL_BLEND); |
glDisable(GL_BLEND); |
glEnable(GL_DEPTH_TEST); |
glEnable(GL_DEPTH_TEST); |
} |
} |
|
newGraph = 1; |
break; |
break; |
case 5: |
case 5: |
exAxis = !exAxis; |
exAxis = !exAxis; |
Line 825 int main(int argc, char** argv) |
|
Line 849 int main(int argc, char** argv) |
|
triSwitch = 0; |
triSwitch = 0; |
exTex = 1; |
exTex = 1; |
exSample = 0; |
exSample = 0; |
|
printf("$=5.0, @=5.0\n"); |
} |
} |
else if (argc != 2) { |
else if (argc != 2) { |
fprintf(stderr,"Usage: graph filename\n"); |
fprintf(stderr,"Usage: graph filename\n"); |
Line 964 int main(int argc, char** argv) |
|
Line 989 int main(int argc, char** argv) |
|
|
|
glEnable(GL_LIGHT0); |
glEnable(GL_LIGHT0); |
glEnable(GL_LIGHT1); |
glEnable(GL_LIGHT1); |
/* |
|
glEnable(GL_STENCIL_TEST); |
|
glEnable(GL_AUTO_NORMAL); |
|
*/ |
|
/* |
|
glEnable(GL_LIGHT2); |
|
glEnable(GL_LIGHT3); |
|
glEnable(GL_LIGHT4); |
|
glEnable(GL_LIGHT5); |
|
*/ |
|
glutMainLoop(); |
glutMainLoop(); |
return 0; |
return 0; |
} |
} |