PDA

View Full Version : underwater application help



holyevil
04-23-2010, 12:36 PM
guys i'm combining two programs-one with a simple landscape and the other with underwater sharks but it is throwing me an error........as i'm complete newbie to this .....pls help out.......i have to submit the project tomorrow...pls help asap

program-

/* MAIN.C - main file */

#include "main.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <GL/glut.h>
#include "atlantis.h"

fishRec sharks[NUM_SHARKS];


GLboolean moving;

static float N02[3] = {0.000077 ,-0.020611 ,0.999788};
static float N03[3] = {0.961425 ,0.258729 ,-0.093390};
static float N04[3] = {0.510811 ,-0.769633 ,-0.383063};
static float N05[3] = {0.400123 ,0.855734 ,-0.328055};
static float N06[3] = {-0.770715 ,0.610204 ,-0.183440};
static float N07[3] = {-0.915597 ,-0.373345 ,-0.149316};
static float N08[3] = {-0.972788 ,0.208921 ,-0.100179};
static float N09[3] = {-0.939713 ,-0.312268 ,-0.139383};
static float N10[3] = {-0.624138 ,-0.741047 ,-0.247589};
static float N11[3] = {0.591434 ,-0.768401 ,-0.244471};
static float N12[3] = {0.935152 ,-0.328495 ,-0.132598};
static float N13[3] = {0.997102 ,0.074243 ,-0.016593};
static float N14[3] = {0.969995 ,0.241712 ,-0.026186};
static float N15[3] = {0.844539 ,0.502628 ,-0.184714};
static float N16[3] = {-0.906608 ,0.386308 ,-0.169787};
static float N17[3] = {-0.970016 ,0.241698 ,-0.025516};
static float N18[3] = {-0.998652 ,0.050493 ,-0.012045};
static float N19[3] = {-0.942685 ,-0.333051 ,-0.020556};
static float N20[3] = {-0.660944 ,-0.750276 ,0.015480};
static float N21[3] = {0.503549 ,-0.862908 ,-0.042749};
static float N22[3] = {0.953202 ,-0.302092 ,-0.012089};
static float N23[3] = {0.998738 ,0.023574 ,0.044344};
static float N24[3] = {0.979297 ,0.193272 ,0.060202};
static float N25[3] = {0.798300 ,0.464885 ,0.382883};
static float N26[3] = {-0.756590 ,0.452403 ,0.472126};
static float N27[3] = {-0.953855 ,0.293003 ,0.065651};
static float N28[3] = {-0.998033 ,0.040292 ,0.048028};
static float N29[3] = {-0.977079 ,-0.204288 ,0.059858};
static float N30[3] = {-0.729117 ,-0.675304 ,0.111140};
static float N31[3] = {0.598361 ,-0.792753 ,0.116221};
static float N32[3] = {0.965192 ,-0.252991 ,0.066332};
static float N33[3] = {0.998201 ,-0.002790 ,0.059892};
static float N34[3] = {0.978657 ,0.193135 ,0.070207};
static float N35[3] = {0.718815 ,0.680392 ,0.142733};
static float N36[3] = {-0.383096 ,0.906212 ,0.178936};
static float N37[3] = {-0.952831 ,0.292590 ,0.080647};
static float N38[3] = {-0.997680 ,0.032417 ,0.059861};
static float N39[3] = {-0.982629 ,-0.169881 ,0.074700};
static float N40[3] = {-0.695424 ,-0.703466 ,0.146700};
static float N41[3] = {0.359323 ,-0.915531 ,0.180805};
static float N42[3] = {0.943356 ,-0.319387 ,0.089842};
static float N43[3] = {0.998272 ,-0.032435 ,0.048993};
static float N44[3] = {0.978997 ,0.193205 ,0.065084};
static float N45[3] = {0.872144 ,0.470094 ,-0.135565};
static float N46[3] = {-0.664282 ,0.737945 ,-0.119027};
static float N47[3] = {-0.954508 ,0.288570 ,0.075107};
static float N48[3] = {-0.998273 ,0.032406 ,0.048993};
static float N49[3] = {-0.979908 ,-0.193579 ,0.048038};
static float N50[3] = {-0.858736 ,-0.507202 ,-0.072938};
static float N51[3] = {0.643545 ,-0.763887 ,-0.048237};
static float N52[3] = {0.955580 ,-0.288954 ,0.058068};
static float N58[3] = {0.000050 ,0.793007 ,-0.609213};
static float N59[3] = {0.913510 ,0.235418 ,-0.331779};
static float N60[3] = {-0.807970 ,0.495000 ,-0.319625};
static float N61[3] = {0.000000 ,0.784687 ,-0.619892};
static float N62[3] = {0.000000 ,-1.000000 ,0.000000};
static float N63[3] = {0.000000 ,1.000000 ,0.000000};
static float N64[3] = {0.000000 ,1.000000 ,0.000000};
static float N65[3] = {0.000000 ,1.000000 ,0.000000};
static float N66[3] = {-0.055784 ,0.257059 ,0.964784};
static float N69[3] = {-0.000505 ,-0.929775 ,-0.368127};
static float N70[3] = {0.000000 ,1.000000 ,0.000000};
static float P02[3] = {0.00, -36.59, 5687.72};
static float P03[3] = {90.00, 114.73, 724.38};
static float P04[3] = {58.24, -146.84, 262.35};
static float P05[3] = {27.81, 231.52, 510.43};
static float P06[3] = {-27.81, 230.43, 509.76};
static float P07[3] = {-46.09, -146.83, 265.84};
static float P08[3] = {-90.00, 103.84, 718.53};
static float P09[3] = {-131.10, -165.92, 834.85};
static float P10[3] = {-27.81, -285.31, 500.00};
static float P11[3] = {27.81, -285.32, 500.00};
static float P12[3] = {147.96, -170.89, 845.50};
static float P13[3] = {180.00, 0.00, 2000.00};
static float P14[3] = {145.62, 352.67, 2000.00};
static float P15[3] = {55.62, 570.63, 2000.00};
static float P16[3] = {-55.62, 570.64, 2000.00};
static float P17[3] = {-145.62, 352.68, 2000.00};
static float P18[3] = {-180.00, 0.01, 2000.00};
static float P19[3] = {-178.20, -352.66, 2001.61};
static float P20[3] = {-55.63, -570.63, 2000.00};
static float P21[3] = {55.62, -570.64, 2000.00};
static float P22[3] = {179.91, -352.69, 1998.39};
static float P23[3] = {150.00, 0.00, 3000.00};
static float P24[3] = {121.35, 293.89, 3000.00};
static float P25[3] = {46.35, 502.93, 2883.09};
static float P26[3] = {-46.35, 497.45, 2877.24};
static float P27[3] = {-121.35, 293.90, 3000.00};
static float P28[3] = {-150.00, 0.00, 3000.00};
static float P29[3] = {-152.21, -304.84, 2858.68};
static float P30[3] = {-46.36, -475.52, 3000.00};
static float P31[3] = {46.35, -475.53, 3000.00};
static float P32[3] = {155.64, -304.87, 2863.50};
static float P33[3] = {90.00, 0.00, 4000.00};
static float P34[3] = {72.81, 176.33, 4000.00};
static float P35[3] = {27.81, 285.32, 4000.00};
static float P36[3] = {-27.81, 285.32, 4000.00};
static float P37[3] = {-72.81, 176.34, 4000.00};
static float P38[3] = {-90.00, 0.00, 4000.00};
static float P39[3] = {-72.81, -176.33, 4000.00};
static float P40[3] = {-27.81, -285.31, 4000.00};
static float P41[3] = {27.81, -285.32, 4000.00};
static float P42[3] = {72.81, -176.34, 4000.00};
static float P43[3] = {30.00, 0.00, 5000.00};
static float P44[3] = {24.27, 58.78, 5000.00};
static float P45[3] = {9.27, 95.11, 5000.00};
static float P46[3] = {-9.27, 95.11, 5000.00};
static float P47[3] = {-24.27, 58.78, 5000.00};
static float P48[3] = {-30.00, 0.00, 5000.00};
static float P49[3] = {-24.27, -58.78, 5000.00};
static float P50[3] = {-9.27, -95.10, 5000.00};
static float P51[3] = {9.27, -95.11, 5000.00};
static float P52[3] = {24.27, -58.78, 5000.00};
static float P58[3] = {0.00, 1212.72, 2703.08};
static float P59[3] = {50.36, 0.00, 108.14};
static float P60[3] = {-22.18, 0.00, 108.14};
static float P61[3] = {0.00, 1181.61, 6344.65};
static float P62[3] = {516.45, -887.08, 2535.45};
static float P63[3] = {-545.69, -879.31, 2555.63};
static float P64[3] = {618.89, -1005.64, 2988.32};
static float P65[3] = {-635.37, -1014.79, 2938.68};
static float P66[3] = {0.00, 1374.43, 3064.18};
static float P69[3] = {0.00, -418.25, 5765.04};
static float P70[3] = {0.00, 1266.91, 6629.60};
static float P71[3] = {-139.12, -124.96, 997.98};
static float P72[3] = {-139.24, -110.18, 1020.68};
static float P73[3] = {-137.33, -94.52, 1022.63};
static float P74[3] = {-137.03, -79.91, 996.89};
static float P75[3] = {-135.21, -91.48, 969.14};
static float P76[3] = {-135.39, -110.87, 968.76};
static float P77[3] = {150.23, -78.44, 995.53};
static float P78[3] = {152.79, -92.76, 1018.46};
static float P79[3] = {154.19, -110.20, 1020.55};
static float P80[3] = {151.33, -124.15, 993.77};
static float P81[3] = {150.49, -111.19, 969.86};
static float P82[3] = {150.79, -92.41, 969.70};
static float iP02[3] = {0.00, -36.59, 5687.72};
static float iP04[3] = {58.24, -146.84, 262.35};
static float iP07[3] = {-46.09, -146.83, 265.84};
static float iP10[3] = {-27.81, -285.31, 500.00};
static float iP11[3] = {27.81, -285.32, 500.00};
static float iP23[3] = {150.00, 0.00, 3000.00};
static float iP24[3] = {121.35, 293.89, 3000.00};
static float iP25[3] = {46.35, 502.93, 2883.09};
static float iP26[3] = {-46.35, 497.45, 2877.24};
static float iP27[3] = {-121.35, 293.90, 3000.00};
static float iP28[3] = {-150.00, 0.00, 3000.00};
static float iP29[3] = {-121.35, -304.84, 2853.86};
static float iP30[3] = {-46.36, -475.52, 3000.00};
static float iP31[3] = {46.35, -475.53, 3000.00};
static float iP32[3] = {121.35, -304.87, 2853.86};
static float iP33[3] = {90.00, 0.00, 4000.00};
static float iP34[3] = {72.81, 176.33, 4000.00};
static float iP35[3] = {27.81, 285.32, 4000.00};
static float iP36[3] = {-27.81, 285.32, 4000.00};
static float iP37[3] = {-72.81, 176.34, 4000.00};
static float iP38[3] = {-90.00, 0.00, 4000.00};
static float iP39[3] = {-72.81, -176.33, 4000.00};
static float iP40[3] = {-27.81, -285.31, 4000.00};
static float iP41[3] = {27.81, -285.32, 4000.00};
static float iP42[3] = {72.81, -176.34, 4000.00};
static float iP43[3] = {30.00, 0.00, 5000.00};
static float iP44[3] = {24.27, 58.78, 5000.00};
static float iP45[3] = {9.27, 95.11, 5000.00};
static float iP46[3] = {-9.27, 95.11, 5000.00};
static float iP47[3] = {-24.27, 58.78, 5000.00};
static float iP48[3] = {-30.00, 0.00, 5000.00};
static float iP49[3] = {-24.27, -58.78, 5000.00};
static float iP50[3] = {-9.27, -95.10, 5000.00};
static float iP51[3] = {9.27, -95.11, 5000.00};
static float iP52[3] = {24.27, -58.78, 5000.00};
static float iP61[3] = {0.00, 1181.61, 6344.65};
static float iP69[3] = {0.00, -418.25, 5765.04};
static float iP70[3] = {0.00, 1266.91, 6629.60};

