source: GTP/trunk/Lib/Vis/Preprocessing/src/mixkit/MxGLUtils.h @ 1097

Revision 1097, 1.7 KB checked in by mattausch, 18 years ago (diff)
Line 
1#ifndef MXGLUTILS_INCLUDED // -*- C++ -*-
2#define MXGLUTILS_INCLUDED
3#if !defined(__GNUC__)
4#  pragma once
5#endif
6
7/************************************************************************
8
9  MxGLUtils
10
11  Copyright (C) 1998 Michael Garland.  See "COPYING.txt" for details.
12 
13  $Id: MxGLUtils.h,v 1.1 2002/09/24 16:53:54 wimmer Exp $
14
15 ************************************************************************/
16
17#include "MxBlock.h"
18#include "MxGL.h"
19#include "MxRaster.h"
20
21
22extern void mxgl_default_texinit(MxRaster *tex, bool will_draw_texture=true);
23extern void mxgl_default_init();
24extern GLenum mxgl_matrix_for_mode(GLenum mode);
25
26extern void mxgl_pick_begin(int x, int y, double window);
27extern uint mxgl_pick_complete();
28
29
30class MxGLPicker
31{
32private:
33    MxBlock<GLuint> buffer;
34
35public:
36    MxGLPicker(int x, int y, double window);
37    uint complete();
38};
39
40
41//
42// The OpenGL projection matrix stack is often very small.  For instance,
43// it's only 2 levels deep on an Impact.  So we often wind up having to
44// manage that stack manually.  And that's exactly what this little
45// class is for.
46//
47class MxGLMatrixCache
48{
49private:
50    GLdouble saved_mat[16];
51    GLenum mode, saved_mode;
52
53    void save_mode() { glGetIntegerv(GL_MATRIX_MODE, (GLint *)&saved_mode); }
54    void restore_mode() { glMatrixMode(saved_mode); }
55
56public:
57    MxGLMatrixCache(GLenum m=GL_PROJECTION) { mode=m; }
58
59    void save_matrix()
60        { glGetDoublev(mxgl_matrix_for_mode(mode), saved_mat); }
61
62    void restore_matrix()
63        {
64            save_mode();
65            glMatrixMode(mode);  glLoadMatrixd(saved_mat);
66            restore_mode();
67        }
68};
69
70
71
72
73// MXGLUTILS_INCLUDED
74#endif
Note: See TracBrowser for help on using the repository browser.