2003-07-01 20:37:09 +00:00
|
|
|
// The contents of this file are subject to the BOINC Public License
|
2003-05-20 00:03:39 +00:00
|
|
|
// Version 1.0 (the "License"); you may not use this file except in
|
|
|
|
// compliance with the License. You may obtain a copy of the License at
|
2003-07-01 20:37:09 +00:00
|
|
|
// http://boinc.berkeley.edu/license_1.0.txt
|
2003-05-20 00:03:39 +00:00
|
|
|
//
|
|
|
|
// Software distributed under the License is distributed on an "AS IS"
|
|
|
|
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
|
|
|
// License for the specific language governing rights and limitations
|
|
|
|
// under the License.
|
|
|
|
//
|
|
|
|
// The Original Code is the Berkeley Open Infrastructure for Network Computing.
|
|
|
|
//
|
|
|
|
// The Initial Developer of the Original Code is the SETI@home project.
|
|
|
|
// Portions created by the SETI@home project are Copyright (C) 2002
|
|
|
|
// University of California at Berkeley. All Rights Reserved.
|
|
|
|
//
|
|
|
|
// Contributor(s):
|
|
|
|
//
|
|
|
|
|
2003-10-05 05:26:59 +00:00
|
|
|
// various utility classes for OpenGL programming,
|
|
|
|
// used in Astropulse and SETI@home
|
|
|
|
// See also graphics_data.C,h
|
|
|
|
|
2003-10-03 22:51:28 +00:00
|
|
|
#ifndef GUTIL_H
|
|
|
|
#define GUTIL_H
|
2003-10-03 00:44:25 +00:00
|
|
|
|
2003-01-29 21:13:15 +00:00
|
|
|
struct COLOR {
|
2003-10-05 21:30:00 +00:00
|
|
|
float r;
|
|
|
|
float g;
|
|
|
|
float b;
|
|
|
|
float a;
|
2003-01-29 21:13:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern void HLStoRGB( double H, double L, double S, COLOR& c);
|
|
|
|
|
|
|
|
extern float frand();
|
|
|
|
|
2003-10-05 21:30:00 +00:00
|
|
|
extern void drawSphere(float* pos, float rad);
|
|
|
|
extern void drawCylinder(bool vertical, float* pos, float len, float rad);
|
2003-01-29 21:13:15 +00:00
|
|
|
|
|
|
|
#define TEXT_LEFT 0
|
|
|
|
#define TEXT_CENTER 1
|
|
|
|
#define TEXT_RIGHT 2
|
|
|
|
extern void draw_text_line(
|
2003-10-05 21:30:00 +00:00
|
|
|
float* pos, float height, float width, char *text,
|
2003-01-29 21:13:15 +00:00
|
|
|
int justify=TEXT_LEFT
|
|
|
|
);
|
2003-09-16 23:45:29 +00:00
|
|
|
|
|
|
|
void draw_text_simple(char* text,float line_width,float char_height);
|
|
|
|
|
2003-01-29 21:13:15 +00:00
|
|
|
extern void draw_text(
|
2003-10-05 21:30:00 +00:00
|
|
|
float* pos, float height, float width, float spacing, char *text
|
2003-01-29 21:13:15 +00:00
|
|
|
);
|
2003-09-10 23:44:46 +00:00
|
|
|
|
2003-09-18 23:55:11 +00:00
|
|
|
extern void draw_text_new(
|
2003-10-05 21:30:00 +00:00
|
|
|
float* pos, float height, float width, float spacing, char *text
|
2003-09-18 23:55:11 +00:00
|
|
|
);
|
|
|
|
|
2003-10-09 00:21:49 +00:00
|
|
|
extern void draw_text_new_right(
|
|
|
|
float* pos, float height, float width, float spacing, char *text
|
|
|
|
);
|
|
|
|
|
|
|
|
extern void draw_text_new_3d(
|
|
|
|
float* pos, float height, float width, float spacing, char *text
|
|
|
|
);
|
|
|
|
|
2003-09-10 23:44:46 +00:00
|
|
|
extern void draw_rotated_text(
|
2003-10-05 21:30:00 +00:00
|
|
|
float* pos, float height, float width, float spacing, char *text, float rotation, float* rotation_vector
|
2003-09-10 23:44:46 +00:00
|
|
|
);
|
|
|
|
|
2003-10-05 21:30:00 +00:00
|
|
|
extern float text_width(char* text);
|
2003-10-09 00:21:49 +00:00
|
|
|
extern float text_width_new(char* text);
|
2003-01-29 21:13:15 +00:00
|
|
|
extern void draw_text_panel(
|
2003-10-05 21:30:00 +00:00
|
|
|
float* _pos, float* size, float margin, COLOR color,
|
|
|
|
float char_height, float line_width, float line_spacing,
|
2003-05-20 00:03:39 +00:00
|
|
|
char* text
|
|
|
|
);
|
2003-03-27 18:20:25 +00:00
|
|
|
|
2003-03-30 23:27:22 +00:00
|
|
|
extern void mode_texture();
|
2003-09-16 23:45:29 +00:00
|
|
|
extern void mode_ortho();
|
2003-10-05 21:30:00 +00:00
|
|
|
extern void mode_shaded(float*);
|
2003-03-27 18:20:25 +00:00
|
|
|
extern void mode_unshaded();
|
|
|
|
extern void mode_lines();
|
2003-09-16 23:45:29 +00:00
|
|
|
extern void ortho_done();
|
|
|
|
extern bool get_matrix_invert(float[16]);
|
2003-09-17 23:17:09 +00:00
|
|
|
extern bool get_matrix(double src[16]);
|
|
|
|
extern bool get_projection(double src[16]);
|
|
|
|
extern bool get_viewport(int view[4]);
|
|
|
|
extern void get_2d_positions(float p1,float p2,float p3,
|
2003-10-05 21:30:00 +00:00
|
|
|
double model[16], double proj[16], int viewport[4], double proj_pos[3]
|
|
|
|
);
|
2003-03-27 18:20:25 +00:00
|
|
|
|
2003-10-06 16:10:33 +00:00
|
|
|
// a progress bar represented as an opaque cylinder within a translucent cylinder
|
2003-03-27 18:20:25 +00:00
|
|
|
//
|
|
|
|
class PROGRESS {
|
2003-10-05 21:30:00 +00:00
|
|
|
float pos[3];
|
|
|
|
float color[4], inner_color[4];
|
|
|
|
float len, rad, inner_rad;
|
2003-03-27 18:20:25 +00:00
|
|
|
public:
|
2003-10-05 21:30:00 +00:00
|
|
|
PROGRESS(float* pos, float len, float diam, float inner, float* c, float* ic);
|
2003-03-27 18:20:25 +00:00
|
|
|
void draw(float);
|
|
|
|
};
|
|
|
|
|
2003-10-09 00:21:49 +00:00
|
|
|
//2d progress bar
|
|
|
|
class PROGRESS_2D {
|
|
|
|
float pos[3];
|
|
|
|
float color[4], inner_color[4];
|
|
|
|
float len, width, inner_width;
|
|
|
|
public:
|
|
|
|
PROGRESS_2D(float* pos, float len, float width, float inner_width, float* c, float* ic);
|
|
|
|
void draw(float);
|
|
|
|
};
|
|
|
|
|
2003-10-06 16:10:33 +00:00
|
|
|
// a graph drawn as a ribbon in 3D
|
2003-03-27 18:20:25 +00:00
|
|
|
//
|
|
|
|
class GRAPH_2D {
|
|
|
|
float pos[3], size[3];
|
|
|
|
float color[4], tick_color[4];
|
|
|
|
float *data, dmax;
|
|
|
|
int len;
|
|
|
|
void draw_x(int);
|
|
|
|
void draw_y(int);
|
|
|
|
public:
|
|
|
|
GRAPH_2D(float* pos, float* size, float* color, float* tick_color);
|
2003-10-09 00:21:49 +00:00
|
|
|
void draw(float* data, int len);
|
2003-03-27 18:20:25 +00:00
|
|
|
void add_tick(float x, float yfrac);
|
2003-03-28 18:30:39 +00:00
|
|
|
};
|
|
|
|
|
2003-10-06 16:10:33 +00:00
|
|
|
// a colored panel with some text, that can move cyclically
|
|
|
|
//
|
|
|
|
class MOVING_TEXT_PANEL {
|
|
|
|
float base_pos[3];
|
|
|
|
float size[3];
|
|
|
|
float theta;
|
|
|
|
float dtheta;
|
|
|
|
float char_height;
|
|
|
|
float line_width;
|
|
|
|
float line_spacing;
|
|
|
|
double margin;
|
|
|
|
COLOR color;
|
|
|
|
public:
|
|
|
|
char text[1024];
|
|
|
|
float pos[3];
|
|
|
|
void init(float* pos, float* size, COLOR& color, double dtheta, double ch, double lw, double ls, double margin);
|
|
|
|
void draw();
|
|
|
|
static void sort(MOVING_TEXT_PANEL* tp, int n);
|
|
|
|
void move(double dt);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2003-10-05 05:26:59 +00:00
|
|
|
// ----- STUFF RELATED TO STARFIELDS
|
2003-05-20 00:03:39 +00:00
|
|
|
//
|
2003-10-09 00:21:49 +00:00
|
|
|
|
|
|
|
#define PI 3.14159265358979323846264
|
|
|
|
#define TAN22_5 0.41421356237309504880
|
|
|
|
#define MAX_STARFIELD_SIZE 10000
|
|
|
|
|
2003-10-05 05:26:59 +00:00
|
|
|
struct Star {
|
2003-10-09 00:21:49 +00:00
|
|
|
float x,y,z,v;
|
2003-09-16 23:45:29 +00:00
|
|
|
};
|
|
|
|
|
2003-10-05 05:26:59 +00:00
|
|
|
extern void build_stars(int, float);
|
2003-10-09 00:21:49 +00:00
|
|
|
extern void update_stars(int, float,float);
|
|
|
|
extern void replaceStar(int);
|
2003-09-17 23:17:09 +00:00
|
|
|
|
2003-10-05 05:26:59 +00:00
|
|
|
|
|
|
|
// ----- STUFF RELATED TO TEXTURES AND IMAGES
|
|
|
|
|
2003-10-09 06:00:05 +00:00
|
|
|
#if 0
|
2003-10-05 05:26:59 +00:00
|
|
|
#define IMAGE_TYPE_JPG 0
|
|
|
|
#define IMAGE_TYPE_PPM 1
|
|
|
|
#define IMAGE_TYPE_BMP 2
|
|
|
|
#define IMAGE_TYPE_TGA 3
|
2003-10-09 06:00:05 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define ALIGN_BOTTOM 0
|
|
|
|
#define ALIGN_CENTER 1
|
|
|
|
#define ALIGN_TOP 2
|
2003-10-05 05:26:59 +00:00
|
|
|
|
2003-10-06 16:10:33 +00:00
|
|
|
struct TEXTURE_DESC {
|
2003-10-09 00:55:38 +00:00
|
|
|
bool present;
|
2003-10-06 16:10:33 +00:00
|
|
|
unsigned int id;
|
|
|
|
double xsize; // size of underlying image
|
|
|
|
double ysize;
|
2003-10-09 06:00:05 +00:00
|
|
|
void draw(float* pos, float* size, int xalign, int yalign);
|
|
|
|
int load_image_file(char* filename);
|
|
|
|
int CreateTextureJPG(char* strFileName);
|
|
|
|
int CreateTextureBMP(char* strFileName);
|
|
|
|
int CreateTexturePPM(char* strFileName);
|
|
|
|
int CreateTextureTGA(char* strFileName);
|
2003-10-06 16:10:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#if 0
|
2003-10-05 05:26:59 +00:00
|
|
|
// read a portable pixmap file
|
|
|
|
//
|
|
|
|
extern int read_ppm(char* name, int& w, int& h, unsigned char** arrayp);
|
|
|
|
extern int init_texture(char* filename);
|
2003-10-06 16:10:33 +00:00
|
|
|
#endif
|
|
|
|
|
2003-10-05 05:26:59 +00:00
|
|
|
struct tImageJPG {
|
2003-10-02 20:22:03 +00:00
|
|
|
int rowSpan;
|
|
|
|
int sizeX;
|
|
|
|
int sizeY;
|
|
|
|
unsigned char *data;
|
|
|
|
};
|
|
|
|
|
2003-09-18 23:55:11 +00:00
|
|
|
extern tImageJPG *LoadJPG(const char *filename);
|
2003-10-05 05:26:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
// ----- STUFF RELATED TO FONTS
|
|
|
|
//
|
|
|
|
#define MAX_FONTS 16
|
2003-10-06 16:10:33 +00:00
|
|
|
extern unsigned int listBase[MAX_FONTS];
|
2003-10-05 05:26:59 +00:00
|
|
|
extern void MyCreateFont(unsigned int &base, char *fontName, int Size,int weight);
|
2003-09-18 23:55:11 +00:00
|
|
|
extern void print_text(unsigned int base, char *string);
|
2003-10-05 05:26:59 +00:00
|
|
|
|
2003-10-03 22:51:28 +00:00
|
|
|
#endif
|