GLint windW, windH,i;

struct LandScapeTerrain *LandScape; /* HEIGHT data */
struct ThePlayer CurrentPlayer; /* "PLAYER" */
GLuint texobjs[NUM_TEXTURES]; /* textures */
GLuint texobjse[NUM_TEXTURES];
AUX_RGBImageRec *texture_grass; /* "grass" texture itself */
AUX_RGBImageRec *texture_water;
GLfloat x_pos_frac, y_pos_frac; /* fractional parts of move */
GLint z=0;
void
Fish001(void)
{
glBegin(GL_POLYGON);
glNormal3fv(N05);
glVertex3fv(P05);
glNormal3fv(N59);
glVertex3fv(P59);
glNormal3fv(N60);
glVertex3fv(P60);
glNormal3fv(N06);
glVertex3fv(P06);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N15);
glVertex3fv(P15);
glNormal3fv(N05);
glVertex3fv(P05);
glNormal3fv(N06);
glVertex3fv(P06);
glNormal3fv(N16);
glVertex3fv(P16);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N06);
glVertex3fv(P06);
glNormal3fv(N60);
glVertex3fv(P60);
glNormal3fv(N08);
glVertex3fv(P08);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N16);
glVertex3fv(P16);
glNormal3fv(N06);
glVertex3fv(P06);
glNormal3fv(N08);
glVertex3fv(P08);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N16);
glVertex3fv(P16);
glNormal3fv(N08);
glVertex3fv(P08);
glNormal3fv(N17);
glVertex3fv(P17);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N17);
glVertex3fv(P17);
glNormal3fv(N08);
glVertex3fv(P08);
glNormal3fv(N18);
glVertex3fv(P18);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N08);
glVertex3fv(P08);
glNormal3fv(N09);
glVertex3fv(P09);
glNormal3fv(N18);
glVertex3fv(P18);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N08);
glVertex3fv(P08);
glNormal3fv(N60);
glVertex3fv(P60);
glNormal3fv(N09);
glVertex3fv(P09);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N07);
glVertex3fv(P07);
glNormal3fv(N10);
glVertex3fv(P10);
glNormal3fv(N09);
glVertex3fv(P09);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N09);
glVertex3fv(P09);
glNormal3fv(N19);
glVertex3fv(P19);
glNormal3fv(N18);
glVertex3fv(P18);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N09);
glVertex3fv(P09);
glNormal3fv(N10);
glVertex3fv(P10);
glNormal3fv(N19);
glVertex3fv(P19);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N10);
glVertex3fv(P10);
glNormal3fv(N20);
glVertex3fv(P20);
glNormal3fv(N19);
glVertex3fv(P19);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N10);
glVertex3fv(P10);
glNormal3fv(N11);
glVertex3fv(P11);
glNormal3fv(N21);
glVertex3fv(P21);
glNormal3fv(N20);
glVertex3fv(P20);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N04);
glVertex3fv(P04);
glNormal3fv(N11);
glVertex3fv(P11);
glNormal3fv(N10);
glVertex3fv(P10);
glNormal3fv(N07);
glVertex3fv(P07);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N04);
glVertex3fv(P04);
glNormal3fv(N12);
glVertex3fv(P12);
glNormal3fv(N11);
glVertex3fv(P11);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N12);
glVertex3fv(P12);
glNormal3fv(N22);
glVertex3fv(P22);
glNormal3fv(N11);
glVertex3fv(P11);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N11);
glVertex3fv(P11);
glNormal3fv(N22);
glVertex3fv(P22);
glNormal3fv(N21);
glVertex3fv(P21);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N59);
glVertex3fv(P59);
glNormal3fv(N05);
glVertex3fv(P05);
glNormal3fv(N15);
glVertex3fv(P15);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N15);
glVertex3fv(P15);
glNormal3fv(N14);
glVertex3fv(P14);
glNormal3fv(N03);
glVertex3fv(P03);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N15);
glVertex3fv(P15);
glNormal3fv(N03);
glVertex3fv(P03);
glNormal3fv(N59);
glVertex3fv(P59);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N14);
glVertex3fv(P14);
glNormal3fv(N13);
glVertex3fv(P13);
glNormal3fv(N03);
glVertex3fv(P03);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N03);
glVertex3fv(P03);
glNormal3fv(N12);
glVertex3fv(P12);
glNormal3fv(N59);
glVertex3fv(P59);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N13);
glVertex3fv(P13);
glNormal3fv(N12);
glVertex3fv(P12);
glNormal3fv(N03);
glVertex3fv(P03);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N13);
glVertex3fv(P13);
glNormal3fv(N22);
glVertex3fv(P22);
glNormal3fv(N12);
glVertex3fv(P12);
glEnd();
glBegin(GL_POLYGON);
glVertex3fv(P71);
glVertex3fv(P72);
glVertex3fv(P73);
glVertex3fv(P74);
glVertex3fv(P75);
glVertex3fv(P76);
glEnd();
glBegin(GL_POLYGON);
glVertex3fv(P77);
glVertex3fv(P78);
glVertex3fv(P79);
glVertex3fv(P80);
glVertex3fv(P81);
glVertex3fv(P82);
glEnd();
}

