1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412
|
/*
A* -------------------------------------------------------------------
B* This file contains source code for the PyMOL computer program
C* copyright 1998-2000 by Warren Lyford Delano of DeLano Scientific.
D* -------------------------------------------------------------------
E* It is unlawful to modify or remove this copyright notice.
F* -------------------------------------------------------------------
G* Please see the accompanying LICENSE file for further information.
H* -------------------------------------------------------------------
I* Additional authors of this source file include:
-*
-*
-*
Z* -------------------------------------------------------------------
*/
#ifndef _H_CGO
#define _H_CGO
#include"Base.h"
#include"Ray.h"
#include"Setting.h"
#include"os_gl.h"
#include"Rep.h"
#include"ObjectGadgetRamp.h"
/* Compiled Graphics Library for simple graphics objects
in floating point three-space, with the goal of achieving
quick and easy rendering in multiple environments without the
headaches of OpenGL arrays.
*/
#define CGO_read_int(p) (*((int*)((p)++)))
#define CGO_get_int(p) (*((int*)(p)))
#define CGO_get_uint(p) (uint)(*((int*)(p)))
#define CGO_write_int(p,i) ((*((int*)(p++)))=(i))
#define CGO_put_int(p,i) ((*((int*)(p)))=(i))
/* Supported functions:
* stop
* null
* begin
GL_POINTS,
GL_LINES, GL_LINE_LOOP, GL_LINE_STRIP,
GL_TRIANGLES, GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN
* end
* vertex
* normal
* color
* sphere * currently for ray-tracing only
* triangle * currently for ray-tracing only
* cylinder * currently for ray-tracing only
* linewidth
* primwidth * ray-tracing
*/
#include "CGOStruct.h"
/* instructions and data segment sizes */
#define CGO_STOP 0x00
#define CGO_STOP_SZ 0
#define CGO_NULL 0x01
#define CGO_NULL_SZ 0
#define CGO_BEGIN 0x02
#define CGO_BEGIN_SZ 1
#define CGO_END 0x03
#define CGO_END_SZ 0
#define CGO_VERTEX 0x04
#define CGO_VERTEX_SZ 3
#define CGO_NORMAL 0x05
#define CGO_NORMAL_SZ 3
#define CGO_COLOR 0x06
#define CGO_COLOR_SZ 3
#define CGO_SPHERE 0x07
#define CGO_SPHERE_SZ 4
#define CGO_TRIANGLE 0x08
#define CGO_TRIANGLE_SZ 27
#define CGO_CYLINDER 0x09
#define CGO_CYLINDER_SZ 13
#define CGO_LINEWIDTH 0x0A
#define CGO_LINEWIDTH_SZ 1
#define CGO_WIDTHSCALE 0x0B
#define CGO_WIDTHSCALE_SZ 1
#define CGO_ENABLE 0x0C
#define CGO_ENABLE_SZ 1
#define CGO_DISABLE 0x0D
#define CGO_DISABLE_SZ 1
#define CGO_SAUSAGE 0x0E
#define CGO_SAUSAGE_SZ 13
#define CGO_CUSTOM_CYLINDER 0x0F
#define CGO_CUSTOM_CYLINDER_SZ 15
#define CGO_DOTWIDTH 0x10
#define CGO_DOTWIDTH_SZ 1
#define CGO_ALPHA_TRIANGLE 0x11
#define CGO_ALPHA_TRIANGLE_SZ 35
#define CGO_ELLIPSOID 0x12
#define CGO_ELLIPSOID_SZ 13
#define CGO_FONT 0x13
#define CGO_FONT_SZ 3 /* size, face, style */
#define CGO_FONT_SCALE 0x14
#define CGO_FONT_SCALE_SZ 2
#define CGO_FONT_VERTEX 0x15
#define CGO_FONT_VERTEX_SZ 3 /* principle axes (zeros -> use camera x y z */
#define CGO_FONT_AXES 0x16
#define CGO_FONT_AXES_SZ 9 /* principle axes (zeros -> use camera x y z */
#define CGO_CHAR 0x17
#define CGO_CHAR_SZ 1
#define CGO_INDENT 0x18
#define CGO_INDENT_SZ 2
#define CGO_ALPHA 0x19
#define CGO_ALPHA_SZ 1
#define CGO_QUADRIC 0x1A
#define CGO_QUADRIC_SZ 14
#define CGO_CONE 0x1B
#define CGO_CONE_SZ 16
#define CGO_RESET_NORMAL 0x1E
#define CGO_RESET_NORMAL_SZ 1
#define CGO_PICK_COLOR 0x1F
#define CGO_PICK_COLOR_SZ 2
/* CGO_DRAW_ARRAYS : operation that calls glDrawArrays with all arrays in memory
(i.e., stored in the CGO array). There can be up to 4 arrays (vertex, normal, color,
and pick color array, where each are stored using GL_FLOAT array (except for the pick
color array, which is GL_UNSIGNED_BYTE, because the 2nd 2/3rds of the array is used to
store atom/bond picking information. Also, the color array is stored using 4 floats,
since glColorPointer() requires having 4 as an argument for OpenGLES.
- mode : GL Mode that is used
- arrays : which arrays that are used (bitmask on CGO_<type>_ARRAY, where <type>
can be VERTEX, NORMAL, COLOR, or PICK_COLOR)
- narrays : number of arrays specified in arrays
- nverts : number of total vertices specified in arrays
- each GL_FLOAT array specified in order
*/
#define CGO_DRAW_ARRAYS 0x1C
#define CGO_DRAW_ARRAYS_SZ 0
#define CGO_DRAW_ARRAYS_HEADER 4
/* CGO_DRAW_BUFFERS : operation that uses glDrawArrays with VBOs. This is not currently
used, since CGO_DRAW_BUFFERS_INDEXED is a bit more flexible where an index can be specified
for vertex order. However, this is useful for when all primitives are defined only once
and an index is not needed.
This operation is similar to CGO_DRAW_ARRAYS except since it is using VBOs, the length
of the operation is constant (i.e., 8 floats, CGO_DRAW_BUFFERS_SZ). The VBO ids are stored
and are used to manage the data inside the buffers using glBindBuffer()/glBufferData()
- mode : GL Mode that is used
- arrays : which arrays that are used (bitmask on CGO_<type>_ARRAY, where <type>
can be VERTEX, NORMAL, COLOR, or PICK_COLOR)
- narrays : number of arrays specified in arrays
- nverts : number of total vertices specified in arrays
- bufs[4] : each VBO id in order (if used, VERTEX, NORMAL, COLOR, PICK_COLOR)
*/
#define CGO_DRAW_BUFFERS 0x20
#define CGO_DRAW_BUFFERS_SZ 8
/* CGO_DRAW_BUFFERS_INDEXED : operation that uses glDrawArrays with VBOs. It also
has a dynamic length since it holds the picking information (atom/bond) for each vertex,
as well as space for picking to use when drawing colors (since colors are dynamically generated
for each atom/bond value).
- mode : GL Mode that is used
- arrays : which arrays that are used (bitmask on CGO_<type>_ARRAY, where <type>
can be VERTEX, NORMAL, COLOR, or PICK_COLOR)
- narrays : number of arrays specified in arrays
- nverts : number of total vertices specified in arrays
- bufs[5] : each VBO id in order (if used, VERTEX, NORMAL, COLOR, PICK_COLOR), plus the
vertex index array that specifies all vertices.
*/
#define CGO_DRAW_BUFFERS_INDEXED 0x21
#define CGO_DRAW_BUFFERS_INDEXED_SZ 0
/* CGO_BOUNDING_BOX : operation that allows the extent to be expanded. Since the geometry
data is not kept in the CGO object for VBO objects (only on the card), this object allows
the bounding box of the object to be saved in the CGO. This is used in the CGOGetExtent(),
typically when the view is being automatically set, but can be used for other things.
*/
#define CGO_BOUNDING_BOX 0x22
#define CGO_BOUNDING_BOX_SZ 6
#define CGO_DRAW_BUFFERS_NOT_INDEXED 0x23
#define CGO_DRAW_BUFFERS_NOT_INDEXED_SZ 0
#define CGO_LINEWIDTH_SPECIAL 0x24
#define CGO_LINEWIDTH_SPECIAL_SZ 1
#define CGO_DRAW_CYLINDER_BUFFERS 0x25
#define CGO_DRAW_CYLINDER_BUFFERS_SZ 7
#define CGO_SHADER_CYLINDER 0x26
#define CGO_SHADER_CYLINDER_SZ 8
#define CGO_SHADER_CYLINDER_WITH_2ND_COLOR 0x27
#define CGO_SHADER_CYLINDER_WITH_2ND_COLOR_SZ 11
#define CGO_DRAW_SPHERE_BUFFERS 0x28
#define CGO_DRAW_SPHERE_BUFFERS_SZ 5
#define CGO_ACCESSIBILITY 0x29
#define CGO_ACCESSIBILITY_SZ 1
#define CGO_DRAW_TEXTURE 0x2A
#define CGO_DRAW_TEXTURE_SZ 13
#define CGO_DRAW_TEXTURES 0x2B
#define CGO_DRAW_TEXTURES_SZ 0
#define CGO_DRAW_SCREEN_TEXTURES_AND_POLYGONS 0x2C
#define CGO_DRAW_SCREEN_TEXTURES_AND_POLYGONS_SZ 4
#define CGO_TEX_COORD 0x2D
#define CGO_TEX_COORD_SZ 2
#define CGO_DRAW_LABEL 0x2E
#ifdef PYMOL_TEXT_IN_ONE_TEXTURE
#define CGO_DRAW_LABEL_SZ 16
#else
#define CGO_DRAW_LABEL_SZ 19
#endif
#define CGO_DRAW_LABELS 0x2F
#define CGO_DRAW_LABELS_SZ 0
#define CGO_MASK 0x3F
#define CGO_LIGHTING 0x0B50
#define CGO_VERTEX_ARRAY 0x01
#define CGO_NORMAL_ARRAY 0x02
#define CGO_COLOR_ARRAY 0x04
#define CGO_PICK_COLOR_ARRAY 0x08
#define CGO_ACCESSIBILITY_ARRAY 0x10
#define CGO_TEX_COORD_ARRAY 0x20
int CGORendererInit(PyMOLGlobals * G);
void CGORendererFree(PyMOLGlobals * G);
CGO *CGONew(PyMOLGlobals * G);
CGO *CGONewSized(PyMOLGlobals * G, int size);
int CGOGetExtent(CGO * I, float *mn, float *mx);
int CGOHasNormals(CGO * I);
void CGOFreeWithoutVBOs(CGO * I);
void CGOFree(CGO * &I);
void CGOFreeImpl(CGO * I, short withVBOs);
CGO *CGODrawText(CGO * I, int est, float *camera);
CGO *CGOSimplify(CGO * I, int est);
bool CGOCombineBeginEnd(CGO ** I, bool do_not_split_lines = false);
CGO *CGOCombineBeginEnd(CGO * I, int est);
void CGOFreeVBOs(CGO *I);
CGO *CGOOptimizeToVBOIndexedWithColor(CGO * I, int est, float *color);
CGO *CGOOptimizeToVBOIndexedNoShader(CGO * I, int est);
CGO *CGOOptimizeToVBOIndexed(CGO * I, int est);
CGO *CGOOptimizeToVBONotIndexedWithReturnedData(CGO * I, int est, short, float **);
CGO *CGOOptimizeToVBONotIndexed(CGO * I, int est);
CGO *CGOOptimizeSpheresToVBONonIndexedImpl(CGO * I, int est, CGO *leftOverCGO);
CGO *CGOOptimizeSpheresToVBONonIndexed(CGO * I, int est=0, bool addshaders=false, CGO *leftOverCGO=NULL);
#define CGOOptimizeSpheresToVBONonIndexedNoShader(I, est) CGOOptimizeSpheresToVBONonIndexed(I, est, false, NULL)
void CGOReserve(CGO * ptr, int est);
int CGOCheckComplex(CGO * I);
int CGOPreloadFonts(CGO * I);
int CGOCheckForText(CGO * I);
int CGOFromFloatArray(CGO * I, const float *src, int len);
int CGOBegin(CGO * I, int mode);
int CGOEnd(CGO * I);
int CGOSphere(CGO * I, const float *v1, float r);
int CGOEllipsoid(CGO * I, const float *v1, float r, const float *n1, const float *n2, const float *n3);
int CGOQuadric(CGO * I, const float *v1, float r, const float *p); /* NOT WORKING YET */
int CGOSausage(CGO * I, const float *v1, const float *v2, float r, const float *c1, const float *c2);
int CGOVertex(CGO * I, float v1, float v2, float v3);
int CGOVertexv(CGO * I, const float *v);
int CGOAlpha(CGO * I, float alpha);
int CGOColor(CGO * I, float v1, float v2, float v3);
int CGOColorv(CGO * I, const float *v);
int CGOTexCoord2f(CGO * I, float v1, float v2);
int CGOTexCoord2fv(CGO * I, const float *v);
int CGONormal(CGO * I, float v1, float v2, float v3);
int CGONormalv(CGO * I, const float *v);
int CGOResetNormal(CGO * I, int mode);
int CGOLinewidth(CGO * I, float v);
int CGOLinewidthSpecial(CGO * I, int v);
#define LINEWIDTH_DYNAMIC_WITH_SCALE 1
#define LINEWIDTH_DYNAMIC_MESH 2
#define POINTSIZE_DYNAMIC_DOT_WIDTH 3
#define LINEWIDTH_DYNAMIC_WITH_SCALE_RIBBON 4
#define LINEWIDTH_DYNAMIC_WITH_SCALE_DASH 5
#define CYLINDERWIDTH_DYNAMIC_MESH 6
#define LINEWIDTH_WITH_SCALE 7
int CGODotwidth(CGO * I, float v);
int CGOChar(CGO * I, char c);
int CGOFontVertex(CGO * I, float x, float y, float z);
int CGOFontVertexv(CGO * I, const float *v);
int CGOFontScale(CGO * I, float v1, float v2);
int CGOIndent(CGO * I, char c, float dir);
int CGOWrite(CGO * I, const char *str);
int CGOWriteLeft(CGO * I, const char *str);
int CGOWriteIndent(CGO * I, const char *str, float indent);
GLfloat *CGODrawArrays(CGO *I, GLenum mode, short arrays, int nverts);
int CGODrawBuffers(CGO *I, GLenum mode, short arrays, int nverts, uint *bufs);
GLfloat *CGODrawBuffersIndexed(CGO *I, GLenum mode, short arrays, int nindices, int nverts, uint *bufs);
int CGOBoundingBox(CGO *I, float *min, float *max);
int CGOAccessibility(CGO * I, float a);
int CGODrawTexture(CGO *I, int texture_id, float *worldPos, float *screenMin, float *screenMax, float *textExtent);
int CGODrawLabel(CGO *I, int texture_id, float *worldPos, float *screenWorldOffset, float *screenMin, float *screenMax, float *textExtent);
CGO *CGOOptimizeLabels(CGO * I, int est);
CGO *CGOOptimizeTextures(CGO * I, int est);
CGO *CGOExpandDrawTextures(CGO * I, int est);
/*void CGOFontScale(CGO *I,float v);
void CGOFont(CGO *I,float size,int face,int style);*/
int CGOEnable(CGO * I, int mode);
int CGODisable(CGO * I, int mode);
int CGOStop(CGO * I);
int CGOCylinderv(CGO * I, const float *p1, const float *p2, float r, const float *c1, const float *c2);
int CGOCustomCylinderv(CGO * I, const float *p1, const float *p2, float r, const float *c1, const float *c2,
float cap1, float cap2);
int CGOConev(CGO * I, const float *p1, const float *p2, float r1, float r2, const float *c1, const float *c2,
float cap1, float cap2);
int CGOAlphaTriangle(CGO * I,
const float *v1, const float *v2, const float *v3,
const float *n1, const float *n2, const float *n3,
const float *c1, const float *c2, const float *c3,
float a1, float a2, float a3, int reverse);
void CGOSetZVector(CGO * I, float z0, float z1, float z2);
void CGORenderGLPicking(CGO * I, Picking ** pick,
PickContext * context, CSetting * set1, CSetting * set2);
void CGORenderGL(CGO * I, const float *color, CSetting * set1, CSetting * set2,
RenderInfo * info, Rep *rep);
void CGORenderGLAlpha(CGO * I, RenderInfo * info);
int CGORenderRay(CGO * I, CRay * ray, const float *color, CSetting * set1, CSetting * set2);
void CGOReset(CGO * I);
void CGOSetUseShader(CGO *I, int use_shader);
PyObject *CGOAsPyList(CGO * I);
CGO *CGONewFromPyList(PyMOLGlobals * G, PyObject * list, int version);
void SetCGOPickColor(float *colorVals, int nverts, int pl, int index, int bond);
int CGOPickColor(CGO * I, int index, int bond);
float *CGO_add_GLfloat(CGO * I, int c);
float *CGOGetNextDrawBufferedIndex(float *cgo_op);
float *CGOGetNextDrawBufferedNotIndex(float *cgo_op);
float *CGOGetNextDrawBufferedImpl(float *cgo_op, int optype);
float *CGOGetNextOp(float *cgo_op, int optype);
int CGOAppendNoStop(CGO *dest, CGO *source);
int CGOAppend(CGO *dest, CGO *source);
CGO *CGOOptimizeGLSLCylindersToVBOIndexed(CGO * I, int est);
CGO *CGOOptimizeGLSLCylindersToVBOIndexedWithLeftOver(CGO * I, int est, CGO *leftOverCGO);
CGO *CGOOptimizeGLSLCylindersToVBOIndexedNoColor(CGO * I, int est);
int CGOShaderCylinder(CGO *I, const float *origin, const float *axis, float tube_size, int cap);
int CGOShaderCylinder2ndColor(CGO *I, const float *origin, const float *axis, float tube_size, int cap, const float *color2);
int CGOCountNumberOfOperationsOfTypeDEBUG(CGO *I, int optype);
int CGOCountNumberOfOperationsOfType(CGO *I, int op);
short CGOHasOperationsOfType(const CGO *I, int op);
short CGOHasOperationsOfType2(CGO *I, int op1, int op2);
short CGOHasCylinderOperations(CGO *I);
bool CGOHasSphereOperations(const CGO *I);
short CGOCheckWhetherToFree(PyMOLGlobals * G, CGO *I);
CGO *CGOConvertLinesToShaderCylinders(CGO * I, int est);
int CGOChangeShadersTo(CGO *I, int frommode, int tomode);
void CGOCountNumVerticesDEBUG(CGO *I);
CGO *CGOOptimizeScreenTexturesAndPolygons(CGO * I, int est);
#define CGOLineAsTriangleStrips(CGO, minx, miny, maxx, maxy) \
CGOBegin(CGO, GL_TRIANGLE_STRIP); \
CGOVertex(CGO, minx, miny, 0.f); \
CGOVertex(CGO, minx, maxy+1, 0.f); \
CGOVertex(CGO, minx+1, miny, 0.f); \
CGOVertex(CGO, minx+1, maxy+1, 0.f); \
CGOEnd(CGO); \
CGOBegin(CGO, GL_TRIANGLE_STRIP); \
CGOVertex(CGO, minx, maxy, 0.f); \
CGOVertex(CGO, minx, maxy+1, 0.f); \
CGOVertex(CGO, maxx, maxy, 0.f); \
CGOVertex(CGO, maxx, maxy+1, 0.f); \
CGOEnd(CGO); \
CGOBegin(CGO, GL_TRIANGLE_STRIP); \
CGOVertex(CGO, maxx, miny, 0.f); \
CGOVertex(CGO, maxx, maxy+1, 0.f); \
CGOVertex(CGO, maxx+1, miny, 0.f); \
CGOVertex(CGO, maxx+1, maxy+1, 0.f); \
CGOEnd(CGO); \
CGOBegin(CGO, GL_TRIANGLE_STRIP); \
CGOVertex(CGO, minx, miny, 0.f); \
CGOVertex(CGO, minx, miny+1, 0.f); \
CGOVertex(CGO, maxx, miny, 0.f); \
CGOVertex(CGO, maxx, miny+1, 0.f); \
CGOEnd(CGO);
#endif
|