*** empty log message ***

svn path=/trunk/boinc/; revision=2346
This commit is contained in:
Oliver Wang 2003-09-22 22:22:20 +00:00
parent 9e75c1a30a
commit e109339306
5 changed files with 66 additions and 28 deletions

View File

@ -116,6 +116,7 @@ int boinc_finish_opengl() {
GLvoid glPrint(GLuint font, const char *fmt, ...) // Custom GL "Print" Routine GLvoid glPrint(GLuint font, const char *fmt, ...) // Custom GL "Print" Routine
{ {
/*
char text[256]; // Holds Our String char text[256]; // Holds Our String
va_list ap; // Pointer To List Of Arguments va_list ap; // Pointer To List Of Arguments
@ -130,6 +131,7 @@ GLvoid glPrint(GLuint font, const char *fmt, ...) // Custom GL "Print" Routin
glListBase(font); // Sets The Base Character glListBase(font); // Sets The Base Character
glCallLists(strlen(text), GL_UNSIGNED_BYTE, text); // Draws The Display List Text glCallLists(strlen(text), GL_UNSIGNED_BYTE, text); // Draws The Display List Text
glPopAttrib(); // Pops The Display List Bits glPopAttrib(); // Pops The Display List Bits
*/
} }
GLenum InitGL(GLvoid) { // All Setup For OpenGL Goes Here GLenum InitGL(GLvoid) { // All Setup For OpenGL Goes Here
@ -170,6 +172,7 @@ GLenum ReSizeGLScene(GLsizei width, GLsizei height) { // Resize And Initialize T
glViewport(0,0,(int)(height*aspect_ratio),(height)); // Reset The Current Viewport glViewport(0,0,(int)(height*aspect_ratio),(height)); // Reset The Current Viewport
if (err=glGetError()) return err; if (err=glGetError()) return err;
app_resize(width,height);
return GL_NO_ERROR; return GL_NO_ERROR;
} }

View File

@ -36,6 +36,7 @@ GLenum ReSizeGLScene(GLsizei width, GLsizei height);
extern bool app_render(int xs, int ys, double time_of_day); extern bool app_render(int xs, int ys, double time_of_day);
extern void app_init_gl(void); extern void app_init_gl(void);
extern void app_unload_gl(); extern void app_unload_gl();
extern void app_resize(int width, int height);
#endif #endif
#endif #endif

View File

@ -72,7 +72,6 @@
#include "gutil.h" #include "gutil.h"
extern HDC myhDC; extern HDC myhDC;
unsigned int listBase;
GLfloat mat_diffuse[] = {0.7, 0.5, 1.0, 0.4}; GLfloat mat_diffuse[] = {0.7, 0.5, 1.0, 0.4};
GLfloat mat_specular[] = {1.0, 1.0, 1.0, 1.0}; GLfloat mat_specular[] = {1.0, 1.0, 1.0, 1.0};
@ -458,7 +457,7 @@ void draw_text_new(
q = strchr(p, '\n'); q = strchr(p, '\n');
if (q) *q = 0; if (q) *q = 0;
glRasterPos3d(pos[0],pos[1],pos[2]); glRasterPos3d(pos[0],pos[1],pos[2]);
print_text(listBase, p); print_text(listBase[0], p);
pos[1] -= line_spacing; pos[1] -= line_spacing;
if (!q) break; if (!q) break;
p = q+1; p = q+1;
@ -770,12 +769,17 @@ void build_stars()
float fov=45.0f; float fov=45.0f;
while(i<STARFIELD_SIZE) while(i<STARFIELD_SIZE)
{ {
float z = (float)(rand()%2000-1000); float z = (float)(rand()%2000-1000);
float alpha = 2.0*PI*(float)((rand()%359)/359.0) ; float alpha = 2.0*PI*(float)((rand()%359)/359.0) ;
float beta = asin(z/1000.0f); float beta = asin(z/1000.0f);
float x = 1000.0f * cos(beta) * cos(alpha); float x = 1000.0f * cos(beta) * cos(alpha);
float y = 1000.0f * cos(beta) * sin(alpha); float y = 1000.0f * cos(beta) * sin(alpha);
/*
float z = (float)(-rand()%1000);
float x = (float)(rand()%(int)(2.0f*-z*tan(22.5f*PI/180.0f) - (-z*tan(22.5f*PI/180.0f))));
float y = (float)(rand()%(int)(2.0f*-z*tan(22.5f*PI/180.0f) - (-z*tan(22.5f*PI/180.0f))));
*/
tmpStar->x=x; tmpStar->x=x;
tmpStar->y=y; tmpStar->y=y;
tmpStar->z=z; tmpStar->z=z;
@ -786,12 +790,20 @@ void build_stars()
tmpStar->next = new Star; tmpStar->next = new Star;
tmpStar=tmpStar->next; tmpStar=tmpStar->next;
i++; i++;
} }
tmpStar->next=NULL; tmpStar->next=NULL;
tmpStar=NULL; tmpStar=NULL;
} }
//moves stars towards the eye vector, and replaces ones that go behind z=0 //moves stars towards the eye vector, and replaces ones that go behind z=0
float dotProd(float a, float b, float c, float x, float y, float z)
{
return(a*x+b*y+c*z);
}
void update_stars() void update_stars()
{ {
float modelview[16]; float modelview[16];
@ -812,10 +824,7 @@ void update_stars()
// get_projection(proj); // get_projection(proj);
if(get_matrix_invert(modelview)==false) if(get_matrix_invert(modelview)==false)
fprintf(stderr,"ERROR: 0 determinant in modelview matrix"); fprintf(stderr,"ERROR: 0 determinant in modelview matrix");
if(get_matrix_invert(modelview)==false)
fprintf(stderr,"ERROR: 0 determinant in modelview matrix");
eye[0]=modelview[2]; eye[0]=modelview[2];
eye[1]=modelview[6]; eye[1]=modelview[6];
@ -831,17 +840,12 @@ void update_stars()
(camera[1]-tmpStar->y)*(camera[1]-tmpStar->y) + (camera[1]-tmpStar->y)*(camera[1]-tmpStar->y) +
(camera[2]-tmpStar->z)*(camera[2]-tmpStar->z)); (camera[2]-tmpStar->z)*(camera[2]-tmpStar->z));
if(tmpStar->z>0) //replace it if its behind the camera if(dotProd(eye[0],eye[1],eye[2],tmpStar->x,tmpStar->y,tmpStar->z)>0) // behing camera
{ {
replaceStar(tmpStar); replaceStar(tmpStar);
continue; continue;
} }
// tmpStar->x+=(0)*tmpStar->v*STAR_SPEED;
// tmpStar->y+=(0)*tmpStar->v*STAR_SPEED;
// tmpStar->z+=(1)*tmpStar->v*STAR_SPEED;
tmpStar->x+=(eye[0])*tmpStar->v*STAR_SPEED; tmpStar->x+=(eye[0])*tmpStar->v*STAR_SPEED;
tmpStar->y+=(eye[1])*tmpStar->v*STAR_SPEED; tmpStar->y+=(eye[1])*tmpStar->v*STAR_SPEED;
@ -850,8 +854,8 @@ void update_stars()
//grow objects as the approach you //grow objects as the approach you
if(dist>900) glPointSize(1.0f); if(dist>900) glPointSize(1.0f);
else if(dist>700) glPointSize(2.0f); else if(dist>600) glPointSize(2.0f);
else if(dist>10) glPointSize(3.0f); else if(dist>30) glPointSize(3.0f);
GLfloat mat_emission[] = {1, 1, 1, 1}; GLfloat mat_emission[] = {1, 1, 1, 1};
glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, mat_emission ); glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, mat_emission );
@ -989,6 +993,7 @@ bool CreateTexturePPM(UINT textureArray[], LPSTR strFileName, int textureID)
} }
//text //text
UINT listBase[MAX_TEXTURES];
void print_text(unsigned int base, char *string) void print_text(unsigned int base, char *string)
{ {
@ -1001,8 +1006,8 @@ void print_text(unsigned int base, char *string)
glPopAttrib(); glPopAttrib();
} }
void MyCreateFont(unsigned int &base, char *fontName, int Size) void MyCreateFont(unsigned int &base, char *fontName, int Size, int weight)
{ {
// windows font // windows font
HFONT hFont; HFONT hFont;
@ -1017,7 +1022,7 @@ void MyCreateFont(unsigned int &base, char *fontName, int Size)
} }
else else
{ {
hFont = CreateFont(Size, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, hFont = CreateFont(Size, 0, 0, 0, weight, FALSE, FALSE, FALSE,
ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS,
ANTIALIASED_QUALITY, FF_DONTCARE | DEFAULT_PITCH, fontName); ANTIALIASED_QUALITY, FF_DONTCARE | DEFAULT_PITCH, fontName);
} }