void
Fish002(void)
{
glBegin(GL_POLYGON);
glNormal3fv(N13);
glVertex3fv(P13);
glNormal3fv(N14);
glVertex3fv(P14);
glNormal3fv(N24);
glVertex3fv(P24);
glNormal3fv(N23);
glVertex3fv(P23);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N14);
glVertex3fv(P14);
glNormal3fv(N15);
glVertex3fv(P15);
glNormal3fv(N25);
glVertex3fv(P25);
glNormal3fv(N24);
glVertex3fv(P24);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N16);
glVertex3fv(P16);
glNormal3fv(N17);
glVertex3fv(P17);
glNormal3fv(N27);
glVertex3fv(P27);
glNormal3fv(N26);
glVertex3fv(P26);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N17);
glVertex3fv(P17);
glNormal3fv(N18);
glVertex3fv(P18);
glNormal3fv(N28);
glVertex3fv(P28);
glNormal3fv(N27);
glVertex3fv(P27);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N20);
glVertex3fv(P20);
glNormal3fv(N21);
glVertex3fv(P21);
glNormal3fv(N31);
glVertex3fv(P31);
glNormal3fv(N30);
glVertex3fv(P30);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N13);
glVertex3fv(P13);
glNormal3fv(N23);
glVertex3fv(P23);
glNormal3fv(N22);
glVertex3fv(P22);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N22);
glVertex3fv(P22);
glNormal3fv(N23);
glVertex3fv(P23);
glNormal3fv(N32);
glVertex3fv(P32);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N22);
glVertex3fv(P22);
glNormal3fv(N32);
glVertex3fv(P32);
glNormal3fv(N31);
glVertex3fv(P31);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N22);
glVertex3fv(P22);
glNormal3fv(N31);
glVertex3fv(P31);
glNormal3fv(N21);
glVertex3fv(P21);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N18);
glVertex3fv(P18);
glNormal3fv(N19);
glVertex3fv(P19);
glNormal3fv(N29);
glVertex3fv(P29);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N18);
glVertex3fv(P18);
glNormal3fv(N29);
glVertex3fv(P29);
glNormal3fv(N28);
glVertex3fv(P28);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N19);
glVertex3fv(P19);
glNormal3fv(N20);
glVertex3fv(P20);
glNormal3fv(N30);
glVertex3fv(P30);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N19);
glVertex3fv(P19);
glNormal3fv(N30);
glVertex3fv(P30);
glNormal3fv(N29);
glVertex3fv(P29);
glEnd();
}

