casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GLPCTexture.h
Go to the documentation of this file.
1 //# GLPCTexture.h: Holds data for displaying images as textures.
2 //# Copyright (C) 2001
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 
28 #ifndef TRIALDISPLAY_GLPCTEXTURE_H
29 #define TRIALDISPLAY_GLPCTEXTURE_H
30 
31 #include <graphics/X11/X_enter.h>
32 #include <GL/gl.h>
33 #include <X11/Xlib.h>
34 #include <X11/Intrinsic.h>
35 #include <graphics/X11/X_exit.h>
36 #include <casa/aips.h>
38 
39 namespace casa { //# NAMESPACE CASA - BEGIN
40 
41 // <summary>
42 // Holds parameters for setting glTexParameteri variables.
43 // </summary>
44 // <visibility=local>
45 // <synopsis>
46 // Holds parameters for setting glTexParameteri variables. See the man
47 // page for glTexParameteri for description. This class is not needed
48 // unless the caller wishes to change the defaults for a textured image.
49 // maxtexturesize is used to specify the maximum texture size used for
50 // an image. The value used will be the smallest power of 2 that
51 // is >= maxtexturesize. By default, the display hosts' maximum texture
52 // size will be used. Again, this isn't normally changed.
53 // GLPCTextureParams may be deleted after GLPCTexturedImage is created.
55  public:
59  void copy(const GLPCTextureParams &p);
61  // Set min/mag filters. If magFilter is 0, use min Filter.
62  void filter(GLint minFilter, GLint magFilter=0);
63  // Set wrap parameters. If wrapT is 0, use wrapS.
64  void wrap(GLint wrapS, GLint wrapT=0);
65 
66  // Set value to use for max texture size. Value will be rounded
67  // up to a power of 2 >= maxTextureSize.
68  void maxTextureSize(GLint maxtexturesize);
69  void format(GLenum fmt);
70 
71  // For glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, mode);
72  void environMode(GLenum mode);
73  public:
74  // glTexParameteri(GL_TEXTURE_2D, x, y).
75  GLint min_filter_; // GL_TEXTURE_MIN_FILTER
76  GLint mag_filter_; // GL_TEXTURE_MAG_FILTER
77  GLint wrap_s_; // GL_TEXTURE_WRAP_S
78  GLint wrap_t_; // GL_TEXTURE_WRAP_T
79 
80  // Maximum texture size to use. Default is host's max texture size.
82  GLenum envmode_; // GL_DECAL, GL_BLEND or GL_MODULATE.
83  GLenum format_; // GL_RGB or GL_COLOR_INDEX.
84  private:
85  void init();
86  };
87 
88  class GLPCTextureObject;
89 
90 // <prerequisite>
91 // <li> <linkto class="GLPCDisplayListEntry">GLPCDisplayListEntry</linkto>
92 // </prerequisite>
93 // <synopsis>
94 // GLPCTexturedImage is used to convert an image to texture objects for
95 // display. The pixels array contains pixels stored as RGB triples.
96 // This class is typically only used by
97 // <linkto class="GLPixelCanvas">GLPixelCanvas</linkto>
98 // If the image is larger than the maximum texture size, it will be broken
99 // into pieces that fit.
100 // </synopsis>
101 //<thrown><li> casacore::AipsError </thrown>
103  public:
104  GLPCTexturedImage(GLsizei width, GLsizei height,
105  const GLushort *pixels,
106  const GLPCTextureParams* = NULL);
108  void draw(); // Draw image using current values.
109  // Draw image and save values for later.
110  void draw(GLfloat x, GLfloat y, GLfloat z=0.0,
111  GLfloat xscale=1.0, GLfloat yscale=1.0);
112 
113  void envmode(GLenum mode);
114  GLenum envmode()const {
115  return params_->envmode_;
116  }
118  return params_;
119  }
120  private:
121  void createTextures(GLsizei dWidth, GLsizei dHeight);
122  void storeImage(GLsizei dWidth, GLsizei dHeight,
123  const GLushort *pixels);
124  int ntx_, nty_;
125  int numTextures_; // ntx_*nty_;
126  GLPCTextureObject **textures_; // numtexures entries.
127  GLfloat x_, y_, z_;
128  GLfloat xscale_, yscale_;
129  GLsizei dWidth_, dHeight_;
132  };
133 
134 
135 } //# NAMESPACE CASA - END
136 
137 #endif
GLuint maxtexturesize_
Maximum texture size to use.
Definition: GLPCTexture.h:81
GLPCTexturedImage(GLsizei width, GLsizei height, const GLushort *pixels, const GLPCTextureParams *=NULL)
void wrap(GLint wrapS, GLint wrapT=0)
Set wrap parameters.
void copy(const GLPCTextureParams &p)
void format(GLenum fmt)
GLPCTextureObject ** textures_
Definition: GLPCTexture.h:126
Holds parameters for setting glTexParameteri variables. &lt;visibility=local&gt;
Definition: GLPCTexture.h:54
void environMode(GLenum mode)
For glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, mode);.
GLPCTextureParams * params_
Definition: GLPCTexture.h:130
void filter(GLint minFilter, GLint magFilter=0)
Set min/mag filters.
Returns a Display casacore::List Element for recording GL commands.
void createTextures(GLsizei dWidth, GLsizei dHeight)
GLPCTextureParams * params() const
Definition: GLPCTexture.h:117
void maxTextureSize(GLint maxtexturesize)
Set value to use for max texture size.
void storeImage(GLsizei dWidth, GLsizei dHeight, const GLushort *pixels)
GLint min_filter_
glTexParameteri(GL_TEXTURE_2D, x, y).
Definition: GLPCTexture.h:75
GLenum envmode() const
Definition: GLPCTexture.h:114