View File

@ -124,10 +124,12 @@ extern void replaceStar(Star* tmpStar);
#include "jpeglib.h" #include "jpeglib.h"
#include "bmplib.h" #include "bmplib.h"
#define MAX_TEXTURES 16 #define MAX_TEXTURES 16
#define MAX_FONTS 16
extern UINT g_Texture[MAX_TEXTURES]; extern UINT g_Texture[MAX_TEXTURES];
extern UINT listBase[MAX_FONTS];
extern bool CreateTextureJPG(UINT textureArray[], LPSTR strFileName, int textureID); extern bool CreateTextureJPG(UINT textureArray[], LPSTR strFileName, int textureID);
extern bool CreateTextureBMP(UINT textureArray[], LPSTR strFileName, int textureID); extern bool CreateTextureBMP(UINT textureArray[], LPSTR strFileName, int textureID);
extern bool CreateTexturePPM(UINT textureArray[], LPSTR strFileName, int textureID); extern bool CreateTexturePPM(UINT textureArray[], LPSTR strFileName, int textureID);
extern tImageJPG *LoadJPG(const char *filename); extern tImageJPG *LoadJPG(const char *filename);
extern void print_text(unsigned int base, char *string); extern void print_text(unsigned int base, char *string);
extern void MyCreateFont(unsigned int &base, char *fontName, int Size); extern void MyCreateFont(unsigned int &base, char *fontName, int Size, int weight);