void
Fish003(void)
{
glColor3f(1.0,0.0,0.0);
glBegin(GL_POLYGON);
glNormal3fv(N32);
glVertex3fv(P32);
glNormal3fv(N23);
glVertex3fv(P23);
glNormal3fv(N33);
glVertex3fv(P33);
glNormal3fv(N42);
glVertex3fv(P42);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N31);
glVertex3fv(P31);
glNormal3fv(N32);
glVertex3fv(P32);
glNormal3fv(N42);
glVertex3fv(P42);
glNormal3fv(N41);
glVertex3fv(P41);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N23);
glVertex3fv(P23);
glNormal3fv(N24);
glVertex3fv(P24);
glNormal3fv(N34);
glVertex3fv(P34);
glNormal3fv(N33);
glVertex3fv(P33);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N24);
glVertex3fv(P24);
glNormal3fv(N25);
glVertex3fv(P25);
glNormal3fv(N35);
glVertex3fv(P35);
glNormal3fv(N34);
glVertex3fv(P34);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N30);
glVertex3fv(P30);
glNormal3fv(N31);
glVertex3fv(P31);
glNormal3fv(N41);
glVertex3fv(P41);
glNormal3fv(N40);
glVertex3fv(P40);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N25);
glVertex3fv(P25);
glNormal3fv(N26);
glVertex3fv(P26);
glNormal3fv(N36);
glVertex3fv(P36);
glNormal3fv(N35);
glVertex3fv(P35);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N26);
glVertex3fv(P26);
glNormal3fv(N27);
glVertex3fv(P27);
glNormal3fv(N37);
glVertex3fv(P37);
glNormal3fv(N36);
glVertex3fv(P36);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N27);
glVertex3fv(P27);
glNormal3fv(N28);
glVertex3fv(P28);
glNormal3fv(N38);
glVertex3fv(P38);
glNormal3fv(N37);
glVertex3fv(P37);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N28);
glVertex3fv(P28);
glNormal3fv(N29);
glVertex3fv(P29);
glNormal3fv(N39);
glVertex3fv(P39);
glNormal3fv(N38);
glVertex3fv(P38);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N29);
glVertex3fv(P29);
glNormal3fv(N30);
glVertex3fv(P30);
glNormal3fv(N40);
glVertex3fv(P40);
glNormal3fv(N39);
glVertex3fv(P39);
glEnd();
}

void
Fish004(void)
{
glBegin(GL_POLYGON);
glNormal3fv(N40);
glVertex3fv(P40);
glNormal3fv(N41);
glVertex3fv(P41);
glNormal3fv(N51);
glVertex3fv(P51);
glNormal3fv(N50);
glVertex3fv(P50);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N41);
glVertex3fv(P41);
glNormal3fv(N42);
glVertex3fv(P42);
glNormal3fv(N52);
glVertex3fv(P52);
glNormal3fv(N51);
glVertex3fv(P51);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N42);
glVertex3fv(P42);
glNormal3fv(N33);
glVertex3fv(P33);
glNormal3fv(N43);
glVertex3fv(P43);
glNormal3fv(N52);
glVertex3fv(P52);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N33);
glVertex3fv(P33);
glNormal3fv(N34);
glVertex3fv(P34);
glNormal3fv(N44);
glVertex3fv(P44);
glNormal3fv(N43);
glVertex3fv(P43);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N34);
glVertex3fv(P34);
glNormal3fv(N35);
glVertex3fv(P35);
glNormal3fv(N45);
glVertex3fv(P45);
glNormal3fv(N44);
glVertex3fv(P44);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N35);
glVertex3fv(P35);
glNormal3fv(N36);
glVertex3fv(P36);
glNormal3fv(N46);
glVertex3fv(P46);
glNormal3fv(N45);
glVertex3fv(P45);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N36);
glVertex3fv(P36);
glNormal3fv(N37);
glVertex3fv(P37);
glNormal3fv(N47);
glVertex3fv(P47);
glNormal3fv(N46);
glVertex3fv(P46);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N37);
glVertex3fv(P37);
glNormal3fv(N38);
glVertex3fv(P38);
glNormal3fv(N48);
glVertex3fv(P48);
glNormal3fv(N47);
glVertex3fv(P47);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N38);
glVertex3fv(P38);
glNormal3fv(N39);
glVertex3fv(P39);
glNormal3fv(N49);
glVertex3fv(P49);
glNormal3fv(N48);
glVertex3fv(P48);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N39);
glVertex3fv(P39);
glNormal3fv(N40);
glVertex3fv(P40);
glNormal3fv(N50);
glVertex3fv(P50);
glNormal3fv(N49);
glVertex3fv(P49);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N70);
glVertex3fv(P70);
glNormal3fv(N61);
glVertex3fv(P61);
glNormal3fv(N02);
glVertex3fv(P02);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N61);
glVertex3fv(P61);
glNormal3fv(N46);
glVertex3fv(P46);
glNormal3fv(N02);
glVertex3fv(P02);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N45);
glVertex3fv(P45);
glNormal3fv(N46);
glVertex3fv(P46);
glNormal3fv(N61);
glVertex3fv(P61);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N02);
glVertex3fv(P02);
glNormal3fv(N61);
glVertex3fv(P61);
glNormal3fv(N70);
glVertex3fv(P70);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N02);
glVertex3fv(P02);
glNormal3fv(N45);
glVertex3fv(P45);
glNormal3fv(N61);
glVertex3fv(P61);
glEnd();
}

void
Fish005(void)
{
glBegin(GL_POLYGON);
glNormal3fv(N02);
glVertex3fv(P02);
glNormal3fv(N44);
glVertex3fv(P44);
glNormal3fv(N45);
glVertex3fv(P45);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N02);
glVertex3fv(P02);
glNormal3fv(N43);
glVertex3fv(P43);
glNormal3fv(N44);
glVertex3fv(P44);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N02);
glVertex3fv(P02);
glNormal3fv(N52);
glVertex3fv(P52);
glNormal3fv(N43);
glVertex3fv(P43);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N02);
glVertex3fv(P02);
glNormal3fv(N51);
glVertex3fv(P51);
glNormal3fv(N52);
glVertex3fv(P52);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N02);
glVertex3fv(P02);
glNormal3fv(N46);
glVertex3fv(P46);
glNormal3fv(N47);
glVertex3fv(P47);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N02);
glVertex3fv(P02);
glNormal3fv(N47);
glVertex3fv(P47);
glNormal3fv(N48);
glVertex3fv(P48);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N02);
glVertex3fv(P02);
glNormal3fv(N48);
glVertex3fv(P48);
glNormal3fv(N49);
glVertex3fv(P49);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N02);
glVertex3fv(P02);
glNormal3fv(N49);
glVertex3fv(P49);
glNormal3fv(N50);
glVertex3fv(P50);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N50);
glVertex3fv(P50);
glNormal3fv(N51);
glVertex3fv(P51);
glNormal3fv(N69);
glVertex3fv(P69);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N51);
glVertex3fv(P51);
glNormal3fv(N02);
glVertex3fv(P02);
glNormal3fv(N69);
glVertex3fv(P69);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N50);
glVertex3fv(P50);
glNormal3fv(N69);
glVertex3fv(P69);
glNormal3fv(N02);
glVertex3fv(P02);
glEnd();
}

