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-10-15 19:08:51 +00:00
|
|
|
//
|
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
|
2003-10-15 19:08:51 +00:00
|
|
|
// under the License.
|
|
|
|
//
|
|
|
|
// The Original Code is the Berkeley Open Infrastructure for Network Computing.
|
|
|
|
//
|
2003-05-20 00:03:39 +00:00
|
|
|
// The Initial Developer of the Original Code is the SETI@home project.
|
|
|
|
// Portions created by the SETI@home project are Copyright (C) 2002
|
2003-10-15 19:08:51 +00:00
|
|
|
// University of California at Berkeley. All Rights Reserved.
|
|
|
|
//
|
2003-05-20 00:03:39 +00:00
|
|
|
// 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-16 21:06:10 +00:00
|
|
|
extern void scale_screen(int w,int h);
|
|
|
|
extern void center_screen(int w,int h);
|
2003-01-29 21:13:15 +00:00
|
|
|
|
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(
|
2004-07-09 15:29:18 +00:00
|
|
|
float* pos, float height, float width, const char *text,
|
2003-01-29 21:13:15 +00:00
|
|
|
int justify=TEXT_LEFT
|
|
|
|
);
|
2003-09-16 23:45:29 +00:00
|
|
|
|
2004-07-09 15:29:18 +00:00
|
|
|
void draw_text_simple(const char* text,float line_width,float char_height);
|
2003-09-16 23:45:29 +00:00
|
|
|
|
2003-01-29 21:13:15 +00:00
|
|
|
extern void draw_text(
|
2004-07-09 15:29:18 +00:00
|
|
|
float* pos, float height, float width, float spacing, const 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(
|
2004-07-09 15:29:18 +00:00
|
|
|
float* pos, float height, float width, float spacing, const char *text
|
2003-09-18 23:55:11 +00:00
|
|
|
);
|
|
|
|
|
2003-10-16 21:06:10 +00:00
|
|
|
extern void draw_text_right(
|
2004-07-09 15:29:18 +00:00
|
|
|
float* pos, float height, float width, float spacing, const char *text
|
2003-10-09 00:21:49 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
extern void draw_text_new_3d(
|
2004-07-09 15:29:18 +00:00
|
|
|
float* pos, float height, float width, float spacing, const char *text
|
2003-10-09 00:21:49 +00:00
|
|
|
);
|
|
|
|
|
2003-09-10 23:44:46 +00:00
|
|
|
extern void draw_rotated_text(
|
2004-07-09 15:29:18 +00:00
|
|
|
float* pos, float height, float width, float spacing, const char *text, float rotation, float* rotation_vector
|
2003-09-10 23:44:46 +00:00
|
|
|
);
|
|
|
|
|
2004-07-09 15:29:18 +00:00
|
|
|
extern float text_width(const char* text);
|
|
|
|
extern float text_width_new(const 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,
|
2004-07-09 15:29:18 +00:00
|
|
|
const char* text
|
2003-05-20 00:03:39 +00:00
|
|
|
);
|
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();
|
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]);
|
2004-05-15 22:09:26 +00:00
|
|
|
extern void get_2d_positions(double p1, double p2, double p3,
|
2004-07-09 15:29:18 +00:00
|
|
|
double model[16], double proj[16], int viewport[4], double proj_pos[3]
|
2003-10-05 21:30:00 +00:00
|
|
|
);
|
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
|
|
|
//
|
2003-10-15 19:08:51 +00:00
|
|
|
class PROGRESS {
|
2003-10-05 21:30:00 +00:00
|
|
|
float color[4], inner_color[4];
|
|
|
|
float len, rad, inner_rad;
|
2003-03-27 18:20:25 +00:00
|
|
|
public:
|
2004-07-09 15:29:18 +00:00
|
|
|
float pos[3];
|
2003-10-31 22:37:46 +00:00
|
|
|
void init(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 color[4], inner_color[4];
|
|
|
|
float len, width, inner_width;
|
2004-07-09 15:29:18 +00:00
|
|
|
float pos[3];
|
2003-10-15 00:01:58 +00:00
|
|
|
public:
|
|
|
|
void set_pos(float*);
|
2003-10-31 22:37:46 +00:00
|
|
|
void init(float* pos, float len, float width, float inner_width, float* c, float* ic);
|
2003-10-09 00:21:49 +00:00
|
|
|
void draw(float);
|
|
|
|
};
|
|
|
|
|
2003-10-10 18:00:35 +00:00
|
|
|
// a graph of a function of 1 variable drawn as a ribbon in 3D
|
2003-03-27 18:20:25 +00:00
|
|
|
//
|
2003-10-10 18:00:35 +00:00
|
|
|
class RIBBON_GRAPH {
|
2003-10-10 23:36:19 +00:00
|
|
|
float size[3];
|
2003-03-27 18:20:25 +00:00
|
|
|
float color[4], tick_color[4];
|
|
|
|
float *data, dmax;
|
2003-10-10 18:00:35 +00:00
|
|
|
float tick_yfrac;
|
|
|
|
float ticks[3];
|
2003-03-27 18:20:25 +00:00
|
|
|
int len;
|
|
|
|
void draw_x(int);
|
|
|
|
void draw_y(int);
|
2003-10-10 18:00:35 +00:00
|
|
|
void draw_tick(int i);
|
2004-07-09 15:29:18 +00:00
|
|
|
float pos[3];
|
2003-10-14 23:40:50 +00:00
|
|
|
public:
|
|
|
|
void set_pos(float*);
|
2003-10-31 22:37:46 +00:00
|
|
|
void init(float* pos, float* size, float* color, float* tick_color, float tick_yfrac=0.2);
|
2003-10-15 19:08:51 +00:00
|
|
|
void draw(float* data, int len, bool with_ticks=false);
|
2003-10-10 18:00:35 +00:00
|
|
|
void add_tick(float x, int index);
|
2003-03-28 18:30:39 +00:00
|
|
|
};
|
|
|
|
|
2003-10-14 23:40:50 +00:00
|
|
|
#define PANEL_MAX_LINES 10
|
2003-10-06 16:10:33 +00:00
|
|
|
// a colored panel with some text, that can move cyclically
|
|
|
|
//
|
|
|
|
class MOVING_TEXT_PANEL {
|
2003-10-15 19:08:51 +00:00
|
|
|
float base_pos[3];
|
2003-10-06 16:10:33 +00:00
|
|
|
float theta;
|
|
|
|
float dtheta;
|
|
|
|
COLOR color;
|
2004-07-09 15:29:18 +00:00
|
|
|
float char_height;
|
2003-10-14 22:30:52 +00:00
|
|
|
float line_width;
|
2003-10-15 19:08:51 +00:00
|
|
|
float line_spacing;
|
2004-07-09 15:29:18 +00:00
|
|
|
float size[3];
|
|
|
|
double margin;
|
|
|
|
char text[PANEL_MAX_LINES][256];
|
2003-10-15 19:08:51 +00:00
|
|
|
public:
|
2004-07-09 15:29:18 +00:00
|
|
|
float pos[3];
|
2003-10-06 16:10:33 +00:00
|
|
|
void init(float* pos, float* size, COLOR& color, double dtheta, double ch, double lw, double ls, double margin);
|
|
|
|
void draw();
|
2004-07-09 15:29:18 +00:00
|
|
|
void set_text(int lineno, const char* t);
|
2003-10-14 23:40:50 +00:00
|
|
|
void get_pos(int lineno, float* pos);
|
2003-10-06 16:10:33 +00:00
|
|
|
static void sort(MOVING_TEXT_PANEL* tp, int n);
|
|
|
|
void move(double dt);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2003-10-31 22:37:46 +00:00
|
|
|
// ----- STARFIELDS
|
2003-05-20 00:03:39 +00:00
|
|
|
//
|
2004-05-15 22:09:26 +00:00
|
|
|
// stars have their own coord system
|
|
|
|
// x = -1..1
|
|
|
|
// y = -1..1
|
|
|
|
// z = 0..zmax
|
|
|
|
// the projection plane is z=1,
|
|
|
|
// and the square +- 1/zmax is mapped to the window
|
|
|
|
//
|
2003-10-09 00:21:49 +00:00
|
|
|
|
2003-10-15 19:08:51 +00:00
|
|
|
struct STAR {
|
2004-07-09 15:29:18 +00:00
|
|
|
double x, y, z;
|
2003-09-16 23:45:29 +00:00
|
|
|
};
|
|
|
|
|
2003-10-10 18:00:35 +00:00
|
|
|
class STARFIELD {
|
2004-05-15 22:09:26 +00:00
|
|
|
double zmax, zmaxinv;
|
|
|
|
double speed;
|
2004-07-09 15:29:18 +00:00
|
|
|
int nstars;
|
|
|
|
void replace_star(int);
|
2003-10-10 18:00:35 +00:00
|
|
|
STAR* stars;
|
2003-10-31 22:37:46 +00:00
|
|
|
public:
|
|
|
|
STARFIELD();
|
2003-10-10 18:00:35 +00:00
|
|
|
void build_stars(int, float);
|
2003-10-16 21:06:10 +00:00
|
|
|
void update_stars(float);
|
2003-10-10 18:00:35 +00:00
|
|
|
};
|
|
|
|
|
2003-09-17 23:17:09 +00:00
|
|
|
|
2003-10-05 05:26:59 +00:00
|
|
|
|
2003-10-31 22:37:46 +00:00
|
|
|
// ----- TEXTURES AND IMAGES
|
2003-10-09 06:00:05 +00:00
|
|
|
|
|
|
|
#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 {
|
2004-07-09 15:29:18 +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);
|
2004-07-09 15:29:18 +00:00
|
|
|
int load_image_file(const char* filename);
|
|
|
|
int CreateTextureJPG(const char* strFileName);
|
|
|
|
int CreateTextureBMP(const char* strFileName);
|
|
|
|
int CreateTexturePPM(const char* strFileName);
|
|
|
|
int CreateTextureTGA(const char* strFileName);
|
2003-10-06 16:10:33 +00:00
|
|
|
};
|
|
|
|
|
2003-10-05 05:26:59 +00:00
|
|
|
|
2003-10-31 22:37:46 +00:00
|
|
|
// ----- FONTS
|
2003-10-05 05:26:59 +00:00
|
|
|
//
|
2003-10-10 23:36:19 +00:00
|
|
|
extern unsigned int listBase;
|
2004-07-09 15:29:18 +00:00
|
|
|
extern unsigned int MyCreateFont(const char *fontName, int Size,int weight);
|
|
|
|
extern void print_text(const char* string);
|
2003-10-05 05:26:59 +00:00
|
|
|
|
2003-10-15 19:08:51 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|