View File

@ -17,8 +17,6 @@
#include "gutil.h" #include "gutil.h"
#include "reduce.h" #include "reduce.h"
extern unsigned int listBase;
REDUCED_ARRAY::REDUCED_ARRAY() { REDUCED_ARRAY::REDUCED_ARRAY() {
rdata = 0; rdata = 0;
ftemp = 0; ftemp = 0;
@ -470,6 +468,7 @@ void REDUCED_ARRAY::draw_row_rect_x(DrawType type,int row)
glEnd(); glEnd();
break; break;
case TYPE_WAVE: case TYPE_WAVE:
glLineWidth(1.0f);
z0 = draw_pos[2] + (draw_size[2]*row)/rdimy; z0 = draw_pos[2] + (draw_size[2]*row)/rdimy;
z1 = z0+.14f; z1 = z0+.14f;
row0 = rrow(row); row0 = rrow(row);
@ -786,10 +785,31 @@ void REDUCED_ARRAY::draw_labels()
double proj[16]; double proj[16];
double z_pos[3]; double z_pos[3];
double x_pos[3]; double x_pos[3];
double p_pos[3];
double xzmin_corner[3]; double xzmin_corner[3];
double zmax_corner[3]; double zmax_corner[3];
double xmax_corner[3]; double xmax_corner[3];
float arrowh = .35f;
float arroww = .05f;
glLineWidth(1.4f);
glBegin(GL_LINES);
glColor3f(1,1,1);
glVertex3f(draw_pos[0]+draw_size[0]+.4f,draw_pos[1],draw_pos[2]+draw_size[2]-.5f);
glVertex3f(draw_pos[0]+draw_size[0]+.4f,draw_pos[1]+1.2f,draw_pos[2]+draw_size[2]-.5f);
glEnd();
glBegin(GL_TRIANGLE_FAN);
glVertex3f(draw_pos[0]+draw_size[0]+.4f,draw_pos[1]+1.2f+arrowh,draw_pos[2]+draw_size[2]-.5f);
glVertex3f(draw_pos[0]+draw_size[0]+.4f-arroww,draw_pos[1]+1.2f,draw_pos[2]+draw_size[2]-.5f-arroww);
glVertex3f(draw_pos[0]+draw_size[0]+.4f+arroww,draw_pos[1]+1.2f,draw_pos[2]+draw_size[2]-.5f-arroww);
glVertex3f(draw_pos[0]+draw_size[0]+.4f+arroww,draw_pos[1]+1.2f,draw_pos[2]+draw_size[2]-.5f+arroww);
glVertex3f(draw_pos[0]+draw_size[0]+.4f-arroww,draw_pos[1]+1.2f,draw_pos[2]+draw_size[2]-.5f+arroww);
glVertex3f(draw_pos[0]+draw_size[0]+.4f-arroww,draw_pos[1]+1.2f,draw_pos[2]+draw_size[2]-.5f-arroww);
glEnd();
int viewport[4]; int viewport[4];
get_matrix(model); get_matrix(model);
@ -800,6 +820,7 @@ void REDUCED_ARRAY::draw_labels()
char* zlabel = "Time(sec)"; char* zlabel = "Time(sec)";
char* xlabel = "Frequency(HZ)"; char* xlabel = "Frequency(HZ)";
char* plabel = "Power";
char* zmax = "107.4"; char* zmax = "107.4";
char* zmin = "0"; char* zmin = "0";
@ -811,7 +832,6 @@ void REDUCED_ARRAY::draw_labels()
float left_of_z2 = -0.04f; float left_of_z2 = -0.04f;
float below_x = -.03f; float below_x = -.03f;
float center_x = -.06f; float center_x = -.06f;
get_2d_positions(draw_pos[0],draw_pos[1],draw_pos[2]+(draw_size[2]/2.0f), get_2d_positions(draw_pos[0],draw_pos[1],draw_pos[2]+(draw_size[2]/2.0f),
model, proj, viewport,z_pos); model, proj, viewport,z_pos);
@ -827,6 +847,9 @@ void REDUCED_ARRAY::draw_labels()
get_2d_positions(draw_pos[0],draw_pos[1],draw_pos[2], get_2d_positions(draw_pos[0],draw_pos[1],draw_pos[2],
model, proj, viewport,zmax_corner); model, proj, viewport,zmax_corner);
get_2d_positions(draw_pos[0]+draw_size[0]+.4f,draw_pos[1]+1.5f/2.3f,draw_pos[2]+draw_size[2]-.5f,
model, proj, viewport,p_pos);
mode_ortho(); mode_ortho();
@ -840,8 +863,9 @@ void REDUCED_ARRAY::draw_labels()
float xmaxpos[3]={(float)xmax_corner[0]/(float)(viewport[2]),(float)xmax_corner[1]/(float)(viewport[3])+below_x,(float)xmax_corner[2]}; float xmaxpos[3]={(float)xmax_corner[0]/(float)(viewport[2]),(float)xmax_corner[1]/(float)(viewport[3])+below_x,(float)xmax_corner[2]};
float zminpos[3]={(float)xzmin_corner[0]/(float)(viewport[2])+left_of_z2,(float)xzmin_corner[1]/(float)(viewport[3]),(float)xzmin_corner[2]}; float zminpos[3]={(float)xzmin_corner[0]/(float)(viewport[2])+left_of_z2,(float)xzmin_corner[1]/(float)(viewport[3]),(float)xzmin_corner[2]};
float zmaxpos[3]={(float)zmax_corner[0]/(float)(viewport[2])+left_of_z2,(float)zmax_corner[1]/(float)(viewport[3]),(float)zmax_corner[2]}; float zmaxpos[3]={(float)zmax_corner[0]/(float)(viewport[2])+left_of_z2,(float)zmax_corner[1]/(float)(viewport[3]),(float)zmax_corner[2]};
//draw_text_line(zpos, w, l, zlabel); float ppos[3]={(float)p_pos[0]/(float)(viewport[2])+.02f,(float)p_pos[1]/(float)(viewport[3]),(float)p_pos[2]};
//draw_text_line(xpos, w, l, xlabel); // draw_text_line(zpos, w, l, zlabel);
// draw_text_line(xpos, w, l, xlabel);
// draw_text_line(xminpos, w, l, xmin); // draw_text_line(xminpos, w, l, xmin);
// draw_text_line(xmaxpos, w, l, xmax); // draw_text_line(xmaxpos, w, l, xmax);
// draw_text_line(zminpos, w, l, zmin); // draw_text_line(zminpos, w, l, zmin);
@ -852,10 +876,13 @@ void REDUCED_ARRAY::draw_labels()
glLoadIdentity(); glLoadIdentity();
glRasterPos3d(zpos[0],zpos[1],-1);//zpos[2]); glRasterPos3d(zpos[0],zpos[1],-1);//zpos[2]);
print_text(listBase, "Time(sec)"); print_text(listBase[0], zlabel);
glRasterPos3d(xpos[0],xpos[1],-1);//xpos[2]); glRasterPos3d(xpos[0],xpos[1],-1);//xpos[2]);
print_text(listBase, "Frequency(HZ)"); print_text(listBase[0], xlabel);
glRasterPos3d(ppos[0],ppos[1],-1);//xpos[2]);
print_text(listBase[0], plabel);
glPopMatrix(); glPopMatrix();