void
Fish006(void)
{
glBegin(GL_POLYGON);
glNormal3fv(N66);
glVertex3fv(P66);
glNormal3fv(N16);
glVertex3fv(P16);
glNormal3fv(N26);
glVertex3fv(P26);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N15);
glVertex3fv(P15);
glNormal3fv(N66);
glVertex3fv(P66);
glNormal3fv(N25);
glVertex3fv(P25);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N25);
glVertex3fv(P25);
glNormal3fv(N66);
glVertex3fv(P66);
glNormal3fv(N26);
glVertex3fv(P26);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N66);
glVertex3fv(P66);
glNormal3fv(N58);
glVertex3fv(P58);
glNormal3fv(N16);
glVertex3fv(P16);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N15);
glVertex3fv(P15);
glNormal3fv(N58);
glVertex3fv(P58);
glNormal3fv(N66);
glVertex3fv(P66);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N58);
glVertex3fv(P58);
glNormal3fv(N15);
glVertex3fv(P15);
glNormal3fv(N16);
glVertex3fv(P16);
glEnd();
}

void
Fish007(void)
{
glBegin(GL_POLYGON);
glNormal3fv(N62);
glVertex3fv(P62);
glNormal3fv(N22);
glVertex3fv(P22);
glNormal3fv(N32);
glVertex3fv(P32);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N62);
glVertex3fv(P62);
glNormal3fv(N32);
glVertex3fv(P32);
glNormal3fv(N64);
glVertex3fv(P64);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N22);
glVertex3fv(P22);
glNormal3fv(N62);
glVertex3fv(P62);
glNormal3fv(N32);
glVertex3fv(P32);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N62);
glVertex3fv(P62);
glNormal3fv(N64);
glVertex3fv(P64);
glNormal3fv(N32);
glVertex3fv(P32);
glEnd();
}

void
Fish008(void)
{
glBegin(GL_POLYGON);
glNormal3fv(N63);
glVertex3fv(P63);
glNormal3fv(N19);
glVertex3fv(P19);
glNormal3fv(N29);
glVertex3fv(P29);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N19);
glVertex3fv(P19);
glNormal3fv(N63);
glVertex3fv(P63);
glNormal3fv(N29);
glVertex3fv(P29);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N63);
glVertex3fv(P63);
glNormal3fv(N29);
glVertex3fv(P29);
glNormal3fv(N65);
glVertex3fv(P65);
glEnd();
glBegin(GL_POLYGON);
glNormal3fv(N63);
glVertex3fv(P63);
glNormal3fv(N65);
glVertex3fv(P65);
glNormal3fv(N29);
glVertex3fv(P29);
glEnd();
}

void
Fish009(void)
{
glBegin(GL_POLYGON);
glVertex3fv(P59);
glVertex3fv(P12);
glVertex3fv(P09);
glVertex3fv(P60);
glEnd();
glBegin(GL_POLYGON);
glVertex3fv(P12);
glVertex3fv(P04);
glVertex3fv(P07);
glVertex3fv(P09);
glEnd();
}

void
Fish_1(void)
{
Fish004();
Fish005();
Fish003();
Fish007();
Fish006();
Fish002();
Fish008();
Fish009();
Fish001();
}

void
Fish_2(void)
{
Fish005();
Fish004();
Fish003();
Fish008();
Fish006();
Fish002();
Fish007();
Fish009();
Fish001();
}

void
Fish_3(void)
{
glColor3f(1.0,1.0,0.0);
Fish005();
Fish004();
Fish007();
Fish003();
Fish002();
Fish008();
Fish009();
Fish001();
Fish006();
}

void
Fish_4(void)
{
Fish005();
Fish004();
Fish008();
Fish003();
Fish002();
Fish007();
Fish009();
Fish001();
Fish006();
}

void
Fish_5(void)
{
Fish009();
Fish006();
Fish007();
Fish001();
Fish002();
Fish003();
Fish008();
Fish004();
Fish005();
}

void
Fish_6(void)
{
Fish009();
Fish006();
Fish008();
Fish001();
Fish002();
Fish007();
Fish003();
Fish004();
Fish005();
}

void
Fish_7(void)
{
Fish009();
Fish001();
Fish007();
Fish005();
Fish002();
Fish008();
Fish003();
Fish004();
Fish006();
}

void
Fish_8(void)
{
Fish009();
Fish008();
Fish001();
Fish002();
Fish007();
Fish003();
Fish005();
Fish004();
Fish006();
}

