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 |
|
---|
22 | extern void mxgl_default_texinit(MxRaster *tex, bool will_draw_texture=true);
|
---|
23 | extern void mxgl_default_init();
|
---|
24 | extern GLenum mxgl_matrix_for_mode(GLenum mode);
|
---|
25 |
|
---|
26 | extern void mxgl_pick_begin(int x, int y, double window);
|
---|
27 | extern uint mxgl_pick_complete();
|
---|
28 |
|
---|
29 |
|
---|
30 | class MxGLPicker
|
---|
31 | {
|
---|
32 | private:
|
---|
33 | MxBlock<GLuint> buffer;
|
---|
34 |
|
---|
35 | public:
|
---|
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 | //
|
---|
47 | class MxGLMatrixCache
|
---|
48 | {
|
---|
49 | private:
|
---|
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 |
|
---|
56 | public:
|
---|
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.