EMAN2
glutil.h
Go to the documentation of this file.
00001 
00005 /*
00006  * Author: David Woolford, 11/06/2007 (woolford@bcm.edu)
00007  * Copyright (c) 2000-2006 Baylor College of Medicine
00008  *
00009  * This software is issued under a joint BSD/GNU license. You may use the
00010  * source code in this file under either license. However, note that the
00011  * complete EMAN2 and SPARX software packages have some GPL dependencies,
00012  * so you are responsible for compliance with the licenses of these packages
00013  * if you opt to use BSD licensing. The warranty disclaimer below holds
00014  * in either instance.
00015  *
00016  * This complete copyright notice must be included in any revised version of the
00017  * source code. Additional authorship citations may be added, but existing
00018  * author citations must be preserved.
00019  *
00020  * This program is free software; you can redistribute it and/or modify
00021  * it under the terms of the GNU General Public License as published by
00022  * the Free Software Foundation; either version 2 of the License, or
00023  * (at your option) any later version.
00024  *
00025  * This program is distributed in the hope that it will be useful,
00026  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00027  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00028  * GNU General Public License for more details.
00029  *
00030  * You should have received a copy of the GNU General Public License
00031  * along with this program; if not, write to the Free Software
00032  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00033  *
00034  * */
00035 #ifndef glutil_h__
00036 #define glutil_h__
00037 
00038 #include <vector>
00039 #include "vec3.h"
00040 #include "transform.h"
00041 
00042 #ifdef __APPLE__
00043         #include "OpenGL/gl.h"
00044 #else // WIN32, LINUX
00045         #include "GL/gl.h"
00046 #endif  //__APPLE__
00047 
00048 using std::vector;
00049 
00050 namespace EMAN
00051 {
00052         class EMData;
00053         class MarchingCubes;
00054 
00055         class GLUtil {
00056         public:
00060                 static unsigned int gen_glu_mipmaps(const EMData* const emdata);
00061 
00067                 static unsigned int gen_gl_texture(const EMData* const emdata, GLenum format = GL_LUMINANCE);
00068 
00072                 static unsigned int render_amp8_gl_texture(EMData* emdata, int x0, int y0, int ixsize, int iysize, int bpl, float scale, int mingray, int maxgray,      float render_min, float render_max,float gamma,int flags);
00073 
00077                 static int nearest_projected_points(const vector<float>& model_matrix, const vector<float>& proj_matrix, const vector<int>& view_matrix, const vector<Vec3f>& points, const float mouse_x, const float mouse_y,const float& nearnes);
00078                 static void colored_rectangle(const vector<float>& data,const float& alpha, const bool center_point=false);
00079                 static void mx_bbox(const vector<float>& data, const vector<float>& text_color, const vector<float>& bg_color);
00080 
00099                 static std::string render_amp8(EMData * emdata, int x, int y, int xsize, int ysize,
00100                                                  int bpl, float scale, int min_gray, int max_gray,
00101                                                  float min_render, float max_render,float gamma,int flags);
00102 
00109                 static unsigned long get_isosurface_dl(MarchingCubes* mc, unsigned int tex_id = 0, bool surface_face_z = false, bool recontour = true);
00110                 
00112                 static void render_using_VBOs(MarchingCubes* mc, unsigned int tex_id = 0, bool surface_face_z = false);
00113                 
00115                 static void contour_isosurface(MarchingCubes* mc);
00116                 
00121                 static void glLoadMatrix(const Transform& xform);
00122                 
00127                 static void glMultMatrix(const Transform& xform);
00128                 
00130                 static void glDrawBoundingBox(float width, float height, float depth);
00131                 
00132                 static void glDrawDisk(float radius, int spokes);
00133                 
00134         private:
00135                 //This is a buffer for the bounding box
00136                 static GLuint buffer[2];
00137                 
00138         };
00139 }
00140 
00141 #endif  //glutil_h__