void
DrawShark(fishRec * fish)
{
float mat[4][4];
int n;
float seg1, seg2, seg3, seg4, segup;
float thrash, chomp;

fish->htail = (int) (fish->htail - (int) (5.0 * fish->v)) % 360;

thrash = 50.0 * fish->v;

seg1 = 0.6 * thrash * sin(fish->htail * RRAD);
seg2 = 1.8 * thrash * sin((fish->htail + 45.0) * RRAD);
seg3 = 3.0 * thrash * sin((fish->htail + 90.0) * RRAD);
seg4 = 4.0 * thrash * sin((fish->htail + 110.0) * RRAD);

chomp = 0.0;
if (fish->v > 2.0) {
chomp = -(fish->v - 2.0) * 200.0;
}
P04[1] = iP04[1] + chomp;
P07[1] = iP07[1] + chomp;
P10[1] = iP10[1] + chomp;
P11[1] = iP11[1] + chomp;

P23[0] = iP23[0] + seg1;
P24[0] = iP24[0] + seg1;
P25[0] = iP25[0] + seg1;
P26[0] = iP26[0] + seg1;
P27[0] = iP27[0] + seg1;
P28[0] = iP28[0] + seg1;
P29[0] = iP29[0] + seg1;
P30[0] = iP30[0] + seg1;
P31[0] = iP31[0] + seg1;
P32[0] = iP32[0] + seg1;
P33[0] = iP33[0] + seg2;
P34[0] = iP34[0] + seg2;
P35[0] = iP35[0] + seg2;
P36[0] = iP36[0] + seg2;
P37[0] = iP37[0] + seg2;
P38[0] = iP38[0] + seg2;
P39[0] = iP39[0] + seg2;
P40[0] = iP40[0] + seg2;
P41[0] = iP41[0] + seg2;
P42[0] = iP42[0] + seg2;
P43[0] = iP43[0] + seg3;
P44[0] = iP44[0] + seg3;
P45[0] = iP45[0] + seg3;
P46[0] = iP46[0] + seg3;
P47[0] = iP47[0] + seg3;
P48[0] = iP48[0] + seg3;
P49[0] = iP49[0] + seg3;
P50[0] = iP50[0] + seg3;
P51[0] = iP51[0] + seg3;
P52[0] = iP52[0] + seg3;
P02[0] = iP02[0] + seg4;
P61[0] = iP61[0] + seg4;
P69[0] = iP69[0] + seg4;
P70[0] = iP70[0] + seg4;

fish->vtail += ((fish->dtheta - fish->vtail) * 0.1);

if (fish->vtail > 0.5) {
fish->vtail = 0.5;
} else if (fish->vtail < -0.5) {
fish->vtail = -0.5;
}
segup = thrash * fish->vtail;

P23[1] = iP23[1] + segup;
P24[1] = iP24[1] + segup;
P25[1] = iP25[1] + segup;
P26[1] = iP26[1] + segup;
P27[1] = iP27[1] + segup;
P28[1] = iP28[1] + segup;
P29[1] = iP29[1] + segup;
P30[1] = iP30[1] + segup;
P31[1] = iP31[1] + segup;
P32[1] = iP32[1] + segup;
P33[1] = iP33[1] + segup * 5.0;
P34[1] = iP34[1] + segup * 5.0;
P35[1] = iP35[1] + segup * 5.0;
P36[1] = iP36[1] + segup * 5.0;
P37[1] = iP37[1] + segup * 5.0;
P38[1] = iP38[1] + segup * 5.0;
P39[1] = iP39[1] + segup * 5.0;
P40[1] = iP40[1] + segup * 5.0;
P41[1] = iP41[1] + segup * 5.0;
P42[1] = iP42[1] + segup * 5.0;
P43[1] = iP43[1] + segup * 12.0;
P44[1] = iP44[1] + segup * 12.0;
P45[1] = iP45[1] + segup * 12.0;
P46[1] = iP46[1] + segup * 12.0;
P47[1] = iP47[1] + segup * 12.0;
P48[1] = iP48[1] + segup * 12.0;
P49[1] = iP49[1] + segup * 12.0;
P50[1] = iP50[1] + segup * 12.0;
P51[1] = iP51[1] + segup * 12.0;
P52[1] = iP52[1] + segup * 12.0;
P02[1] = iP02[1] + segup * 17.0;
P61[1] = iP61[1] + segup * 17.0;
P69[1] = iP69[1] + segup * 17.0;
P70[1] = iP70[1] + segup * 17.0;

glPushMatrix();

glTranslatef(0.0, 0.0, -3000.0);

glGetFloatv(GL_MODELVIEW_MATRIX, &amp;mat[0][0]);
n = 0;
if (mat[0][2] >= 0.0) {
n += 1;
}
if (mat[1][2] >= 0.0) {
n += 2;
}
if (mat[2][2] >= 0.0) {
n += 4;
}
glScalef(2.0, 1.0, 1.0);

glEnable(GL_CULL_FACE);
switch (n) {
case 0:
Fish_1();
break;
case 1:
Fish_2();
break;
case 2:
Fish_3();
break;
case 3:
Fish_4();
break;
case 4:
Fish_5();
break;
case 5:
Fish_6();
break;
case 6:
Fish_7();
break;
case 7:
Fish_8();
break;
}
glDisable(GL_CULL_FACE);

glPopMatrix();
}
void
FishTransform(fishRec * fish)
{

glTranslatef(fish->y, fish->z, -fish->x);
glRotatef(-fish->psi, 0.0, 1.0, 0.0);
glRotatef(fish->theta, 1.0, 0.0, 0.0);
glRotatef(-fish->phi, 0.0, 0.0, 1.0);
}

void
SharkPilot(fishRec * fish)
{
static int sign = 1;
float X, Y, Z, tpsi, ttheta, thetal;

fish->xt = 60000.0;
fish->yt = 0.0;
fish->zt = 0.0;

X = fish->xt - fish->x;
Y = fish->yt - fish->y;
Z = fish->zt - fish->z;

thetal = fish->theta;

ttheta = RAD * atan(Z / (sqrt(X * X + Y * Y)));

if (ttheta > fish->theta + 0.25) {
fish->theta += 0.5;
} else if (ttheta < fish->theta - 0.25) {
fish->theta -= 0.5;
}
if (fish->theta > 90.0) {
fish->theta = 90.0;
}
if (fish->theta < -90.0) {
fish->theta = -90.0;
}
fish->dtheta = fish->theta - thetal;

tpsi = RAD * atan2(Y, X);

fish->attack = 0;

if (fabs(tpsi - fish->psi) < 10.0) {
fish->attack = 1;
} else if (fabs(tpsi - fish->psi) < 45.0) {
if (fish->psi > tpsi) {
fish->psi -= 0.5;
if (fish->psi < -180.0) {
fish->psi += 360.0;
}
} else if (fish->psi < tpsi) {
fish->psi += 0.5;
if (fish->psi > 180.0) {
fish->psi -= 360.0;
}
}
} else {
if (rand() % 100 > 98) {
sign = 1 - sign;
}
fish->psi += sign;
if (fish->psi > 180.0) {
fish->psi -= 360.0;
}
if (fish->psi < -180.0) {
fish->psi += 360.0;
}
}

if (fish->attack) {
if (fish->v < 1.1) {
fish->spurt = 1;
}
if (fish->spurt) {
fish->v += 0.2;
}
if (fish->v > 5.0) {
fish->spurt = 0;
}
if ((fish->v > 1.0) &amp;&amp; (!fish->spurt)) {
fish->v -= 0.2;
}
} else {
if (!(rand() % 400) &amp;&amp; (!fish->spurt)) {
fish->spurt = 1;
}
if (fish->spurt) {
fish->v += 0.05;
}
if (fish->v > 3.0) {
fish->spurt = 0;
}
if ((fish->v > 1.0) &amp;&amp; (!fish->spurt)) {
fish->v -= 0.05;
}
}

fish->x += SHARKSPEED * fish->v * cos(fish->psi / RAD) * cos(fish->theta / RAD);
fish->y += SHARKSPEED * fish->v * sin(fish->psi / RAD) * cos(fish->theta / RAD);
fish->z += SHARKSPEED * fish->v * sin(fish->theta / RAD);
}

void
SharkMiss(int i)
{
int j;
float avoid, thetal;
float X, Y, Z, R;

for (j = 0; j < NUM_SHARKS; j++) {
if (j != i) {
X = sharks[j].x - sharks[i].x;
Y = sharks[j].y - sharks[i].y;
Z = sharks[j].z - sharks[i].z;

R = sqrt(X * X + Y * Y + Z * Z);

avoid = 1.0;
thetal = sharks[i].theta;

if (R < SHARKSIZE) {
if (Z > 0.0) {
sharks[i].theta -= avoid;
} else {
sharks[i].theta += avoid;
}
}
sharks[i].dtheta += (sharks[i].theta - thetal);
}
}
}

void
InitFishs(void)
{
int i;

for (i = 0; i < NUM_SHARKS; i++) {
sharks[i].x = 70000.0 + rand() % 6000;
sharks[i].y = rand() % 6000;
sharks[i].z = rand() % 6000;
sharks[i].psi = rand() % 360 - 180.0;
sharks[i].v = 1.0;
}



}


GLboolean LoadTerrain(char *fn)
{
int LandScapeFile;
LandScapeFile = _open(fn, _O_RDONLY | _O_BINARY);
if (LandScapeFile == -1) return GL_FALSE;
_read(LandScapeFile, LandScape->HEIGHTMAP, LANDSCAPESIZE2);
_close(LandScapeFile);
return GL_TRUE;
}

void SetupPlayer(void)
{
CurrentPlayer.x_pos = (GLfloat)LANDSCAPESIZE / 2.0f;
CurrentPlayer.y_pos = (GLfloat)LANDSCAPESIZE / 2.0f;
CurrentPlayer.height = 1.2f * FLAT_SCALER;
CurrentPlayer.alpha = 0;
}

GLboolean Init(void)
{ static float ambient[]={0.1,0.1,0.1,1.0};
static float diffuse[]={1.0, 1.0, 1.0, 1.0};
static float position[]={0.0, 1.0, 0.0, 0.0};
static float mat_shininess[]={90.0};
static float mat_specular[]={0.8, 0.8, 0.8, 1.0};
static float mat_diffuse[]={0.46, 0.66, 0.795, 1.0};
static float mat_ambient[]={0.0, 0.1, 0.2, 1.0};
static float lmodel_ambient[]={0.4, 0.4, 0.4, 1.0};
static float lmodel_localviewer[]={0.0};

GLfloat fogColor[] = {0.0f, 0.0f, 0.3f, 0.2f};

LandScape = (struct LandScapeTerrain*)malloc(sizeof(struct LandScapeTerrain));
if (LandScape == NULL) return GL_FALSE;
if (LoadTerrain("data\\land.raw") == GL_FALSE) {
free(LandScape);
return GL_FALSE;
}

texture_grass = auxDIBImageLoad("data\\grass.bmp");
if (texture_grass == NULL) return GL_FALSE;

glGenTextures(NUM_TEXTURES, texobjs);
glBindTexture(GL_TEXTURE_2D, texobjs[0]);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, texture_grass->sizeX, texture_grass->sizeY,
GL_RGB, GL_UNSIGNED_BYTE, texture_grass->data);

glClearColor(fogColor[0], fogColor[1], fogColor[2], fogColor[3]);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
glEnable(GL_TEXTURE_2D);

glEnable(GL_FOG);
glFogi(GL_FOG_MODE, GL_EXP2);
glFogf(GL_FOG_DENSITY, 0.04f);
glFogfv(GL_FOG_COLOR, fogColor);

SetupPlayer();

/*

glFrontFace(GL_CW);

glDepthFunc(GL_LEQUAL);
glEnable(GL_DEPTH_TEST);

glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
glLightfv(GL_LIGHT0, GL_POSITION, position);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, lmodel_localviewer);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);

glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mat_shininess);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mat_diffuse);
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, mat_ambient);*/

InitFishs();
return GL_TRUE;
}

void Done(void)
{
free(LandScape);
}

static void CALLBACK Reshape(int width, int height)
{
GLfloat aspect;
if (!width) return;

glFinish();

windW = (GLint)width;
windH = (GLint)height;

aspect = (GLfloat)windW / (GLfloat)windH;

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(90.0f, aspect, 0.05f, 50.0f);

glViewport (0, 0, windW, windH);
}

GLfloat ReturnHEIGHT(GLint _x_, GLint _y_)
{
// _x_=_x_ << 1;
// _y_=_y_ << 1;
if (_x_ < 0) _x_+=LANDSCAPESIZE;
if (_y_ < 0) _y_+=LANDSCAPESIZE;
if (_x_ >= LANDSCAPESIZE) _x_-=LANDSCAPESIZE;
if (_y_ >= LANDSCAPESIZE) _y_-=LANDSCAPESIZE;
return (GLfloat)LandScape->HEIGHTMAP[_x_][_y_];
}

GLboolean PointInFrustum(GLint _x_, GLint _y_)
{
if (sqrt(_x_ * _x_ + _y_ * _y_) >= VIEWDISTANCE >> 1) return GL_FALSE;
return GL_TRUE;
}

void PreDrawLandScape(void)
{
GLint ix, iy, oix, oiy;
GLfloat fx, fy, xcf, ycf;
GLfloat h1, h2, h3, h4, res_h;

ix = (GLint)CurrentPlayer.x_pos;
iy = (GLint)CurrentPlayer.y_pos;
fx = (GLfloat)CurrentPlayer.x_pos;
fy = (GLfloat)CurrentPlayer.y_pos;

oix = ix; oiy = iy;
h1 = ReturnHEIGHT(ix, iy);
if (fx > ix) ix++; else ix--;
h2 = ReturnHEIGHT(ix, iy);
if (fy > iy) iy++; else iy--;
h3 = ReturnHEIGHT(oix, iy);
h4 = ReturnHEIGHT(ix, iy);
xcf = 1.0f - fabs((GLfloat)oix - fx);
ycf = 1.0f - fabs((GLfloat)oiy - fy);
res_h = h1 * xcf * ycf +
h2 * (1.0f - xcf) * ycf +
h3 * (1.0f - ycf) * xcf +
h4 * (1.0f - xcf) * (1.0f - ycf);

CurrentPlayer.mounth = res_h;

x_pos_frac = (CurrentPlayer.x_pos - ix) * FLAT_SCALER;
y_pos_frac = (CurrentPlayer.y_pos - iy) * FLAT_SCALER;

}
/*void
reshape(int width, int height)
{
glViewport(0, 0, width, height);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(400.0, 2.0, 10000.0, 400000.0);
glMatrixMode(GL_MODELVIEW);
}*/

void
Animate(void)
{
int i;

for (i = 0; i < NUM_SHARKS; i++) {
SharkPilot(&amp;sharks[i]);
SharkMiss(i);
}


glutPostRedisplay();

}


void DrawLandScape(void)
{
GLint i, j;
GLint tx, ty;
GLint ix, iy;
GLfloat z1, z2, z3, z4;
GLfloat x1, x2, y1, y2;
ix = (GLint)CurrentPlayer.x_pos;
iy = (GLint)CurrentPlayer.y_pos;

glBegin(GL_TRIANGLES);
for (i = - VIEWDISTANCE >> 1; i < VIEWDISTANCE >> 1; i++)
for (j = - VIEWDISTANCE >> 1; j < VIEWDISTANCE >> 1; j++)
{
if (PointInFrustum(i, j) == GL_TRUE) {

tx = ix + i;
ty = iy + j;

z1 = ReturnHEIGHT(tx , ty );
z2 = ReturnHEIGHT(tx + 1, ty );
z3 = ReturnHEIGHT(tx + 1, ty + 1);
z4 = ReturnHEIGHT(tx , ty + 1);

x1 = (GLfloat)(i) * FLAT_SCALER;
x2 = (GLfloat)(i+1) * FLAT_SCALER;
y1 = (GLfloat)(j) * FLAT_SCALER;
y2 = (GLfloat)(j+1) * FLAT_SCALER;

// --1--
glTexCoord2f(0.0f, 0.0f);
glVertex3f(x1, y1, z1);
glTexCoord2f(1.0f, 0.0f);
glVertex3f(x2, y1, z2);
glTexCoord2f(1.0f, 1.0f);
glVertex3f(x2, y2, z3);
// --2--
glTexCoord2f(1.0f, 1.0f);
glVertex3f(x2, y2, z3);
glTexCoord2f(0.0f, 1.0f);
glVertex3f(x1, y2, z4);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(x1, y1, z1);

}

}
glEnd();
}

static void CALLBACK Draw(void)
{
PreDrawLandScape();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
// glTranslatef(0.0f, 0.0f, -p__-15.5);
// glRotatef(t__*100, 0.0f, 0.0f, 1.0f);
// glRotatef(rotX, 1.0f, 0.0f, 0.0f);
// glRotatef(rotY, 0.0f, 1.0f, 0.0f);
// glRotatef(rotZ, 0.0f, 0.0f, 1.0f);
// glRotatef(-45.0f, 1.0f, 0.0f, 0.0f);
gluLookAt( 0+x_pos_frac,
0+y_pos_frac,
CurrentPlayer.mounth + CurrentPlayer.height,
cos(CurrentPlayer.alpha)+x_pos_frac,
sin(CurrentPlayer.alpha)+y_pos_frac,
CurrentPlayer.mounth + CurrentPlayer.height,
0,
0,
1);
// ...
DrawLandScape();
// ...

for (i = 0; i < NUM_SHARKS; i++) {
glPushMatrix();
FishTransform(&amp;sharks[i]);
DrawShark(&amp;sharks[i]);
glPopMatrix();
}

glFlush();
auxSwapBuffers();
}

static void CALLBACK IdleFunc(void)
{
// ...
CurrentPlayer.alpha -= 0.0005f;
CurrentPlayer.x_pos += cos(CurrentPlayer.alpha) / 100.0f;
CurrentPlayer.y_pos += sin(CurrentPlayer.alpha) / 100.0f;
Draw();
Animate();
}
void
Visible(int state)
{
if (state == GLUT_VISIBLE) {
if (moving)
glutIdleFunc(Animate);
} else {
if (moving)
glutIdleFunc(NULL);
}
}



void main(int argc, char **argv)
{
windW = WND_WIDTH;
windH = WND_HEIGHT;

auxInitPosition(0, 0, windW, windH);
auxInitDisplayMode(AUX_RGB | AUX_DOUBLE | AUX_DEPTH);

if (auxInitWindow("LandScape") == GL_FALSE) auxQuit();
if (Init() == GL_FALSE) auxQuit();

auxReshapeFunc((AUXRESHAPEPROC)Reshape);
auxIdleFunc((AUXIDLEPROC)IdleFunc);
glutVisibilityFunc(Visible);
auxMainLoop(Draw);

Done();
}


the error is as listed-
compilation throws me no errors....when i run it in debug mode this is what it has to say


unhandled exception in Landscape.exe(GLUT32.dll):0xC0000005:Access Violation

......where landscape is the project name

immediate help needed
thanks in advance

kowal
04-23-2010, 03:56 PM
First of all, glaux is obsolete, You mixed glaux calls with glut - this is wrong (calling glut functions without proper initialization). Convert Your aux* calls to glut ones (names are quite similar)
basic info about glut:
http://www.lighthouse3d.com/opengl/glut/index.php?2

Edit:
ps. Did you export this 'models' from some program as OpenGL code?

holyevil
04-24-2010, 04:04 AM
nope i didnt..........as for the compatibility issues with glaux and glut i noticed that......but i'm having a hard time loading a bmp image inspite of so many tutorials(yeah browsed through nehe too)...so any help in correction of the code would be greatly appreciated...ty

kowal
04-24-2010, 04:55 AM
Get rid of that aux* crap.
init your display in glut, like that:


int main( int argc, char** argv )
{
glutInit( &amp;argc, argv );
glutInitDisplayMode( GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH );
glutInitWindowSize( windW, windH );
glutCreateWindow( "app_name_here" );
glutReshapeFunc( Reshape );
glutKeyboardFunc( keys ); //optional (if you need kb input)
glutSpecialFunc( specialKeys ); // same as above
glutDisplayFunc( Draw );
//other glut calls (glut IdleFunc(), glutVisibilityFunc() etc.)

setupRC(); //setup opengl here (load files, textures etc.)

glutMainLoop();

Done();

return 0;
}


repalce auxSwpaBuffers() with glut SwapBuffers()

for loading images You can use Devil library (free and relatively simple)
http://openil.sourceforge.net/
it will load your inages in 1-2 calls
(instead of auxDIBImageLoad(...) )

ps. use code tags!