annotate src/gl-render.cc @ 8377:25bc2d31e1bf

improve OCTAVE_LOCAL_BUFFER
author Jaroslav Hajek <highegg@gmail.com>
date Wed, 29 Oct 2008 16:52:10 +0100
parents 22c078fd926b
children 0d263850d582
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1 /*
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3 Copyright (C) 2008 Michael Goffioul
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
4
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
5 This file is part of Octave.
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
6
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
10 option) any later version.
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
11
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
15 for more details.
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
16
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
18 along with Octave; see the file COPYING. If not, see
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
19 <http://www.gnu.org/licenses/>.
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
20
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
21 */
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
22
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
23 #ifdef HAVE_CONFIG_H
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
24 #include <config.h>
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
25 #endif
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
26
7954
3ffc34caec65 configure fixes
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
27 #if defined (HAVE_OPENGL)
3ffc34caec65 configure fixes
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
28
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
29 #include <lo-mappers.h>
8377
25bc2d31e1bf improve OCTAVE_LOCAL_BUFFER
Jaroslav Hajek <highegg@gmail.com>
parents: 8263
diff changeset
30 #include "oct-locbuf.h"
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
31 #include "gl-render.h"
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
32
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
33 #define LIGHT_MODE GL_FRONT_AND_BACK
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
34
7833
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
35 // Win32 API requires the CALLBACK attributes for
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
36 // GLU callback functions. Define it to empty on
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
37 // other platforms.
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
38 #ifndef CALLBACK
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
39 #define CALLBACK
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
40 #endif
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
41
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
42 enum {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
43 AXE_ANY_DIR = 0,
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
44 AXE_DEPTH_DIR = 1,
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
45 AXE_HORZ_DIR = 2,
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
46 AXE_VERT_DIR = 3
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
47 };
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
48
7870
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
49 static octave_idx_type
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
50 xmin (octave_idx_type x, octave_idx_type y)
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
51 {
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
52 return x < y ? x : y;
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
53 }
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
54
7833
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
55 class
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
56 opengl_texture
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
57 {
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
58 protected:
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
59 class texture_rep
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
60 {
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
61 public:
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
62 texture_rep (void) : valid (false), count (1) { }
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
63
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
64 texture_rep (GLuint _id, int _w, int _h, int _tw, int _th)
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
65 : id (_id), w (_w), h (_h), tw (_tw), th (_th),
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
66 tx (double(w)/tw), ty (double(h)/th), valid (true),
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
67 count (1) { }
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
68
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
69 ~texture_rep (void)
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
70 {
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
71 if (valid)
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
72 glDeleteTextures (1, &id);
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
73 }
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
74
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
75 void bind (int mode) const
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
76 { if (valid) glBindTexture (mode, id); }
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
77
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
78 void tex_coord (double q, double r) const
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
79 { if (valid) glTexCoord2d (q*tx, r*ty); }
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
80
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
81 GLuint id;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
82 int w, h;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
83 int tw, th;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
84 double tx, ty;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
85 bool valid;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
86 int count;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
87 };
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
88
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
89 texture_rep *rep;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
90
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
91 private:
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
92 opengl_texture (texture_rep *_rep) : rep (_rep) { }
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
93
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
94 public:
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
95 opengl_texture (void) : rep (new texture_rep ()) { }
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
96
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
97 opengl_texture (const opengl_texture& tx)
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
98 : rep (tx.rep)
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
99 {
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
100 rep->count++;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
101 }
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
102
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
103 ~opengl_texture (void)
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
104 {
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
105 if (--rep->count == 0)
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
106 delete rep;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
107 }
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
108
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
109 opengl_texture& operator = (const opengl_texture& tx)
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
110 {
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
111 if (--rep->count == 0)
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
112 delete rep;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
113
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
114 rep = tx.rep;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
115 rep->count++;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
116
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
117 return *this;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
118 }
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
119
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
120 static opengl_texture create (const octave_value& data);
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
121
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
122 void bind (int mode = GL_TEXTURE_2D) const
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
123 { rep->bind (mode); }
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
124
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
125 void tex_coord (double q, double r) const
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
126 { rep->tex_coord (q, r); }
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
127
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
128 bool is_valid (void) const
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
129 { return rep->valid; }
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
130 };
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
131
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
132 static int
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
133 next_power_of_2 (int n)
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
134 {
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
135 int m = 1;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
136
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
137 while (m < n && m < INT_MAX)
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
138 m <<= 1;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
139
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
140 return m;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
141 }
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
142
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
143 opengl_texture
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
144 opengl_texture::create (const octave_value& data)
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
145 {
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
146 opengl_texture retval;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
147
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
148 dim_vector dv (data.dims ());
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
149
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
150 // Expect RGB data
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
151 if (dv.length () == 3 && dv(2) == 3)
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
152 {
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
153 int h = dv(0), w = dv(1), tw, th;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
154 GLuint id;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
155 bool ok = true;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
156
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
157 tw = next_power_of_2 (w);
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
158 th = next_power_of_2 (w);
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
159
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
160 glGenTextures (1, &id);
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
161 glBindTexture (GL_TEXTURE_2D, id);
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
162
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
163 if (data.is_double_type ())
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
164 {
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
165 NDArray _a = data.array_value ();
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
166
7833
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
167 OCTAVE_LOCAL_BUFFER (float, a, (3*tw*th));
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
168
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
169 for (int i = 0; i < h; i++)
7833
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
170 for (int j = 0, idx = i*tw*3; j < w; j++, idx += 3)
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
171 {
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
172 a[idx] = _a(i,j,0);
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
173 a[idx+1] = _a(i,j,1);
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
174 a[idx+2] = _a(i,j,2);
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
175 }
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
176
7833
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
177 glTexImage2D (GL_TEXTURE_2D, 0, 3, tw, th, 0,
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
178 GL_RGB, GL_FLOAT, a);
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
179 }
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
180 else if (data.is_uint8_type ())
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
181 {
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
182 uint8NDArray _a = data.uint8_array_value ();
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
183
7833
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
184 OCTAVE_LOCAL_BUFFER (octave_uint8, a, (3*tw*th));
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
185
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
186 for (int i = 0; i < h; i++)
7833
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
187 for (int j = 0, idx = i*tw*3; j < w; j++, idx += 3)
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
188 {
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
189 a[idx] = _a(i,j,0);
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
190 a[idx+1] = _a(i,j,1);
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
191 a[idx+2] = _a(i,j,2);
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
192 }
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
193
7833
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
194 glTexImage2D (GL_TEXTURE_2D, 0, 3, tw, th, 0,
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
195 GL_RGB, GL_UNSIGNED_BYTE, a);
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
196 }
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
197 else
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
198 {
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
199 ok = false;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
200 warning ("opengl_texture::create: invalid texture data type (expected double or uint8)");
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
201 }
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
202
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
203 if (ok)
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
204 {
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
205 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
206 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
207
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
208 if (glGetError () != GL_NO_ERROR)
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
209 warning ("opengl_texture::create: OpenGL error while generating texture data");
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
210 else
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
211 retval = opengl_texture (new texture_rep (id, w, h, tw, th));
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
212 }
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
213 }
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
214 else
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
215 warning ("opengl_texture::create: invalid texture data size");
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
216
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
217 return retval;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
218 }
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
219
7833
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
220 class
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
221 opengl_tesselator
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
222 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
223 public:
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
224 typedef void (CALLBACK *fcn) (void);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
225
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
226 public:
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
227
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
228 opengl_tesselator (void) : glu_tess (0) { init (); }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
229
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
230 virtual ~opengl_tesselator (void)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
231 { if (glu_tess) gluDeleteTess (glu_tess); }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
232
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
233 void begin_polygon (bool filled = true)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
234 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
235 gluTessProperty (glu_tess, GLU_TESS_BOUNDARY_ONLY,
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
236 (filled ? GL_FALSE : GL_TRUE));
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
237 fill = filled;
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
238 gluTessBeginPolygon (glu_tess, this);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
239 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
240
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
241 void end_polygon (void) const
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
242 { gluTessEndPolygon (glu_tess); }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
243
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
244 void begin_contour (void) const
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
245 { gluTessBeginContour (glu_tess); }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
246
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
247 void end_contour (void) const
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
248 { gluTessEndContour (glu_tess); }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
249
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
250 void add_vertex (double *loc, void *data) const
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
251 { gluTessVertex (glu_tess, loc, data); }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
252
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
253 protected:
7870
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
254 virtual void begin (GLenum /*type*/) { }
7833
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
255
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
256 virtual void end (void) { }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
257
7870
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
258 virtual void vertex (void */*data*/) { }
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
259
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
260 virtual void combine (GLdouble /*c*/[3], void */*data*/[4],
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
261 GLfloat /*w*/[4], void **/*out_data*/) { }
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
262
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
263 virtual void edge_flag (GLboolean /*flag*/) { }
7833
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
264
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
265 virtual void error (GLenum err)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
266 { ::error ("OpenGL tesselation error (%d)", err); }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
267
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
268 virtual void init (void)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
269 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
270 glu_tess = gluNewTess ();
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
271
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
272 gluTessCallback (glu_tess, GLU_TESS_BEGIN_DATA,
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
273 reinterpret_cast<fcn> (tess_begin));
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
274 gluTessCallback (glu_tess, GLU_TESS_END_DATA,
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
275 reinterpret_cast<fcn> (tess_end));
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
276 gluTessCallback (glu_tess, GLU_TESS_VERTEX_DATA,
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
277 reinterpret_cast<fcn> (tess_vertex));
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
278 gluTessCallback (glu_tess, GLU_TESS_COMBINE_DATA,
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
279 reinterpret_cast<fcn> (tess_combine));
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
280 gluTessCallback (glu_tess, GLU_TESS_EDGE_FLAG_DATA,
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
281 reinterpret_cast<fcn> (tess_edge_flag));
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
282 gluTessCallback (glu_tess, GLU_TESS_ERROR_DATA,
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
283 reinterpret_cast<fcn> (tess_error));
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
284 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
285
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
286 bool is_filled (void) const { return fill; }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
287
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
288 private:
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
289 static void CALLBACK tess_begin (GLenum type, void *t)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
290 { reinterpret_cast<opengl_tesselator *> (t)->begin (type); }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
291
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
292 static void CALLBACK tess_end (void *t)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
293 { reinterpret_cast<opengl_tesselator *> (t)->end (); }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
294
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
295 static void CALLBACK tess_vertex (void *v, void *t)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
296 { reinterpret_cast<opengl_tesselator *> (t)->vertex (v); }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
297
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
298 static void CALLBACK tess_combine (GLdouble c[3], void *v[4], GLfloat w[4],
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
299 void **out, void *t)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
300 { reinterpret_cast<opengl_tesselator *> (t)->combine (c, v, w, out); }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
301
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
302 static void CALLBACK tess_edge_flag (GLboolean flag, void *t)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
303 { reinterpret_cast<opengl_tesselator *> (t)->edge_flag (flag); }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
304
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
305 static void CALLBACK tess_error (GLenum err, void *t)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
306 { reinterpret_cast<opengl_tesselator *> (t)->error (err); }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
307
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
308 private:
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
309 GLUtesselator *glu_tess;
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
310 bool fill;
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
311 };
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
312
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
313 class
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
314 vertex_data
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
315 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
316 public:
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
317 class vertex_data_rep
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
318 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
319 public:
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
320 Matrix coords;
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
321 Matrix color;
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
322 Matrix normal;
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
323 double alpha;
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
324 float ambient;
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
325 float diffuse;
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
326 float specular;
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
327 float specular_exp;
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
328
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
329 // reference counter
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
330 int count;
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
331
7904
1fddd9b8e862 Fix nil_rep reference counting in gl-render.cc::vertex_data internal class
John W. Eaton <jwe@octave.org>
parents: 7874
diff changeset
332 vertex_data_rep (void) : count (1) { }
7833
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
333
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
334 vertex_data_rep (const Matrix& c, const Matrix& col, const Matrix& n,
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
335 double a, float as, float ds, float ss, float se)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
336 : coords (c), color (col), normal (n), alpha (a),
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
337 ambient (as), diffuse (ds), specular (ss), specular_exp (se),
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
338 count (1) { }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
339 };
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
340
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
341 private:
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
342 vertex_data_rep *rep;
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
343
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
344 vertex_data_rep *nil_rep (void) const
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
345 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
346 static vertex_data_rep *nr = new vertex_data_rep ();
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
347
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
348 return nr;
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
349 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
350
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
351 public:
7904
1fddd9b8e862 Fix nil_rep reference counting in gl-render.cc::vertex_data internal class
John W. Eaton <jwe@octave.org>
parents: 7874
diff changeset
352 vertex_data (void) : rep (nil_rep ())
1fddd9b8e862 Fix nil_rep reference counting in gl-render.cc::vertex_data internal class
John W. Eaton <jwe@octave.org>
parents: 7874
diff changeset
353 { rep->count++; }
7833
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
354
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
355 vertex_data (const vertex_data& v) : rep (v.rep)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
356 { rep->count++; }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
357
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
358 vertex_data (const Matrix& c, const Matrix& col, const Matrix& n,
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
359 double a, float as, float ds, float ss, float se)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
360 : rep (new vertex_data_rep (c, col, n, a, as, ds, ss, se))
7904
1fddd9b8e862 Fix nil_rep reference counting in gl-render.cc::vertex_data internal class
John W. Eaton <jwe@octave.org>
parents: 7874
diff changeset
361 { }
7833
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
362
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
363 vertex_data (vertex_data_rep *new_rep)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
364 : rep (new_rep) { }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
365
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
366 ~vertex_data (void)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
367 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
368 if (--rep->count == 0)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
369 delete rep;
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
370 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
371
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
372 vertex_data& operator = (const vertex_data& v)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
373 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
374 if (--rep->count == 0)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
375 delete rep;
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
376
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
377 rep = v.rep;
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
378 rep->count++;
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
379
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
380 return *this;
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
381 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
382
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
383 vertex_data_rep *get_rep (void) const { return rep; }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
384 };
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
385
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
386 class
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
387 opengl_renderer::patch_tesselator : public opengl_tesselator
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
388 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
389 public:
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
390 patch_tesselator (opengl_renderer *r, int cmode, int lmode, int idx = 0)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
391 : opengl_tesselator (), renderer (r),
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
392 color_mode (cmode), light_mode (lmode), index (idx),
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
393 first (true) { }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
394
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
395 protected:
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
396 void begin (GLenum type)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
397 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
398 //printf("patch_tesselator::begin (%d)\n", type);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
399 first = true;
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
400
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
401 if (color_mode == 2 || light_mode == 2)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
402 glShadeModel (GL_SMOOTH);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
403 else
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
404 glShadeModel (GL_FLAT);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
405
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
406 if (is_filled ())
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
407 renderer->set_polygon_offset (true, 1+index);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
408
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
409 glBegin (type);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
410 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
411
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
412 void end (void)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
413 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
414 //printf("patch_tesselator::end\n");
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
415 glEnd ();
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
416 renderer->set_polygon_offset (false);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
417 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
418
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
419 void vertex (void *data)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
420 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
421 vertex_data::vertex_data_rep *v
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
422 = reinterpret_cast<vertex_data::vertex_data_rep *> (data);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
423 //printf("patch_tesselator::vertex (%g, %g, %g)\n", v->coords(0), v->coords(1), v->coords(2));
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
424
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
425 // FIXME: why did I need to keep the first vertex of the face
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
426 // in JHandles? I think it's related to the fact that the
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
427 // tessellation process might re-order the vertices, such that
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
428 // the first one you get here might not be the first one of the face;
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
429 // but I can't figure out the actual reason.
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
430 if (color_mode > 0 && (first || color_mode == 2))
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
431 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
432 Matrix col = v->color;
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
433
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
434 if (col.numel () == 3)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
435 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
436 glColor3dv (col.data ());
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
437 if (light_mode > 0)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
438 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
439 float buf[4] = { 0, 0, 0, 1 };
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
440
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
441 for (int k = 0; k < 3; k++)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
442 buf[k] = (v->ambient * col(k));
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
443 glMaterialfv (LIGHT_MODE, GL_AMBIENT, buf);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
444
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
445 for (int k = 0; k < 3; k++)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
446 buf[k] = (v->diffuse * col(k));
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
447 glMaterialfv (LIGHT_MODE, GL_AMBIENT, buf);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
448 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
449 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
450 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
451
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
452 if (light_mode > 0 && (first || light_mode == 2))
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
453 glNormal3dv (v->normal.data ());
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
454
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
455 glVertex3dv (v->coords.data ());
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
456
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
457 first = false;
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
458 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
459
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
460 void combine (GLdouble xyz[3], void *data[4], GLfloat w[4],
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
461 void **out_data)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
462 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
463 //printf("patch_tesselator::combine\n");
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
464
7837
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
465 vertex_data::vertex_data_rep *v[4];
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
466 int vmax = 4;
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
467
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
468 for (int i = 0; i < 4; i++)
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
469 {
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
470 v[i] = reinterpret_cast<vertex_data::vertex_data_rep *> (data[i]);
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
471
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
472 if (vmax == 4 && ! v[i])
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
473 vmax = i;
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
474 }
7833
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
475
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
476 Matrix vv (1, 3, 0.0);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
477 Matrix cc;
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
478 Matrix nn (1, 3, 0.0);
7837
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
479 double aa = 0.0;
7833
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
480
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
481 vv(0) = xyz[0];
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
482 vv(1) = xyz[1];
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
483 vv(2) = xyz[2];
7837
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
484
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
485 if (v[0]->color.numel ())
7833
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
486 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
487 cc.resize (1, 3, 0.0);
7837
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
488 for (int ic = 0; ic < 3; ic++)
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
489 for (int iv = 0; iv < vmax; iv++)
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
490 cc(ic) += (w[iv] * v[iv]->color(ic));
7833
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
491 }
7837
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
492
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
493 if (v[0]->normal.numel () > 0)
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
494 {
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
495 for (int in = 0; in < 3; in++)
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
496 for (int iv = 0; iv < vmax; iv++)
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
497 nn(in) += (w[iv] * v[iv]->normal(in));
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
498 }
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
499
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
500 for (int iv = 0; iv < vmax; iv++)
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
501 aa += (w[iv] * v[iv]->alpha);
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
502
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
503 vertex_data new_v (vv, cc, nn, aa, v[0]->ambient, v[0]->diffuse,
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
504 v[0]->specular, v[0]->specular_exp);
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
505 tmp_vdata.push_back (new_v);
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
506
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
507 *out_data = new_v.get_rep ();
7833
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
508 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
509
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
510 private:
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
511 opengl_renderer *renderer;
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
512 int color_mode; // 0: uni, 1: flat, 2: interp
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
513 int light_mode; // 0: none, 1: flat, 2: gouraud
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
514 int index;
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
515 bool first;
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
516 std::list<vertex_data> tmp_vdata;
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
517 };
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
518
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
519 void
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
520 opengl_renderer::draw (const graphics_object& go)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
521 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
522 if (! go.valid_object ())
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
523 return;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
524
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
525 const base_properties& props = go.get_properties ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
526
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
527 if (go.isa ("figure"))
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
528 draw (dynamic_cast<const figure::properties&> (props));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
529 else if (go.isa ("axes"))
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
530 draw (dynamic_cast<const axes::properties&> (props));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
531 else if (go.isa ("line"))
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
532 draw (dynamic_cast<const line::properties&> (props));
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
533 else if (go.isa ("surface"))
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
534 draw (dynamic_cast<const surface::properties&> (props));
7833
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
535 else if (go.isa ("patch"))
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
536 draw (dynamic_cast<const patch::properties&> (props));
7866
35e8d6199455 Add hggroup support in OpenGL renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7851
diff changeset
537 else if (go.isa ("hggroup"))
35e8d6199455 Add hggroup support in OpenGL renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7851
diff changeset
538 draw (dynamic_cast<const hggroup::properties&> (props));
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
539 else
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
540 warning ("opengl_renderer: cannot render object of type `%s'",
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
541 props.graphics_object_name ().c_str ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
542 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
543
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
544 void
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
545 opengl_renderer::draw (const figure::properties& props)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
546 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
547 backend = props.get_backend ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
548
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
549 // Initialize OpenGL context
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
550
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
551 glEnable (GL_DEPTH_TEST);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
552 glDepthFunc (GL_LEQUAL);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
553 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
554 glEnable (GL_NORMALIZE);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
555
7907
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
556 if (props.is___enhanced__ ())
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
557 {
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
558 glEnable (GL_BLEND);
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
559 glEnable (GL_LINE_SMOOTH);
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
560 }
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
561 else
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
562 {
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
563 glDisable (GL_BLEND);
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
564 glDisable (GL_LINE_SMOOTH);
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
565 }
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
566
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
567 // Clear background
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
568
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
569 Matrix c = props.get_color_rgb ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
570
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
571 if (c.length() >= 3)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
572 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
573 glClearColor (c(0), c(1), c(2), 1);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
574 glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
575 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
576
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
577 // Draw children
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
578
8263
22c078fd926b make fltk backend figures work again
John W. Eaton <jwe@octave.org>
parents: 7954
diff changeset
579 draw (props.get_all_children ());
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
580 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
581
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
582 void
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
583 opengl_renderer::draw (const axes::properties& props)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
584 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
585 // setup OpenGL transformation
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
586
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
587 Matrix x_zlim = props.get_transform_zlim ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
588 Matrix x_mat1 = props.get_opengl_matrix_1 ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
589 Matrix x_mat2 = props.get_opengl_matrix_2 ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
590
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
591 xZ1 = x_zlim(0)-(x_zlim(1)-x_zlim(0))/2;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
592 xZ2 = x_zlim(1)+(x_zlim(1)-x_zlim(0))/2;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
593
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
594 int vw[4];
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
595 glGetIntegerv (GL_VIEWPORT, vw);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
596
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
597 glMatrixMode (GL_MODELVIEW);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
598 glLoadIdentity ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
599 glScaled(1, 1, -1);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
600 glMultMatrixd (x_mat1.data ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
601 glMatrixMode (GL_PROJECTION);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
602 glLoadIdentity ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
603 glOrtho (0, vw[2], vw[3], 0, xZ1, xZ2);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
604 glMultMatrixd (x_mat2.data ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
605 glMatrixMode (GL_MODELVIEW);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
606
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
607 glClear (GL_DEPTH_BUFFER_BIT);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
608
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
609 // store axes transformation data
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
610
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
611 xform = props.get_transform ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
612
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
613 // draw axes object
7907
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
614
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
615 GLboolean antialias;
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
616 glGetBooleanv (GL_LINE_SMOOTH, &antialias);
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
617 glDisable (GL_LINE_SMOOTH);
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
618
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
619 Matrix xlim = xform.xscale (props.get_xlim ().matrix_value ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
620 Matrix ylim = xform.yscale (props.get_ylim ().matrix_value ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
621 Matrix zlim = xform.zscale (props.get_zlim ().matrix_value ());
7870
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
622 double x_min = xlim(0), x_max = xlim(1);
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
623 double y_min = ylim(0), y_max = ylim(1);
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
624 double z_min = zlim(0), z_max = zlim(1);
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
625
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
626 double xd = (props.xdir_is ("normal") ? 1 : -1);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
627 double yd = (props.ydir_is ("normal") ? 1 : -1);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
628 double zd = (props.zdir_is ("normal") ? 1 : -1);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
629
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
630 ColumnVector p1, p2, xv (3), yv (3), zv (3);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
631 int xstate, ystate, zstate;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
632
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
633 xstate = ystate = zstate = AXE_ANY_DIR;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
634
7870
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
635 p1 = xform.transform (x_min, (y_min+y_max)/2, (z_min+z_max)/2, false);
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
636 p2 = xform.transform (x_max, (y_min+y_max)/2, (z_min+z_max)/2, false);
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
637 xv(0) = xround (p2(0)-p1(0));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
638 xv(1) = xround (p2(1)-p1(1));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
639 xv(2) = (p2(2)-p1(2));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
640 if (xv(0) == 0 && xv(1) == 0)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
641 xstate = AXE_DEPTH_DIR;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
642 else if (xv(2) == 0)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
643 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
644 if (xv(0) == 0)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
645 xstate = AXE_VERT_DIR;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
646 else if (xv(1) == 0)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
647 xstate = AXE_HORZ_DIR;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
648 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
649 double xPlane;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
650 if (xv(2) == 0)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
651 if (xv(1) == 0)
7870
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
652 xPlane = (xv(0) > 0 ? x_max : x_min);
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
653 else
7870
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
654 xPlane = (xv(1) < 0 ? x_max : x_min);
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
655 else
7870
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
656 xPlane = (xv(2) < 0 ? x_min : x_max);
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
657 double xPlaneN = (xPlane == x_min ? x_max : x_min);
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
658 double fx = (x_max-x_min)/sqrt(xv(0)*xv(0)+xv(1)*xv(1));
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
659
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
660 p1 = xform.transform ((x_min+x_max)/2, y_min, (z_min+z_max)/2, false);
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
661 p2 = xform.transform ((x_min+x_max)/2, y_max, (z_min+z_max)/2, false);
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
662 yv(0) = xround (p2(0)-p1(0));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
663 yv(1) = xround (p2(1)-p1(1));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
664 yv(2) = (p2(2)-p1(2));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
665 if (yv(0) == 0 && yv(1) == 0)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
666 ystate = AXE_DEPTH_DIR;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
667 else if (yv(2) == 0)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
668 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
669 if (yv(0) == 0)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
670 ystate = AXE_VERT_DIR;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
671 else if (yv(1) == 0)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
672 ystate = AXE_HORZ_DIR;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
673 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
674 double yPlane;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
675 if (yv(2) == 0)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
676 if (yv(1) == 0)
7870
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
677 yPlane = (yv(0) > 0 ? y_max : y_min);
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
678 else
7870
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
679 yPlane = (yv(1) < 0 ? y_max : y_min);
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
680 else
7870
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
681 yPlane = (yv(2) < 0 ? y_min : y_max);
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
682 double yPlaneN = (yPlane == y_min ? y_max : y_min);
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
683 double fy = (y_max-y_min)/sqrt(yv(0)*yv(0)+yv(1)*yv(1));
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
684
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
685 p1 = xform.transform((x_min+x_max)/2, (y_min+y_max)/2, z_min, false);
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
686 p2 = xform.transform((x_min+x_max)/2, (y_min+y_max)/2, z_max, false);
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
687 zv(0) = xround(p2(0)-p1(0));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
688 zv(1) = xround (p2(1)-p1(1));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
689 zv(2) = (p2(2)-p1(2));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
690 if (zv(0) == 0 && zv(1) == 0)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
691 zstate = AXE_DEPTH_DIR;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
692 else if (zv(2) == 0)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
693 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
694 if (zv(0) == 0)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
695 zstate = AXE_VERT_DIR;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
696 else if (zv(1) == 0)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
697 zstate = AXE_HORZ_DIR;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
698 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
699 double zPlane;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
700 if (zv(2) == 0)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
701 if (zv(1) == 0)
7870
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
702 zPlane = (zv(0) > 0 ? z_min : z_max);
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
703 else
7870
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
704 zPlane = (zv(1) < 0 ? z_min : z_max);
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
705 else
7870
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
706 zPlane = (zv(2) < 0 ? z_min : z_max);
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
707 double zPlaneN = (zPlane == z_min ? z_max : z_min);
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
708 double fz = (z_max-z_min)/sqrt(zv(0)*zv(0)+zv(1)*zv(1));
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
709
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
710 bool mode2d = (((xstate > AXE_DEPTH_DIR ? 1 : 0) +
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
711 (ystate > AXE_DEPTH_DIR ? 1 : 0) +
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
712 (zstate > AXE_DEPTH_DIR ? 1 : 0)) == 2);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
713 if (props.tickdirmode_is ("auto"))
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
714 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
715 // FIXME: tickdir should be updated (code below comes
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
716 // from JHandles)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
717 //autoMode++;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
718 //TickDir.set(mode2d ? "in" : "out", true);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
719 //autoMode--;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
720 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
721
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
722 // FIXME: use ticklength property
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
723 double xticklen = 7, yticklen = 7, zticklen = 7;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
724
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
725 //double tickdir = (props.tickdir_is ("in") ? -1 : 1);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
726 double tickdir = (props.tickdirmode_is ("auto") ?
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
727 (mode2d ? -1 : 1) :
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
728 (props.tickdir_is ("in") ? -1 : 1));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
729 double xtickoffset = (mode2d && tickdir < 0 ? 0 : xticklen) + 5;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
730 double ytickoffset = (mode2d && tickdir < 0 ? 0 : yticklen) + 5;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
731 double ztickoffset = (mode2d && tickdir < 0 ? 0 : zticklen) + 5;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
732
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
733 bool xySym = (xd*yd*(xPlane-xPlaneN)*(yPlane-yPlaneN) > 0);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
734 bool x2Dtop = false;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
735 bool y2Dright = false;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
736 double zpTick = zPlane;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
737
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
738 /* 2D mode */
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
739 if (xstate == AXE_HORZ_DIR && ystate == AXE_VERT_DIR)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
740 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
741 if (props.xaxislocation_is ("top"))
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
742 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
743 double tmp = yPlane;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
744 yPlane = yPlaneN;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
745 yPlaneN = tmp;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
746 x2Dtop = true;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
747 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
748 if (props.yaxislocation_is ("right"))
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
749 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
750 double tmp = xPlane;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
751 xPlane = xPlaneN;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
752 xPlaneN = tmp;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
753 y2Dright = true;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
754 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
755 if (props.layer_is ("top"))
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
756 zpTick = zPlaneN;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
757 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
758
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
759 Matrix axe_color = props.get_color_rgb ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
760 bool visible = props.is_visible ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
761 bool box = props.is_box ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
762
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
763 // Axes planes
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
764
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
765 if (axe_color.numel () > 0 && visible)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
766 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
767 set_color (axe_color);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
768 set_polygon_offset (true, 2.5);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
769
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
770 glBegin (GL_QUADS);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
771
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
772 // X plane
7870
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
773 glVertex3d (xPlane, y_min, z_min);
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
774 glVertex3d (xPlane, y_max, z_min);
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
775 glVertex3d (xPlane, y_max, z_max);
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
776 glVertex3d (xPlane, y_min, z_max);
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
777
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
778 // Y plane
7870
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
779 glVertex3d (x_min, yPlane, z_min);
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
780 glVertex3d (x_max, yPlane, z_min);
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
781 glVertex3d (x_max, yPlane, z_max);
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
782 glVertex3d (x_min, yPlane, z_max);
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
783
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
784 // Z plane
7870
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
785 glVertex3d (x_min, y_min, zPlane);
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
786 glVertex3d (x_max, y_min, zPlane);
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
787 glVertex3d (x_max, y_max, zPlane);
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
788 glVertex3d (x_min, y_max, zPlane);
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
789
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
790 glEnd ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
791
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
792 set_polygon_offset (false);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
793 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
794
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
795 // Axes box
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
796
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
797 set_linestyle ("-", true);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
798 set_linewidth (props.get_linewidth ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
799
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
800 if (visible)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
801 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
802 glBegin (GL_LINES);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
803
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
804 // X box
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
805 set_color (props.get_xcolor_rgb ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
806 glVertex3d (xPlaneN, yPlaneN, zPlane);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
807 glVertex3d (xPlane, yPlaneN, zPlane);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
808 if (box)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
809 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
810 glVertex3d (xPlaneN, yPlane, zPlane);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
811 glVertex3d (xPlane, yPlane, zPlane);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
812 glVertex3d (xPlaneN, yPlane, zPlaneN);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
813 glVertex3d (xPlane, yPlane, zPlaneN);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
814 glVertex3d (xPlaneN, yPlaneN, zPlaneN);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
815 glVertex3d (xPlane, yPlaneN, zPlaneN);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
816 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
817
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
818 // Y box
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
819 set_color (props.get_ycolor_rgb ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
820 glVertex3d (xPlaneN, yPlaneN, zPlane);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
821 glVertex3d (xPlaneN, yPlane, zPlane);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
822 if (box)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
823 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
824 glVertex3d (xPlane, yPlaneN, zPlane);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
825 glVertex3d (xPlane, yPlane, zPlane);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
826 glVertex3d (xPlane, yPlaneN, zPlaneN);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
827 glVertex3d (xPlane, yPlane, zPlaneN);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
828 glVertex3d (xPlaneN, yPlaneN, zPlaneN);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
829 glVertex3d (xPlaneN, yPlane, zPlaneN);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
830 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
831
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
832 // Z box
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
833 set_color (props.get_zcolor_rgb ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
834 if (xySym)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
835 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
836 glVertex3d (xPlaneN, yPlane, zPlaneN);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
837 glVertex3d (xPlaneN, yPlane, zPlane);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
838 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
839 else
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
840 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
841 glVertex3d (xPlane, yPlaneN, zPlaneN);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
842 glVertex3d (xPlane, yPlaneN, zPlane);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
843 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
844 if (box)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
845 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
846 glVertex3d (xPlane, yPlane, zPlaneN);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
847 glVertex3d (xPlane, yPlane, zPlane);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
848 if (xySym)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
849 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
850 glVertex3d (xPlane, yPlaneN, zPlaneN);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
851 glVertex3d (xPlane, yPlaneN, zPlane);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
852 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
853 else
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
854 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
855 glVertex3d (xPlaneN, yPlane, zPlaneN);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
856 glVertex3d (xPlaneN, yPlane, zPlane);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
857 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
858 glVertex3d (xPlaneN, yPlaneN, zPlaneN);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
859 glVertex3d (xPlaneN, yPlaneN, zPlane);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
860 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
861
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
862 glEnd ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
863 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
864
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
865 std::string gridstyle = props.get_gridlinestyle ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
866 std::string minorgridstyle = props.get_minorgridlinestyle ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
867
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
868 // X grid
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
869
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
870 if (visible && xstate != AXE_DEPTH_DIR)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
871 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
872 bool do_xgrid = (props.is_xgrid () && (gridstyle != "none"));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
873 bool do_xminorgrid = (props.is_xminorgrid () && (minorgridstyle != "none"));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
874 bool do_xminortick = props.is_xminortick ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
875 Matrix xticks = xform.xscale (props.get_xtick ().matrix_value ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
876 // FIXME: use pre-computed minor ticks
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
877 Matrix xmticks;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
878 // FIXME: use xticklabels property
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
879 string_vector xticklabels;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
880 int wmax = 0, hmax = 0;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
881 bool tick_along_z = xisinf (fy);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
882 Matrix tickpos (xticks.numel (), 3);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
883
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
884 set_color (props.get_xcolor_rgb ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
885
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
886 // grid lines
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
887 if (do_xgrid)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
888 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
889 set_linestyle (gridstyle, true);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
890 glBegin (GL_LINES);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
891 for (int i = 0; i < xticks.numel (); i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
892 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
893 double xval = xticks(i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
894
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
895 glVertex3d (xval, yPlaneN, zpTick);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
896 glVertex3d (xval, yPlane, zpTick);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
897 if (zstate != AXE_DEPTH_DIR)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
898 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
899 glVertex3d (xval, yPlane, zPlaneN);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
900 glVertex3d (xval, yPlane, zPlane);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
901 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
902 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
903 glEnd ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
904 set_linestyle ("-", true);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
905 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
906
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
907 // tick marks
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
908 if (tick_along_z)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
909 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
910 glBegin (GL_LINES);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
911 for (int i = 0; i < xticks.numel (); i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
912 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
913 double xval = xticks(i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
914
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
915 glVertex3d (xval, yPlaneN, zPlane);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
916 glVertex3d (xval, yPlaneN, zPlane+signum(zPlane-zPlaneN)*fz*xticklen*tickdir);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
917 if (box && xstate != AXE_ANY_DIR)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
918 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
919 glVertex3d (xval, yPlaneN, zPlaneN);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
920 glVertex3d (xval, yPlaneN,
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
921 zPlaneN+signum(zPlaneN-zPlane)*fz*xticklen*tickdir);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
922 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
923 tickpos(i,0) = xval;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
924 tickpos(i,1) = yPlaneN;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
925 tickpos(i,2) = zPlane+signum(zPlane-zPlaneN)*fz*xtickoffset;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
926 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
927 glEnd ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
928 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
929 else
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
930 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
931 glBegin (GL_LINES);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
932 for (int i = 0; i < xticks.numel (); i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
933 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
934 double xval = xticks(i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
935
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
936 glVertex3d (xval, yPlaneN, zpTick);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
937 glVertex3d (xval, yPlaneN+signum(yPlaneN-yPlane)*fy*xticklen*tickdir, zpTick);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
938 if (box && xstate != AXE_ANY_DIR)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
939 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
940 glVertex3d (xval, yPlane, zpTick);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
941 glVertex3d (xval,
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
942 yPlane+signum(yPlane-yPlaneN)*fy*xticklen*tickdir, zpTick);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
943 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
944 tickpos(i,0) = xval;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
945 tickpos(i,1) = yPlaneN+signum(yPlaneN-yPlane)*fy*xtickoffset;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
946 tickpos(i,2) = zPlane;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
947 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
948 glEnd ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
949 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
950
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
951 // FIXME: tick texts
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
952
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
953 // minor grid lines
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
954 if (do_xminorgrid)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
955 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
956 set_linestyle (minorgridstyle, true);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
957 glBegin (GL_LINES);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
958 for (int i = 0; i < xmticks.numel (); i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
959 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
960 double xval = xmticks(i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
961
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
962 glVertex3d (xval, yPlaneN, zpTick);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
963 glVertex3d (xval, yPlane, zpTick);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
964 if (zstate != AXE_DEPTH_DIR)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
965 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
966 glVertex3d (xval, yPlane, zPlaneN);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
967 glVertex3d (xval, yPlane, zPlane);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
968 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
969 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
970 glEnd ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
971 set_linestyle ("-", true);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
972 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
973
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
974 // minor tick marks
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
975 if (do_xminortick)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
976 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
977 if (tick_along_z)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
978 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
979 glBegin (GL_LINES);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
980 for (int i = 0; i < xmticks.numel (); i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
981 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
982 double xval = xmticks(i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
983
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
984 glVertex3d (xval, yPlaneN, zPlane);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
985 glVertex3d (xval, yPlaneN,
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
986 zPlane+signum(zPlane-zPlaneN)*fz*xticklen/2*tickdir);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
987 if (box && xstate != AXE_ANY_DIR)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
988 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
989 glVertex3d (xval, yPlaneN, zPlaneN);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
990 glVertex3d (xval, yPlaneN,
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
991 zPlaneN+signum(zPlaneN-zPlane)*fz*xticklen/2*tickdir);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
992 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
993 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
994 glEnd ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
995 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
996 else
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
997 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
998 glBegin (GL_LINES);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
999 for (int i = 0; i < xmticks.numel (); i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1000 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1001 double xval = xmticks(i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1002
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1003 glVertex3d (xval, yPlaneN, zpTick);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1004 glVertex3d (xval,
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1005 yPlaneN+signum(yPlaneN-yPlane)*fy*xticklen/2*tickdir, zpTick);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1006 if (box && xstate != AXE_ANY_DIR)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1007 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1008 glVertex3d (xval, yPlane, zpTick);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1009 glVertex3d (xval,
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1010 yPlane+signum(yPlane-yPlaneN)*fy*xticklen/2*tickdir, zpTick);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1011 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1012 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1013 glEnd ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1014 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1015 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1016
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1017 text::properties& xlabel_props =
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1018 reinterpret_cast<text::properties&> (gh_manager::get_object (props.get_xlabel ()).get_properties ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1019
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1020 // FIXME: auto-positioning should be disabled if the
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1021 // label has been positioned manually
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1022 if (! xlabel_props.get_string ().empty ())
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1023 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1024 xlabel_props.set_horizontalalignment (xstate > AXE_DEPTH_DIR ? "center" : (xySym ? "left" : "right"));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1025 xlabel_props.set_verticalalignment (xstate == AXE_VERT_DIR ? "bottom" : (zd*zv(2) <= 0 ? "top" : "bottom"));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1026
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1027 double angle = 0;
7874
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7870
diff changeset
1028 ColumnVector p = graphics_xform::xform_vector ((x_min+x_max)/2, yPlaneN, zPlane);
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1029
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1030 if (tick_along_z)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1031 p(2) += (signum(zPlane-zPlaneN)*fz*xtickoffset);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1032 else
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1033 p(1) += (signum(yPlaneN-yPlane)*fy*xtickoffset);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1034 p = xform.transform (p(0), p(1), p(2), false);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1035 switch (xstate)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1036 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1037 case AXE_ANY_DIR:
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1038 p(0) += (xySym ? wmax : -wmax);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1039 p(1) += (zd*zv(2) <= 0 ? hmax : -hmax);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1040 break;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1041 case AXE_VERT_DIR:
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1042 p(0) -= wmax;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1043 angle = 90;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1044 break;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1045 case AXE_HORZ_DIR:
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1046 p(1) += hmax;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1047 break;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1048 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1049 p = xform.untransform (p(0), p(1), p(2), true);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1050 xlabel_props.set_position (p.extract_n (0, 3).transpose ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1051 xlabel_props.set_rotation (angle);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1052 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1053 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1054
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1055 // Y grid
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1056
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1057 if (ystate != AXE_DEPTH_DIR && visible)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1058 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1059 bool do_ygrid = (props.is_ygrid () && (gridstyle != "none"));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1060 bool do_yminorgrid = (props.is_yminorgrid () && (minorgridstyle != "none"));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1061 bool do_yminortick = props.is_yminortick ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1062 Matrix yticks = xform.yscale (props.get_ytick ().matrix_value ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1063 // FIXME: use pre-computed minor ticks
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1064 Matrix ymticks;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1065 // FIXME: use yticklabels property
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1066 string_vector yticklabels;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1067 int wmax = 0, hmax = 0;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1068 bool tick_along_z = xisinf (fx);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1069 Matrix tickpos (yticks.numel (), 3);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1070
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1071 set_color (props.get_ycolor_rgb ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1072
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1073 // grid lines
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1074 if (do_ygrid)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1075 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1076 set_linestyle (gridstyle, true);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1077 glBegin (GL_LINES);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1078 for (int i = 0; i < yticks.numel (); i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1079 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1080 double yval = yticks(i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1081
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1082 glVertex3d (xPlaneN, yval, zpTick);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1083 glVertex3d (xPlane, yval, zpTick);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1084 if (zstate != AXE_DEPTH_DIR)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1085 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1086 glVertex3d (xPlane, yval, zPlaneN);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1087 glVertex3d (xPlane, yval, zPlane);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1088 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1089 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1090 glEnd ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1091 set_linestyle ("-", true);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1092 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1093
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1094 // tick marks
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1095 if (tick_along_z)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1096 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1097 glBegin (GL_LINES);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1098 for (int i = 0; i < yticks.numel (); i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1099 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1100 double yval = yticks(i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1101
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1102 glVertex3d (xPlaneN, yval, zPlane);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1103 glVertex3d (xPlaneN, yval, zPlane+signum(zPlane-zPlaneN)*fz*yticklen*tickdir);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1104 if (box && ystate != AXE_ANY_DIR)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1105 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1106 glVertex3d (xPlaneN, yval, zPlaneN);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1107 glVertex3d (xPlaneN, yval,
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1108 zPlaneN+signum(zPlaneN-zPlane)*fz*yticklen*tickdir);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1109 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1110 tickpos(i,0) = xPlaneN;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1111 tickpos(i,1) = yval;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1112 tickpos(i,2) = zPlane+signum(zPlane-zPlaneN)*fz*ytickoffset;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1113 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1114 glEnd ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1115 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1116 else
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1117 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1118 glBegin (GL_LINES);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1119 for (int i = 0; i < yticks.numel (); i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1120 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1121 double yval = yticks(i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1122
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1123 glVertex3d (xPlaneN, yval, zpTick);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1124 glVertex3d (xPlaneN+signum(xPlaneN-xPlane)*fx*yticklen*tickdir, yval, zpTick);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1125 if (box && ystate != AXE_ANY_DIR)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1126 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1127 glVertex3d (xPlane, yval, zpTick);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1128 glVertex3d (xPlane+signum(xPlane-xPlaneN)*fx*yticklen*tickdir,
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1129 yval, zpTick);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1130 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1131 tickpos(i,0) = xPlaneN+signum(xPlaneN-xPlane)*fx*ytickoffset;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1132 tickpos(i,1) = yval;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1133 tickpos(i,2) = zPlane;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1134 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1135 glEnd ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1136 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1137
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1138 // FIXME: tick texts
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1139
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1140 // minor grid lines
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1141 if (do_yminorgrid)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1142 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1143 set_linestyle (minorgridstyle, true);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1144 glBegin (GL_LINES);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1145 for (int i = 0; i < ymticks.numel (); i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1146 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1147 double yval = ymticks(i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1148
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1149 glVertex3d (xPlaneN, yval, zpTick);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1150 glVertex3d (xPlane, yval, zpTick);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1151 if (zstate != AXE_DEPTH_DIR)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1152 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1153 glVertex3d (xPlane, yval, zPlaneN);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1154 glVertex3d (xPlane, yval, zPlane);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1155 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1156 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1157 glEnd ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1158 set_linestyle ("-", true);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1159 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1160
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1161 // minor tick marks
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1162 if (do_yminortick)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1163 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1164 if (tick_along_z)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1165 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1166 glBegin (GL_LINES);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1167 for (int i = 0; i < ymticks.numel (); i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1168 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1169 double yval = ymticks(i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1170
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1171 glVertex3d (xPlaneN, yval, zPlane);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1172 glVertex3d (xPlaneN, yval,
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1173 zPlane+signum(zPlane-zPlaneN)*fz*yticklen/2*tickdir);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1174 if (box && ystate != AXE_ANY_DIR)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1175 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1176 glVertex3d (xPlaneN, yval, zPlaneN);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1177 glVertex3d (xPlaneN, yval,
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1178 zPlaneN+signum(zPlaneN-zPlane)*fz*yticklen/2*tickdir);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1179 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1180 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1181 glEnd ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1182 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1183 else
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1184 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1185 glBegin (GL_LINES);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1186 for (int i = 0; i < ymticks.numel (); i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1187 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1188 double yval = ymticks(i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1189
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1190 glVertex3d (xPlaneN, yval, zpTick);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1191 glVertex3d (xPlaneN+signum(xPlaneN-xPlane)*fx*yticklen/2*tickdir,
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1192 yval, zpTick);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1193 if (box && ystate != AXE_ANY_DIR)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1194 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1195 glVertex3d (xPlane, yval, zpTick);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1196 glVertex3d (xPlane+signum(xPlane-xPlaneN)*fx*yticklen/2*tickdir,
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1197 yval, zpTick);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1198 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1199 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1200 glEnd ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1201 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1202 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1203
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1204 text::properties& ylabel_props =
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1205 reinterpret_cast<text::properties&> (gh_manager::get_object (props.get_ylabel ()).get_properties ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1206
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1207 // FIXME: auto-positioning should be disabled if the
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1208 // label has been positioned manually
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1209 if (! ylabel_props.get_string ().empty ())
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1210 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1211 ylabel_props.set_horizontalalignment (ystate > AXE_DEPTH_DIR ? "center" : (!xySym ? "left" : "right"));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1212 ylabel_props.set_verticalalignment (ystate == AXE_VERT_DIR ? "bottom" : (zd*zv(2) <= 0 ? "top" : "bottom"));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1213
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1214 double angle = 0;
7874
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7870
diff changeset
1215 ColumnVector p = graphics_xform::xform_vector (xPlaneN, (y_min+y_max)/2, zPlane);
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1216
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1217 if (tick_along_z)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1218 p(2) += (signum(zPlane-zPlaneN)*fz*ytickoffset);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1219 else
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1220 p(0) += (signum(xPlaneN-xPlane)*fx*ytickoffset);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1221 p = xform.transform (p(0), p(1), p(2), false);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1222 switch (ystate)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1223 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1224 case AXE_ANY_DIR:
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1225 p(0) += (!xySym ? wmax : -wmax);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1226 p(1) += (zd*zv(2) <= 0 ? hmax : -hmax);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1227 break;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1228 case AXE_VERT_DIR:
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1229 p(0) -= wmax;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1230 angle = 90;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1231 break;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1232 case AXE_HORZ_DIR:
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1233 p(1) += hmax;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1234 break;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1235 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1236 p = xform.untransform(p(0), p(1), p(2), true);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1237 ylabel_props.set_position (p.extract_n (0, 3).transpose ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1238 ylabel_props.set_rotation (angle);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1239 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1240 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1241
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1242 // Z Grid
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1243
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1244 if (zstate != AXE_DEPTH_DIR && visible)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1245 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1246 bool do_zgrid = (props.is_zgrid () && (gridstyle != "none"));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1247 bool do_zminorgrid = (props.is_zminorgrid () && (minorgridstyle != "none"));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1248 bool do_zminortick = props.is_zminortick ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1249 Matrix zticks = xform.zscale (props.get_ztick ().matrix_value ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1250 // FIXME: use pre-computed minor ticks
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1251 Matrix zmticks;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1252 // FIXME: use zticklabels property
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1253 string_vector zticklabels;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1254 int wmax = 0, hmax = 0;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1255 Matrix tickpos (zticks.numel (), 3);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1256
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1257 set_color (props.get_zcolor_rgb ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1258
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1259 // grid lines
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1260 if (do_zgrid)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1261 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1262 set_linestyle (gridstyle, true);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1263 glBegin (GL_LINES);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1264 for (int i = 0; i < zticks.numel (); i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1265 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1266 double zval = zticks(i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1267
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1268 glVertex3d (xPlaneN, yPlane, zval);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1269 glVertex3d (xPlane, yPlane, zval);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1270 glVertex3d (xPlane, yPlaneN, zval);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1271 glVertex3d (xPlane, yPlane, zval);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1272 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1273 glEnd ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1274 set_linestyle ("-", true);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1275 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1276
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1277 // tick marks
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1278 if (xySym)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1279 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1280 if (xisinf (fy))
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1281 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1282 glBegin (GL_LINES);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1283 for (int i = 0; i < zticks.numel (); i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1284 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1285 double zval = zticks(i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1286
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1287 glVertex3d (xPlaneN, yPlane, zval);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1288 glVertex3d (xPlaneN+signum(xPlaneN-xPlane)*fx*zticklen*tickdir,
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1289 yPlane, zval);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1290 if (box && zstate != AXE_ANY_DIR)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1291 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1292 glVertex3d (xPlane, yPlane, zval);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1293 glVertex3d (xPlane+signum(xPlane-xPlaneN)*fx*zticklen*tickdir,
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1294 yPlane, zval);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1295 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1296 tickpos(i,0) = xPlaneN+signum(xPlaneN-xPlane)*fx*ztickoffset;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1297 tickpos(i,1) = yPlane;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1298 tickpos(i,2) = zval;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1299 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1300 glEnd ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1301 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1302 else
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1303 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1304 glBegin (GL_LINES);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1305 for (int i = 0; i < zticks.numel (); i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1306 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1307 double zval = zticks(i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1308
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1309 glVertex3d (xPlaneN, yPlane, zval);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1310 glVertex3d (xPlaneN, yPlane+signum(yPlane-yPlaneN)*fy*zticklen*tickdir, zval);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1311 tickpos(i,0) = xPlaneN;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1312 tickpos(i,1) = yPlane+signum(yPlane-yPlaneN)*fy*ztickoffset;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1313 tickpos(i,2) = zval;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1314 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1315 glEnd ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1316 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1317 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1318 else
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1319 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1320 if (xisinf (fx))
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1321 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1322 glBegin (GL_LINES);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1323 for (int i = 0; i < zticks.numel (); i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1324 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1325 double zval = zticks(i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1326
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1327 glVertex3d (xPlane, yPlaneN, zval);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1328 glVertex3d (xPlane, yPlaneN+signum(yPlaneN-yPlane)*fy*zticklen*tickdir, zval);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1329 if (box && zstate != AXE_ANY_DIR)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1330 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1331 glVertex3d (xPlane, yPlane, zval);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1332 glVertex3d (xPlane, yPlane+signum(yPlane-yPlaneN)*fy*zticklen*tickdir, zval);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1333 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1334 tickpos(i,0) = xPlane;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1335 tickpos(i,1) = yPlaneN+signum(yPlaneN-yPlane)*fy*ztickoffset;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1336 tickpos(i,2) = zval;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1337 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1338 glEnd ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1339 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1340 else
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1341 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1342 glBegin (GL_LINES);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1343 for (int i = 0; i < zticks.numel (); i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1344 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1345 double zval = zticks(i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1346
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1347 glVertex3d (xPlane, yPlaneN, zval);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1348 glVertex3d (xPlane+signum(xPlane-xPlaneN)*fx*zticklen*tickdir, yPlaneN, zval);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1349 tickpos(i,0) = xPlane+signum(xPlane-xPlaneN)*fx*ztickoffset;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1350 tickpos(i,1) = yPlaneN;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1351 tickpos(i,2) = zval;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1352 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1353 glEnd ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1354 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1355 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1356
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1357 // FIXME: tick texts
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1358
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1359 // minor grid lines
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1360 if (do_zminorgrid)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1361 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1362 set_linestyle (minorgridstyle, true);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1363 glBegin (GL_LINES);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1364 for (int i = 0; i < zmticks.numel (); i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1365 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1366 double zval = zmticks(i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1367
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1368 glVertex3d (xPlaneN, yPlane, zval);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1369 glVertex3d (xPlane, yPlane, zval);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1370 glVertex3d (xPlane, yPlaneN, zval);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1371 glVertex3d (xPlane, yPlane, zval);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1372 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1373 glEnd ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1374 set_linestyle ("-", true);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1375 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1376
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1377 // minor tick marks
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1378 if (do_zminortick)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1379 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1380 if (xySym)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1381 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1382 if (xisinf (fy))
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1383 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1384 glBegin (GL_LINES);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1385 for (int i = 0; i < zmticks.numel (); i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1386 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1387 double zval = zmticks(i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1388
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1389 glVertex3d (xPlaneN, yPlane, zval);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1390 glVertex3d (xPlaneN+signum(xPlaneN-xPlane)*fx*zticklen/2*tickdir,
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1391 yPlane, zval);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1392 if (box && zstate != AXE_ANY_DIR)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1393 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1394 glVertex3d (xPlane, yPlane, zval);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1395 glVertex3d (xPlane+signum(xPlane-xPlaneN)*fx*zticklen/2*tickdir,
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1396 yPlane, zval);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1397 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1398 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1399 glEnd ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1400 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1401 else
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1402 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1403 glBegin (GL_LINES);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1404 for (int i = 0; i < zmticks.numel (); i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1405 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1406 double zval = zmticks(i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1407
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1408 glVertex3d (xPlaneN, yPlane, zval);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1409 glVertex3d (xPlaneN, yPlane+signum(yPlane-yPlaneN)*fy*zticklen/2*tickdir, zval);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1410 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1411 glEnd ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1412 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1413 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1414 else
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1415 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1416 if (xisinf (fx))
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1417 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1418 glBegin (GL_LINES);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1419 for (int i = 0; i < zmticks.numel (); i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1420 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1421 double zval = zmticks(i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1422
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1423 glVertex3d (xPlane, yPlaneN, zval);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1424 glVertex3d (xPlane, yPlaneN+signum(yPlaneN-yPlane)*fy*zticklen/2*tickdir, zval);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1425 if (box && zstate != AXE_ANY_DIR)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1426 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1427 glVertex3d (xPlane, yPlane, zval);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1428 glVertex3d (xPlane, yPlane+signum(yPlane-yPlaneN)*fy*zticklen/2*tickdir, zval);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1429 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1430 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1431 glEnd ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1432 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1433 else
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1434 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1435 glBegin (GL_LINES);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1436 for (int i = 0; i < zmticks.numel (); i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1437 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1438 double zval = zmticks(i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1439
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1440 glVertex3d (xPlane, yPlaneN, zval);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1441 glVertex3d (xPlane+signum(xPlane-xPlaneN)*fx*zticklen/2*tickdir, yPlaneN, zval);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1442 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1443 glEnd ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1444 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1445 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1446 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1447
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1448 text::properties& zlabel_props =
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1449 reinterpret_cast<text::properties&> (gh_manager::get_object (props.get_zlabel ()).get_properties ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1450
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1451 // FIXME: auto-positioning should be disabled if the
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1452 // label has been positioned manually
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1453 if (! zlabel_props.get_string ().empty ())
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1454 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1455 bool camAuto = props.cameraupvectormode_is ("auto");
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1456
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1457 zlabel_props.set_horizontalalignment ((zstate > AXE_DEPTH_DIR || camAuto) ? "center" : "right");
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1458 zlabel_props.set_verticalalignment(zstate == AXE_VERT_DIR ? "bottom" : ((zd*zv(2) < 0 || camAuto) ? "bottom" : "top"));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1459
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1460 double angle = 0;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1461 ColumnVector p;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1462
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1463 if (xySym)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1464 {
7874
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7870
diff changeset
1465 p = graphics_xform::xform_vector (xPlaneN, yPlane, (z_min+z_max)/2);
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1466 if (xisinf (fy))
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1467 p(0) += (signum(xPlaneN-xPlane)*fx*ztickoffset);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1468 else
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1469 p(1) += (signum(yPlane-yPlaneN)*fy*ztickoffset);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1470 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1471 else
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1472 {
7874
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7870
diff changeset
1473 p = graphics_xform::xform_vector (xPlane, yPlaneN, (z_min+z_max)/2);
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1474 if (xisinf (fx))
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1475 p(1) += (signum(yPlaneN-yPlane)*fy*ztickoffset);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1476 else
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1477 p(0) += (signum(xPlane-xPlaneN)*fx*ztickoffset);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1478 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1479 p = xform.transform (p(0), p(1), p(2), false);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1480 switch (zstate)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1481 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1482 case AXE_ANY_DIR:
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1483 if (camAuto)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1484 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1485 p(0) -= wmax;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1486 angle = 90;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1487 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1488 /* FIXME: what's the correct offset?
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1489 p[0] += (!xySym ? wmax : -wmax);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1490 p[1] += (zd*zv[2] <= 0 ? hmax : -hmax);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1491 */
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1492 break;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1493 case AXE_VERT_DIR:
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1494 p(0) -= wmax;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1495 angle = 90;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1496 break;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1497 case AXE_HORZ_DIR:
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1498 p(1) += hmax;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1499 break;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1500 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1501 p = xform.untransform (p(0), p(1), p(2), true);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1502 zlabel_props.set_position (p.extract_n (0, 3).transpose ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1503 zlabel_props.set_rotation (angle);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1504 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1505 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1506
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1507 set_linestyle ("-");
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1508
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1509 // Title
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1510
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1511 text::properties& title_props =
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1512 reinterpret_cast<text::properties&> (gh_manager::get_object (props.get_title ()).get_properties ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1513
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1514 // FIXME: auto-positioning should be disabled if the
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1515 // title has been positioned manually
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1516 if (! title_props.get_string ().empty ())
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1517 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1518 Matrix bb = props.get_boundingbox (true);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1519 ColumnVector p = xform.untransform (bb(0)+bb(2)/2, (bb(1)-10),
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1520 (x_zlim(0)+x_zlim(1))/2, true);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1521 title_props.set_position (p.extract_n(0, 3).transpose ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1522 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1523
7874
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7870
diff changeset
1524 set_clipbox (x_min, x_max, y_min, y_max, z_min, z_max);
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1525
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1526 // Children
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1527
7907
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
1528 if (antialias == GL_TRUE)
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
1529 glEnable (GL_LINE_SMOOTH);
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
1530
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1531 Matrix children = props.get_children ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1532 std::list<graphics_object> obj_list;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1533 std::list<graphics_object>::iterator it;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1534
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1535 // 1st pass: draw light objects
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1536
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1537 for (int i = 0; i < children.numel (); i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1538 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1539 graphics_object go = gh_manager::get_object (children (i));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1540
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1541 if (go.get_properties ().is_visible ())
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1542 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1543 if (go.isa ("light"))
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1544 draw (go);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1545 else
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1546 obj_list.push_back (go);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1547 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1548 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1549
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1550 // 2nd pass: draw other objects (with units set to "data")
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1551
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1552 it = obj_list.begin ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1553 while (it != obj_list.end ())
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1554 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1555 graphics_object go = (*it);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1556
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1557 // FIXME: check whether object has "units" property and it is set to "data"
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1558 if (! go.isa ("text") || go.get ("units").string_value () == "data")
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1559 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1560 set_clipping (go.get_properties ().is_clipping ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1561 draw (go);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1562
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1563 it = obj_list.erase (it);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1564 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1565 else
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1566 it++;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1567 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1568
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1569 // 3rd pass: draw remaining objects
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1570
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1571 for (it = obj_list.begin (); it != obj_list.end (); it++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1572 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1573 graphics_object go = (*it);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1574
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1575 set_clipping (go.get_properties ().is_clipping ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1576 draw (go);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1577 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1578
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1579 set_clipping (false);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1580 // FIXME: finalize rendering (transparency processing)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1581 // FIXME: draw zoom box, if needed
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1582 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1583
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1584 void
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1585 opengl_renderer::draw (const line::properties& props)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1586 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1587 Matrix x = xform.xscale (props.get_xdata ().matrix_value ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1588 Matrix y = xform.yscale (props.get_ydata ().matrix_value ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1589 Matrix z = xform.zscale (props.get_zdata ().matrix_value ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1590
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1591 bool has_z = (z.numel () > 0);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1592 int n = static_cast<int> (::xmin (::xmin (x.numel (), y.numel ()), (has_z ? z.numel () : INT_MAX)));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1593 octave_uint8 clip_mask = (props.is_clipping () ? 0x7F : 0x40), clip_ok (0x40);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1594
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1595 std::vector<octave_uint8> clip (n);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1596
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1597 if (has_z)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1598 for (int i = 0; i < n; i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1599 clip[i] = (clip_code (x(i), y(i), z(i)) & clip_mask);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1600 else
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1601 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1602 double z_mid = (zmin+zmax)/2;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1603
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1604 for (int i = 0; i < n; i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1605 clip[i] = (clip_code (x(i), y(i), z_mid) & clip_mask);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1606 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1607
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1608 if (! props.linestyle_is ("none"))
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1609 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1610 set_color (props.get_color_rgb ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1611 set_linestyle (props.get_linestyle (), false);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1612 set_linewidth (props.get_linewidth ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1613
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1614 if (has_z)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1615 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1616 bool flag = false;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1617
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1618 for (int i = 1; i < n; i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1619 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1620 if ((clip[i-1] & clip[i]) == clip_ok)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1621 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1622 if (! flag)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1623 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1624 flag = true;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1625 glBegin (GL_LINE_STRIP);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1626 glVertex3d (x(i-1), y(i-1), z(i-1));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1627 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1628 glVertex3d (x(i), y(i), z(i));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1629 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1630 else if (flag)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1631 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1632 flag = false;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1633 glEnd ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1634 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1635 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1636
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1637 if (flag)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1638 glEnd ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1639 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1640 else
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1641 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1642 bool flag = false;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1643
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1644 for (int i = 1; i < n; i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1645 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1646 if ((clip[i-1] & clip[i]) == clip_ok)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1647 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1648 if (! flag)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1649 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1650 flag = true;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1651 glBegin (GL_LINE_STRIP);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1652 glVertex2d (x(i-1), y(i-1));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1653 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1654 glVertex2d (x(i), y(i));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1655 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1656 else if (flag)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1657 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1658 flag = false;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1659 glEnd ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1660 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1661 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1662
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1663 if (flag)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1664 glEnd ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1665 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1666
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1667 set_linewidth (0.5);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1668 set_linestyle ("-");
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1669 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1670
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1671 set_clipping (false);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1672
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1673 if (! props.marker_is ("none") &&
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1674 ! (props.markeredgecolor_is ("none")
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1675 && props.markerfacecolor_is ("none")))
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1676 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1677 Matrix lc, fc;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1678
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1679 if (props.markeredgecolor_is ("auto"))
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1680 lc = props.get_color_rgb ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1681 else if (! props.markeredgecolor_is ("none"))
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1682 lc = props.get_markeredgecolor_rgb ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1683
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1684 if (props.markerfacecolor_is ("auto"))
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1685 fc = props.get_color_rgb ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1686 else if (! props.markerfacecolor_is ("none"))
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1687 fc = props.get_markerfacecolor_rgb ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1688
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1689 init_marker (props.get_marker (), props.get_markersize (),
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1690 props.get_linewidth ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1691
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1692 for (int i = 0; i < n; i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1693 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1694 if (clip[i] == clip_ok)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1695 draw_marker (x(i), y(i), (has_z ? z(i) : 0), lc, fc);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1696 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1697
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1698 end_marker ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1699 }
7907
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
1700
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1701 set_clipping (props.is_clipping ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1702 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1703
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1704 void
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1705 opengl_renderer::draw (const surface::properties& props)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1706 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1707 Matrix x = xform.xscale (props.get_xdata ().matrix_value ());
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1708 Matrix y = xform.yscale (props.get_ydata ().matrix_value ());
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1709 Matrix z = xform.zscale (props.get_zdata ().matrix_value ());
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1710
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1711 int zr = z.rows (), zc = z.columns ();
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1712
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1713 NDArray c;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1714 NDArray n = props.get_vertexnormals ().array_value ();
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1715
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1716 // FIXME: handle transparency
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1717 Matrix a;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1718
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1719 if (props.facelighting_is ("phong") || props.edgelighting_is ("phong"))
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1720 warning ("opengl_renderer::draw: phong light model not supported");
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1721
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1722 int fc_mode = (props.facecolor_is_rgb () ? 0 :
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1723 (props.facecolor_is ("flat") ? 1 :
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1724 (props.facecolor_is ("interp") ? 2 :
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1725 (props.facecolor_is ("texturemap") ? 3 : -1))));
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1726 int fl_mode = (props.facelighting_is ("none") ? 0 :
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1727 (props.facelighting_is ("flat") ? 1 : 2));
7846
d7737a4268b7 Fix typos in property names (edgealpha/facealpha).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7838
diff changeset
1728 int fa_mode = (props.facealpha_is_double () ? 0 :
d7737a4268b7 Fix typos in property names (edgealpha/facealpha).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7838
diff changeset
1729 (props.facealpha_is ("flat") ? 1 : 2));
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1730 int ec_mode = (props.edgecolor_is_rgb () ? 0 :
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1731 (props.edgecolor_is ("flat") ? 1 :
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1732 (props.edgecolor_is ("interp") ? 2 : -1)));
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1733 int el_mode = (props.edgelighting_is ("none") ? 0 :
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1734 (props.edgelighting_is ("flat") ? 1 : 2));
7846
d7737a4268b7 Fix typos in property names (edgealpha/facealpha).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7838
diff changeset
1735 int ea_mode = (props.edgealpha_is_double () ? 0 :
d7737a4268b7 Fix typos in property names (edgealpha/facealpha).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7838
diff changeset
1736 (props.edgealpha_is ("flat") ? 1 : 2));
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1737
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1738 Matrix fcolor = (fc_mode == 3 ? Matrix (1, 3, 1.0) : props.get_facecolor_rgb ());
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1739 Matrix ecolor = props.get_edgecolor_rgb ();
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1740
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1741 float as = props.get_ambientstrength ();
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1742 float ds = props.get_diffusestrength ();
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1743 float ss = props.get_specularstrength ();
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1744 float se = props.get_specularexponent ();
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1745 float cb[4] = { 0, 0, 0, 1 };
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1746
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
1747 opengl_texture tex;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
1748
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1749 int i1, i2, j1, j2;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1750 bool x_mat = (x.rows () == z.rows ());
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1751 bool y_mat = (y.columns () == z.columns ());
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1752
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1753 i1 = i2 = j1 = j2 = 0;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1754
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
1755 boolMatrix clip (z.dims (), false);
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1756
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1757 for (int i = 0; i < zr; i++)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1758 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1759 if (x_mat)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1760 i1 = i;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1761
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
1762 for (int j = 0; j < zc; j++)
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1763 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1764 if (y_mat)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1765 j1 = j;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1766
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1767 clip(i,j) = is_nan_or_inf (x(i1,j), y(i,j1), z(i,j));
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1768 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1769 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1770
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1771 if ((fc_mode > 0 && fc_mode < 3) || ec_mode > 0)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1772 c = props.get_color_data ().array_value ();
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1773
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1774 if (fa_mode > 0 || ea_mode > 0)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1775 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1776 // FIXME: implement alphadata conversion
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1777 //a = props.get_alpha_data ();
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1778 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1779
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1780 if (fl_mode > 0 || el_mode > 0)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1781 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1782 float buf[4] = { ss, ss, ss, 1 };
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1783
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1784 glMaterialfv (LIGHT_MODE, GL_SPECULAR, buf);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1785 glMaterialf (LIGHT_MODE, GL_SHININESS, se);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1786 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1787
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
1788 // FIXME: good candidate for caching, transfering pixel
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
1789 // data to OpenGL is time consuming.
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1790 if (fc_mode == 3)
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
1791 tex = opengl_texture::create (props.get_color_data ());
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1792
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1793 if (! props.facecolor_is ("none"))
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1794 {
7846
d7737a4268b7 Fix typos in property names (edgealpha/facealpha).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7838
diff changeset
1795 if (props.get_facealpha_double () == 1)
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1796 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1797 if (fc_mode == 0 || fc_mode == 3)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1798 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1799 glColor3dv (fcolor.data ());
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1800 if (fl_mode > 0)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1801 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1802 for (int i = 0; i < 3; i++)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1803 cb[i] = (as * fcolor(i));
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1804 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1805
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1806 for (int i = 0; i < 3; i++)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1807 cb[i] *= (ds / as);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1808 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1809 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1810 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1811
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1812 if (fl_mode > 0)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1813 glEnable (GL_LIGHTING);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1814 glShadeModel ((fc_mode == 2 || fl_mode == 2) ? GL_SMOOTH : GL_FLAT);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1815 set_polygon_offset (true, 1);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1816 if (fc_mode == 3)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1817 glEnable (GL_TEXTURE_2D);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1818
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1819 for (int i = 1; i < zc; i++)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1820 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1821 if (y_mat)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1822 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1823 i1 = i-1;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1824 i2 = i;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1825 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1826
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1827 for (int j = 1; j < zr; j++)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1828 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1829 if (clip(j-1, i-1) || clip (j, i-1)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1830 || clip (j-1, i) || clip (j, i))
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1831 continue;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1832
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1833 if (x_mat)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1834 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1835 j1 = j-1;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1836 j2 = j;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1837 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1838
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1839 glBegin (GL_QUADS);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1840
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1841 // Vertex 1
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1842 if (fc_mode == 3)
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
1843 tex.tex_coord (double (i-1) / (zc-1), double (j-1) / (zr-1));
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1844 else if (fc_mode > 0)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1845 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1846 // FIXME: is there a smarter way to do this?
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1847 for (int k = 0; k < 3; k++)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1848 cb[k] = c(j-1, i-1, k);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1849 glColor3fv (cb);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1850
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1851 if (fl_mode > 0)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1852 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1853 for (int k = 0; k < 3; k++)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1854 cb[k] *= as;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1855 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1856
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1857 for (int k = 0; k < 3; k++)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1858 cb[k] *= (ds / as);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1859 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1860 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1861 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1862 if (fl_mode > 0)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1863 glNormal3d (n(j-1,i-1,0), n(j-1,i-1,1), n(j-1,i-1,2));
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1864 glVertex3d (x(j1,i-1), y(j-1,i1), z(j-1,i-1));
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1865
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1866 // Vertex 2
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1867 if (fc_mode == 3)
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
1868 tex.tex_coord (double (i) / (zc-1), double (j-1) / (zr-1));
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1869 else if (fc_mode == 2)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1870 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1871 for (int k = 0; k < 3; k++)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1872 cb[k] = c(j-1, i, k);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1873 glColor3fv (cb);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1874
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1875 if (fl_mode > 0)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1876 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1877 for (int k = 0; k < 3; k++)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1878 cb[k] *= as;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1879 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1880
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1881 for (int k = 0; k < 3; k++)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1882 cb[k] *= (ds / as);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1883 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1884 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1885 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1886 if (fl_mode == 2)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1887 glNormal3d (n(j-1,i,0), n(j-1,i,1), n(j-1,i,2));
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1888 glVertex3d (x(j1,i), y(j-1,i2), z(j-1,i));
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1889
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1890 // Vertex 3
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1891 if (fc_mode == 3)
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
1892 tex.tex_coord (double (i) / (zc-1), double (j) / (zr-1));
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1893 else if (fc_mode == 2)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1894 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1895 for (int k = 0; k < 3; k++)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1896 cb[k] = c(j, i, k);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1897 glColor3fv (cb);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1898
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1899 if (fl_mode > 0)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1900 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1901 for (int k = 0; k < 3; k++)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1902 cb[k] *= as;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1903 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1904
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1905 for (int k = 0; k < 3; k++)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1906 cb[k] *= (ds / as);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1907 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1908 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1909 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1910 if (fl_mode == 2)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1911 glNormal3d (n(j,i,0), n(j,i,1), n(j,i,2));
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1912 glVertex3d (x(j2,i), y(j,i2), z(j,i));
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1913
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1914 // Vertex 4
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1915 if (fc_mode == 3)
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
1916 tex.tex_coord (double (i-1) / (zc-1), double (j) / (zr-1));
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1917 else if (fc_mode == 2)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1918 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1919 for (int k = 0; k < 3; k++)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1920 cb[k] = c(j, i-1, k);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1921 glColor3fv (cb);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1922
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1923 if (fl_mode > 0)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1924 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1925 for (int k = 0; k < 3; k++)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1926 cb[k] *= as;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1927 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1928
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1929 for (int k = 0; k < 3; k++)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1930 cb[k] *= (ds / as);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1931 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1932 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1933 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1934 if (fl_mode == 2)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1935 glNormal3d (n(j,i-1,0), n(j,i-1,1), n(j,i-1,2));
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1936 glVertex3d (x(j2,i-1), y(j,i1), z(j,i-1));
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1937
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1938 glEnd ();
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1939 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1940 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1941
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1942 set_polygon_offset (false);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1943 if (fc_mode == 3)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1944 glDisable (GL_TEXTURE_2D);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1945
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1946 if (fl_mode > 0)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1947 glDisable (GL_LIGHTING);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1948 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1949 else
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1950 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1951 // FIXME: implement transparency
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1952 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1953 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1954
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1955 if (! props.edgecolor_is ("none"))
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1956 {
7846
d7737a4268b7 Fix typos in property names (edgealpha/facealpha).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7838
diff changeset
1957 if (props.get_edgealpha_double () == 1)
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1958 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1959 if (ec_mode == 0)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1960 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1961 glColor3dv (ecolor.data ());
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1962 if (fl_mode > 0)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1963 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1964 for (int i = 0; i < 3; i++)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1965 cb[i] = (as * ecolor(i));
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1966 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1967
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1968 for (int i = 0; i < 3; i++)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1969 cb[i] *= (ds / as);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1970 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1971 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1972 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1973
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1974 if (el_mode > 0)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1975 glEnable (GL_LIGHTING);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1976 glShadeModel ((ec_mode == 2 || el_mode == 2) ? GL_SMOOTH : GL_FLAT);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1977
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1978 set_linestyle (props.get_linestyle (), false);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1979 set_linewidth (props.get_linewidth ());
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1980
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1981 // Mesh along Y-axis
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1982
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1983 if (props.meshstyle_is ("both") || props.meshstyle_is ("column"))
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1984 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1985 for (int i = 0; i < zc; i++)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1986 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1987 if (y_mat)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1988 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1989 i1 = i-1;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1990 i2 = i;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1991 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1992
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1993 for (int j = 1; j < zr; j++)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1994 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1995 if (clip(j-1,i) || clip(j,i))
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1996 continue;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1997
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1998 if (x_mat)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1999 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2000 j1 = j-1;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2001 j2 = j;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2002 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2003
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2004 glBegin (GL_LINES);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2005
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2006 // Vertex 1
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2007 if (ec_mode > 0)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2008 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2009 for (int k = 0; k < 3; k++)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2010 cb[k] = c(j-1, i, k);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2011 glColor3fv (cb);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2012
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2013 if (fl_mode > 0)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2014 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2015 for (int k = 0; k < 3; k++)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2016 cb[k] *= as;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2017 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2018
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2019 for (int k = 0; k < 3; k++)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2020 cb[k] *= (ds / as);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2021 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2022 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2023 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2024 if (el_mode > 0)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2025 glNormal3d (n(j-1,i,0), n(j-1,i,1), n(j-1,i,2));
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2026 glVertex3d (x(j1,i), y(j-1,i2), z(j-1,i));
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2027
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2028 // Vertex 2
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2029 if (ec_mode == 2)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2030 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2031 for (int k = 0; k < 3; k++)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2032 cb[k] = c(j, i, k);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2033 glColor3fv (cb);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2034
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2035 if (fl_mode > 0)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2036 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2037 for (int k = 0; k < 3; k++)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2038 cb[k] *= as;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2039 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2040
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2041 for (int k = 0; k < 3; k++)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2042 cb[k] *= (ds / as);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2043 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2044 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2045 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2046 if (el_mode == 2)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2047 glNormal3d (n(j,i,0), n(j,i,1), n(j,i,2));
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2048 glVertex3d (x(j2,i), y(j,i2), z(j,i));
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2049
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2050 glEnd ();
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2051 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2052 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2053 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2054
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2055 // Mesh along X-axis
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2056
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2057 if (props.meshstyle_is ("both") || props.meshstyle_is ("row"))
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2058 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2059 for (int j = 0; j < zr; j++)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2060 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2061 if (x_mat)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2062 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2063 j1 = j-1;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2064 j2 = j;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2065 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2066
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2067 for (int i = 1; i < zc; i++)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2068 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2069 if (clip(j,i-1) || clip(j,i))
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2070 continue;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2071
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2072 if (y_mat)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2073 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2074 i1 = i-1;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2075 i2 = i;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2076 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2077
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2078 glBegin (GL_LINES);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2079
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2080 // Vertex 1
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2081 if (ec_mode > 0)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2082 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2083 for (int k = 0; k < 3; k++)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2084 cb[k] = c(j, i-1, k);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2085 glColor3fv (cb);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2086
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2087 if (fl_mode > 0)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2088 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2089 for (int k = 0; k < 3; k++)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2090 cb[k] *= as;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2091 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2092
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2093 for (int k = 0; k < 3; k++)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2094 cb[k] *= (ds / as);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2095 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2096 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2097 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2098 if (el_mode > 0)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2099 glNormal3d (n(j,i-1,0), n(j,i-1,1), n(j,i-1,2));
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2100 glVertex3d (x(j2,i-1), y(j,i1), z(j,i-1));
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2101
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2102 // Vertex 2
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2103 if (ec_mode == 2)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2104 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2105 for (int k = 0; k < 3; k++)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2106 cb[k] = c(j, i, k);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2107 glColor3fv (cb);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2108
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2109 if (fl_mode > 0)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2110 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2111 for (int k = 0; k < 3; k++)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2112 cb[k] *= as;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2113 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2114
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2115 for (int k = 0; k < 3; k++)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2116 cb[k] *= (ds / as);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2117 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2118 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2119 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2120 if (el_mode == 2)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2121 glNormal3d (n(j,i,0), n(j,i,1), n(j,i,2));
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2122 glVertex3d (x(j2,i), y(j,i2), z(j,i));
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2123
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2124 glEnd ();
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2125 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2126 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2127 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2128
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2129 set_linestyle ("-");
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2130 set_linewidth (0.5);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2131
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2132 if (el_mode > 0)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2133 glDisable (GL_LIGHTING);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2134 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2135 else
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2136 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2137 // FIXME: implement transparency
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2138 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2139 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2140
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2141 if (! props.marker_is ("none") &&
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2142 ! (props.markeredgecolor_is ("none")
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2143 && props.markerfacecolor_is ("none")))
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2144 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2145 // FIXME: check how transparency should be handled in markers
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2146 // FIXME: check what to do with marker facecolor set to auto
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2147 // and facecolor set to none.
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2148
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2149 bool do_edge = ! props.markeredgecolor_is ("none");
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2150 bool do_face = ! props.markerfacecolor_is ("none");
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2151
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2152 Matrix mecolor = props.get_markeredgecolor_rgb ();
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2153 Matrix mfcolor = props.get_markerfacecolor_rgb ();
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2154 Matrix cc (1, 3, 0.0);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2155
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2156 if (mecolor.numel () == 0 && props.markeredgecolor_is ("auto"))
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2157 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2158 mecolor = props.get_edgecolor_rgb ();
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2159 do_edge = ! props.edgecolor_is ("none");
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2160 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2161
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2162 if (mfcolor.numel () == 0 && props.markerfacecolor_is ("auto"))
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2163 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2164 mfcolor = props.get_facecolor_rgb ();
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2165 do_face = ! props.facecolor_is ("none");
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2166 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2167
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2168 if ((mecolor.numel () == 0 || mfcolor.numel () == 0)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2169 && c.numel () == 0)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2170 c = props.get_color_data ().array_value ();
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2171
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2172 init_marker (props.get_marker (), props.get_markersize (),
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2173 props.get_linewidth ());
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2174
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2175 for (int i = 0; i < zc; i++)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2176 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2177 if (y_mat)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2178 i1 = i;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2179
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2180 for (int j = 0; j < zr; j++)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2181 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2182 if (clip(j,i))
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2183 continue;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2184
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2185 if (x_mat)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2186 j1 = j;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2187
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2188 if ((do_edge && mecolor.numel () == 0)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2189 || (do_face && mfcolor.numel () == 0))
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2190 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2191 for (int k = 0; k < 3; k++)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2192 cc(k) = c(j,i,k);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2193 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2194
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2195 Matrix lc = (do_edge ? (mecolor.numel () == 0 ? cc : mecolor) : Matrix ());
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2196 Matrix fc = (do_face ? (mfcolor.numel () == 0 ? cc : mfcolor) : Matrix ());
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2197
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2198 draw_marker (x(j1,i), y(j,i1), z(j,i), lc, fc);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2199 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2200 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2201
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2202 end_marker ();
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2203 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2204 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2205
7833
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2206 // FIXME: global optimization (rendering, data structures...), there
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2207 // is probably a smarter/faster/less-memory-consuming way to do this.
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2208 void
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2209 opengl_renderer::draw (const patch::properties &props)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2210 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2211 Matrix f = props.get_faces ().matrix_value ();
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2212 Matrix v = xform.scale (props.get_vertices ().matrix_value ());
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2213 Matrix c;
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2214 Matrix n = props.get_vertexnormals ().matrix_value ();
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2215 Matrix a;
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2216
7870
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
2217 int nv = v.rows ();
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
2218 // int vmax = v.columns ();
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
2219 int nf = f.rows ();
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
2220 int fcmax = f.columns ();
7833
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2221
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2222 bool has_z = (v.columns () > 2);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2223 bool has_facecolor = false;
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2224 bool has_facealpha = false;
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2225
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2226 int fc_mode = (props.facecolor_is_rgb () ? 0 :
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2227 (props.facecolor_is("flat") ? 1 : 2));
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2228 int fl_mode = (props.facelighting_is ("none") ? 0 :
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2229 (props.facelighting_is ("flat") ? 1 : 2));
7846
d7737a4268b7 Fix typos in property names (edgealpha/facealpha).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7838
diff changeset
2230 int fa_mode = (props.facealpha_is_double () ? 0 :
d7737a4268b7 Fix typos in property names (edgealpha/facealpha).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7838
diff changeset
2231 (props.facealpha_is ("flat") ? 1 : 2));
7833
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2232 int ec_mode = (props.edgecolor_is_rgb () ? 0 :
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2233 (props.edgecolor_is("flat") ? 1 : 2));
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2234 int el_mode = (props.edgelighting_is ("none") ? 0 :
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2235 (props.edgelighting_is ("flat") ? 1 : 2));
7846
d7737a4268b7 Fix typos in property names (edgealpha/facealpha).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7838
diff changeset
2236 int ea_mode = (props.edgealpha_is_double () ? 0 :
d7737a4268b7 Fix typos in property names (edgealpha/facealpha).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7838
diff changeset
2237 (props.edgealpha_is ("flat") ? 1 : 2));
7833
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2238
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2239 Matrix fcolor = props.get_facecolor_rgb ();
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2240 Matrix ecolor = props.get_edgecolor_rgb ();
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2241
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2242 float as = props.get_ambientstrength ();
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2243 float ds = props.get_diffusestrength ();
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2244 float ss = props.get_specularstrength ();
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2245 float se = props.get_specularexponent ();
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2246
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2247 boolMatrix clip (1, nv, false);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2248
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2249 if (has_z)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2250 for (int i = 0; i < nv; i++)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2251 clip(i) = is_nan_or_inf (v(i,0), v(i,1), v(i,2));
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2252 else
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2253 for (int i = 0; i < nv; i++)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2254 clip(i) = is_nan_or_inf (v(i,0), v(i,1), 0);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2255
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2256 boolMatrix clip_f (1, nf, false);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2257 Array<int> count_f (nf, 0);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2258
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2259 for (int i = 0; i < nf; i++)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2260 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2261 bool fclip = false;
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2262 int count = 0;
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2263
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2264 for (int j = 0; j < fcmax && ! xisnan (f(i,j)); j++, count++)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2265 fclip = (fclip || clip(int (f(i,j) - 1)));
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2266
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2267 clip_f(i) = fclip;
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2268 count_f(i) = count;
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2269 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2270
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2271 if (fc_mode > 0 || ec_mode > 0)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2272 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2273 c = props.get_color_data ().matrix_value ();
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2274
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2275 if (c.rows () == 1)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2276 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2277 // Single color specifications, we can simplify a little bit
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2278
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2279 if (fc_mode > 0)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2280 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2281 fcolor = c;
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2282 fc_mode = 0;
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2283 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2284
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2285 if (ec_mode > 0)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2286 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2287 ecolor = c;
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2288 ec_mode = 0;
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2289 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2290
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2291 c = Matrix ();
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2292 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2293 else
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2294 has_facecolor = ((c.numel () > 0) && (c.rows () == f.rows ()));
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2295 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2296
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2297 if (fa_mode > 0 || ea_mode > 0)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2298 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2299 // FIXME: retrieve alpha data from patch object
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2300 //a = props.get_alpha_data ();
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2301 has_facealpha = ((a.numel () > 0) && (a.rows () == f.rows ()));
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2302 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2303
7924
4976f66d469b miscellaneous cleanup
John W. Eaton <jwe@octave.org>
parents: 7914
diff changeset
2304 octave_idx_type fr = f.rows ();
7914
e998e81224b5 Various compilation fixes for MSVC.
John W. Eaton <jwe@octave.org>
parents: 7907
diff changeset
2305 std::vector<vertex_data> vdata (f.numel ());
7833
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2306
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2307 for (int i = 0; i < nf; i++)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2308 for (int j = 0; j < count_f(i); j++)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2309 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2310 int idx = int (f(i,j) - 1);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2311
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2312 Matrix vv (1, 3, 0.0);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2313 Matrix cc;
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2314 Matrix nn(1, 3, 0.0);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2315 double aa = 1.0;
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2316
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2317 vv(0) = v(idx,0); vv(1) = v(idx,1);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2318 if (has_z)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2319 vv(2) = v(idx,2);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2320 // FIXME: uncomment when patch object has normal computation
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2321 //nn(0) = n(idx,0); nn(1) = n(idx,1); nn(2) = n(idx,2);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2322 if (c.numel () > 0)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2323 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2324 cc.resize (1, 3);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2325 if (has_facecolor)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2326 cc(0) = c(i,0), cc(1) = c(i,1), cc(2) = c(i,2);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2327 else
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2328 cc(0) = c(idx,0), cc(1) = c(idx,1), cc(2) = c(idx,2);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2329 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2330 if (a.numel () > 0)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2331 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2332 if (has_facealpha)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2333 aa = a(i);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2334 else
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2335 aa = a(idx);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2336 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2337
7914
e998e81224b5 Various compilation fixes for MSVC.
John W. Eaton <jwe@octave.org>
parents: 7907
diff changeset
2338 vdata[i+j*fr] =
7833
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2339 vertex_data (vv, cc, nn, aa, as, ds, ss, se);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2340 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2341
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2342 if (fl_mode > 0 || el_mode > 0)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2343 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2344 float buf[4] = { ss, ss, ss, 1 };
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2345
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2346 glMaterialfv (LIGHT_MODE, GL_SPECULAR, buf);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2347 glMaterialf (LIGHT_MODE, GL_SHININESS, se);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2348 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2349
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2350 if (! props.facecolor_is ("none"))
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2351 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2352 // FIXME: adapt to double-radio property
7846
d7737a4268b7 Fix typos in property names (edgealpha/facealpha).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7838
diff changeset
2353 if (props.get_facealpha_double () == 1)
7833
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2354 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2355 if (fc_mode == 0)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2356 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2357 glColor3dv (fcolor.data ());
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2358 if (fl_mode > 0)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2359 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2360 float cb[4] = { 0, 0, 0, 1 };
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2361
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2362 for (int i = 0; i < 3; i++)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2363 cb[i] = (as * fcolor(i));
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2364 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2365
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2366 for (int i = 0; i < 3; i++)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2367 cb[i] *= (ds / as);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2368 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2369 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2370 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2371
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2372 if (fl_mode > 0)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2373 glEnable (GL_LIGHTING);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2374
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2375 // FIXME: use __index__ property from patch object
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2376 patch_tesselator tess (this, fc_mode, fl_mode, 0);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2377
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2378 for (int i = 0; i < nf; i++)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2379 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2380 if (clip_f(i))
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2381 continue;
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2382
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2383 tess.begin_polygon (true);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2384 tess.begin_contour ();
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2385
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2386 for (int j = 0; j < count_f(i); j++)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2387 {
7914
e998e81224b5 Various compilation fixes for MSVC.
John W. Eaton <jwe@octave.org>
parents: 7907
diff changeset
2388 vertex_data::vertex_data_rep *vv = vdata[i+j*fr].get_rep ();
7833
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2389
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2390 tess.add_vertex (vv->coords.fortran_vec (), vv);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2391 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2392
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2393 tess.end_contour ();
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2394 tess.end_polygon ();
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2395 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2396
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2397 if (fl_mode > 0)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2398 glDisable (GL_LIGHTING);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2399 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2400 else
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2401 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2402 // FIXME: implement transparency
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2403 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2404 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2405
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2406 if (! props.edgecolor_is ("none"))
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2407 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2408 // FIXME: adapt to double-radio property
7846
d7737a4268b7 Fix typos in property names (edgealpha/facealpha).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7838
diff changeset
2409 if (props.get_edgealpha_double () == 1)
7833
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2410 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2411 if (ec_mode == 0)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2412 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2413 glColor3dv (ecolor.data ());
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2414 if (el_mode > 0)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2415 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2416 float cb[4] = { 0, 0, 0, 1 };
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2417
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2418 for (int i = 0; i < 3; i++)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2419 cb[i] = (as * ecolor(i));
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2420 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2421
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2422 for (int i = 0; i < 3; i++)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2423 cb[i] *= (ds / as);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2424 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2425 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2426 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2427
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2428 if (el_mode > 0)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2429 glEnable (GL_LIGHTING);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2430
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2431 set_linestyle (props.get_linestyle (), false);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2432 set_linewidth (props.get_linewidth ());
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2433
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2434 // FIXME: use __index__ property from patch object; should we
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2435 // offset patch contour as well?
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2436 patch_tesselator tess (this, ec_mode, el_mode);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2437
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2438 for (int i = 0; i < nf; i++)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2439 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2440 if (clip_f(i))
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2441 continue;
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2442
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2443 tess.begin_polygon (false);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2444 tess.begin_contour ();
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2445
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2446 for (int j = 0; j < count_f(i); j++)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2447 {
7914
e998e81224b5 Various compilation fixes for MSVC.
John W. Eaton <jwe@octave.org>
parents: 7907
diff changeset
2448 vertex_data::vertex_data_rep *vv = vdata[i+j*fr].get_rep ();
7833
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2449
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2450 tess.add_vertex (vv->coords.fortran_vec (), vv);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2451 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2452
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2453 tess.end_contour ();
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2454 tess.end_polygon ();
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2455 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2456
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2457 set_linestyle ("-");
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2458 set_linewidth (0.5);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2459
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2460 if (el_mode > 0)
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2461 glDisable (GL_LIGHTING);
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2462 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2463 else
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2464 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2465 // FIXME: implement transparency
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2466 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2467 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2468
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2469 if (! props.marker_is ("none") &&
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2470 ! (props.markeredgecolor_is ("none") && props.markerfacecolor_is ("none")))
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2471 {
7838
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2472 bool do_edge = ! props.markeredgecolor_is ("none");
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2473 bool do_face = ! props.markerfacecolor_is ("none");
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2474
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2475 Matrix mecolor = props.get_markeredgecolor_rgb ();
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2476 Matrix mfcolor = props.get_markerfacecolor_rgb ();
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2477 Matrix cc (1, 3, 0.0);
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2478
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2479 if (mecolor.numel () == 0 && props.markeredgecolor_is ("auto"))
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2480 {
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2481 mecolor = props.get_edgecolor_rgb ();
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2482 do_edge = ! props.edgecolor_is ("none");
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2483 }
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2484
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2485 if (mfcolor.numel () == 0 && props.markerfacecolor_is ("auto"))
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2486 {
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2487 mfcolor = props.get_facecolor_rgb ();
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2488 do_face = ! props.facecolor_is ("none");
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2489 }
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2490
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2491 init_marker (props.get_marker (), props.get_markersize (),
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2492 props.get_linewidth ());
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2493
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2494 for (int i = 0; i < nf; i++)
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2495 for (int j = 0; j < count_f(i); j++)
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2496 {
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2497 int idx = int (f(i,j) - 1);
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2498
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2499 if (clip(idx))
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2500 continue;
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2501
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2502 Matrix lc = (do_edge ? (mecolor.numel () == 0 ?
7914
e998e81224b5 Various compilation fixes for MSVC.
John W. Eaton <jwe@octave.org>
parents: 7907
diff changeset
2503 vdata[i+j*fr].get_rep ()->color : mecolor)
7838
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2504 : Matrix ());
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2505 Matrix fc = (do_face ? (mfcolor.numel () == 0 ?
7914
e998e81224b5 Various compilation fixes for MSVC.
John W. Eaton <jwe@octave.org>
parents: 7907
diff changeset
2506 vdata[i+j*fr].get_rep ()->color : mfcolor)
7838
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2507 : Matrix ());
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2508
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2509 draw_marker (v(idx,0), v(idx,1), (has_z ? v(idx,2) : 0), lc, fc);
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2510 }
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2511
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2512 end_marker ();
7833
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2513 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2514 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2515
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2516 void
7866
35e8d6199455 Add hggroup support in OpenGL renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7851
diff changeset
2517 opengl_renderer::draw (const hggroup::properties &props)
35e8d6199455 Add hggroup support in OpenGL renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7851
diff changeset
2518 {
35e8d6199455 Add hggroup support in OpenGL renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7851
diff changeset
2519 draw (props.get_children ());
35e8d6199455 Add hggroup support in OpenGL renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7851
diff changeset
2520 }
35e8d6199455 Add hggroup support in OpenGL renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7851
diff changeset
2521
35e8d6199455 Add hggroup support in OpenGL renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7851
diff changeset
2522 void
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2523 opengl_renderer::set_viewport (int w, int h)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2524 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2525 glViewport (0, 0, w, h);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2526 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2527
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2528 void
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2529 opengl_renderer::set_color (const Matrix& c)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2530 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2531 glColor3dv (c.data ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2532 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2533
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2534 void
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2535 opengl_renderer::set_polygon_offset (bool on, double offset)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2536 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2537 if (on)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2538 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2539 glPolygonOffset (offset, offset);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2540 glEnable (GL_POLYGON_OFFSET_FILL);
7906
b3becd212f3f Draw markers above lines
John W. Eaton <jwe@octave.org>
parents: 7904
diff changeset
2541 glEnable (GL_POLYGON_OFFSET_LINE);
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2542 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2543 else
7906
b3becd212f3f Draw markers above lines
John W. Eaton <jwe@octave.org>
parents: 7904
diff changeset
2544 {
b3becd212f3f Draw markers above lines
John W. Eaton <jwe@octave.org>
parents: 7904
diff changeset
2545 glDisable (GL_POLYGON_OFFSET_FILL);
b3becd212f3f Draw markers above lines
John W. Eaton <jwe@octave.org>
parents: 7904
diff changeset
2546 glDisable (GL_POLYGON_OFFSET_LINE);
b3becd212f3f Draw markers above lines
John W. Eaton <jwe@octave.org>
parents: 7904
diff changeset
2547 }
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2548 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2549
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2550 void
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2551 opengl_renderer::set_linewidth (float w)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2552 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2553 glLineWidth (w);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2554 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2555
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2556 void
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2557 opengl_renderer::set_linestyle (const std::string& s, bool use_stipple)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2558 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2559 bool solid = false;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2560
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2561 if (s == "-")
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2562 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2563 glLineStipple (1, static_cast<unsigned short> (0xFFFF));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2564 solid = true;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2565 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2566 else if (s == ":")
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2567 glLineStipple (1, static_cast<unsigned short> (0x8888));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2568 else if (s == "--")
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2569 glLineStipple (1, static_cast<unsigned short> (0x0FFF));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2570 else if (s == "-.")
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2571 glLineStipple (1, static_cast<unsigned short> (0x020F));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2572 else
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2573 glLineStipple (1, static_cast<unsigned short> (0x0000));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2574
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2575 if (solid && ! use_stipple)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2576 glDisable (GL_LINE_STIPPLE);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2577 else
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2578 glEnable (GL_LINE_STIPPLE);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2579 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2580
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2581 void
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2582 opengl_renderer::set_clipbox (double x1, double x2, double y1, double y2,
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2583 double z1, double z2)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2584 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2585 double dx = (x2-x1);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2586 double dy = (y2-y1);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2587 double dz = (z2-z1);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2588
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2589 x1 -= 0.001*dx; x2 += 0.001*dx;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2590 y1 -= 0.001*dy; y2 += 0.001*dy;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2591 z1 -= 0.001*dz; z2 += 0.001*dz;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2592
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2593 ColumnVector p (4, 0.0);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2594
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2595 p(0) = -1; p(3) = x2;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2596 glClipPlane (GL_CLIP_PLANE0, p.data ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2597 p(0) = 1; p(3) = -x1;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2598 glClipPlane (GL_CLIP_PLANE1, p.data ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2599 p(0) = 0; p(1) = -1; p(3) = y2;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2600 glClipPlane (GL_CLIP_PLANE2, p.data ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2601 p(1) = 1; p(3) = -y1;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2602 glClipPlane (GL_CLIP_PLANE3, p.data ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2603 p(1) = 0; p(2) = -1; p(3) = z2;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2604 glClipPlane (GL_CLIP_PLANE4, p.data ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2605 p(2) = 1; p(3) = -z1;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2606 glClipPlane (GL_CLIP_PLANE5, p.data ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2607
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2608 xmin = x1; xmax = x2;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2609 ymin = y1; ymax = y2;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2610 zmin = z1; zmax = z2;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2611 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2612
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2613 void
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2614 opengl_renderer::set_clipping (bool enable)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2615 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2616 bool has_clipping = (glIsEnabled (GL_CLIP_PLANE0) == GL_TRUE);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2617
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2618 if (enable != has_clipping)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2619 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2620 if (enable)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2621 for (int i = 0; i < 6; i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2622 glEnable (GL_CLIP_PLANE0+i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2623 else
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2624 for (int i = 0; i < 6; i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2625 glDisable (GL_CLIP_PLANE0+i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2626 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2627 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2628
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2629 void
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2630 opengl_renderer::init_marker (const std::string& m, double size, float width)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2631 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2632 int vw[4];
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2633
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2634 glGetIntegerv (GL_VIEWPORT, vw);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2635
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2636 glMatrixMode (GL_PROJECTION);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2637 glPushMatrix ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2638 glLoadIdentity ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2639 glOrtho (0, vw[2], vw[3], 0, xZ1, xZ2);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2640 glMatrixMode (GL_MODELVIEW);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2641 glPushMatrix ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2642
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2643 set_clipping (false);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2644 set_linewidth (width);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2645
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2646 marker_id = make_marker_list (m, size, false);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2647 filled_marker_id = make_marker_list (m, size, true);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2648 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2649
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2650 void
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2651 opengl_renderer::end_marker (void)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2652 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2653 glDeleteLists (marker_id, 1);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2654 glDeleteLists (filled_marker_id, 1);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2655
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2656 glMatrixMode (GL_MODELVIEW);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2657 glPopMatrix ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2658 glMatrixMode (GL_PROJECTION);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2659 glPopMatrix ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2660 set_linewidth (0.5f);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2661 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2662
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2663 void
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2664 opengl_renderer::draw_marker (double x, double y, double z,
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2665 const Matrix& lc, const Matrix& fc)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2666 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2667 ColumnVector tmp = xform.transform (x, y, z, false);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2668
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2669 glLoadIdentity ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2670 glTranslated (tmp(0), tmp(1), -tmp(2));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2671
7907
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
2672 if (filled_marker_id > 0 && fc.numel () > 0)
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2673 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2674 glColor3dv (fc.data ());
7906
b3becd212f3f Draw markers above lines
John W. Eaton <jwe@octave.org>
parents: 7904
diff changeset
2675 set_polygon_offset (true, -1.0);
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2676 glCallList (filled_marker_id);
7906
b3becd212f3f Draw markers above lines
John W. Eaton <jwe@octave.org>
parents: 7904
diff changeset
2677 if (lc.numel () > 0)
b3becd212f3f Draw markers above lines
John W. Eaton <jwe@octave.org>
parents: 7904
diff changeset
2678 {
b3becd212f3f Draw markers above lines
John W. Eaton <jwe@octave.org>
parents: 7904
diff changeset
2679 glColor3dv (lc.data ());
b3becd212f3f Draw markers above lines
John W. Eaton <jwe@octave.org>
parents: 7904
diff changeset
2680 glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
b3becd212f3f Draw markers above lines
John W. Eaton <jwe@octave.org>
parents: 7904
diff changeset
2681 glEdgeFlag (GL_TRUE);
b3becd212f3f Draw markers above lines
John W. Eaton <jwe@octave.org>
parents: 7904
diff changeset
2682 set_polygon_offset (true, -2.0);
b3becd212f3f Draw markers above lines
John W. Eaton <jwe@octave.org>
parents: 7904
diff changeset
2683 glCallList (filled_marker_id);
b3becd212f3f Draw markers above lines
John W. Eaton <jwe@octave.org>
parents: 7904
diff changeset
2684 glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
b3becd212f3f Draw markers above lines
John W. Eaton <jwe@octave.org>
parents: 7904
diff changeset
2685 }
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2686 set_polygon_offset (false);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2687 }
7907
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
2688 else if (marker_id > 0 && lc.numel () > 0)
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2689 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2690 glColor3dv (lc.data ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2691 glCallList (marker_id);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2692 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2693 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2694
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2695 unsigned int
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2696 opengl_renderer::make_marker_list (const std::string& marker, double size,
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2697 bool filled) const
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2698 {
7907
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
2699 char c = marker[0];
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
2700
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
2701 if (filled && (c == '+' || c == 'x' || c == '*' || c == '.'))
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
2702 return 0;
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
2703
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2704 unsigned int ID = glGenLists (1);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2705 double sz = size * backend.get_screen_resolution () / 72.0;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2706
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2707 // constants for the * marker
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2708 const double sqrt2d4 = 0.35355339059327;
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2709 double tt = sz*sqrt2d4;
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2710
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2711 glNewList (ID, GL_COMPILE);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2712
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2713 switch (marker[0])
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2714 {
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2715 case '+':
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2716 glBegin (GL_LINES);
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2717 glVertex2f (-sz/2 ,0 );
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2718 glVertex2f (sz/2 ,0 );
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2719 glVertex2f (0 ,-sz/2 );
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2720 glVertex2f (0 ,sz/2 );
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2721 glEnd ();
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2722 break;
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2723 case 'x':
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2724 glBegin(GL_LINES);
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2725 glVertex2f (-sz/2 ,-sz/2);
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2726 glVertex2f (sz/2 ,sz/2 );
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2727 glVertex2f (-sz/2 ,sz/2 );
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2728 glVertex2f (sz/2 ,-sz/2 );
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2729 glEnd ();
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2730 break;
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2731 case '*':
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2732 glBegin (GL_LINES);
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2733 glVertex2f (-sz/2 ,0 );
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2734 glVertex2f (sz/2 ,0 );
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2735 glVertex2f (0 ,-sz/2 );
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2736 glVertex2f (0 ,sz/2 );
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2737 glVertex2f (-tt ,-tt );
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2738 glVertex2f (+tt ,+tt );
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2739 glVertex2f (-tt ,+tt );
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2740 glVertex2f (+tt ,-tt );
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2741 glEnd ();
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2742 break;
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2743 case '.':
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2744 glBegin (GL_POLYGON);
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2745 glVertex2f (-sz/10, -sz/10);
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2746 glVertex2f (-sz/10, sz/10 );
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2747 glVertex2f (sz/10 , sz/10 );
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2748 glVertex2f (sz/10 , -sz/10);
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2749 glEnd ();
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2750 break;
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2751 case 's':
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2752 glBegin ((filled ? GL_POLYGON : GL_LINE_LOOP));
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2753 glVertex2d (-sz/2, -sz/2);
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2754 glVertex2d (-sz/2, sz/2);
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2755 glVertex2d ( sz/2, sz/2);
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2756 glVertex2d ( sz/2, -sz/2);
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2757 glEnd();
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2758 break;
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2759 case 'o':
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2760 {
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2761 double ang_step = M_PI / 5;
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2762
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2763 glBegin ((filled ? GL_POLYGON : GL_LINE_LOOP));
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2764 for (double ang = 0; ang < (2*M_PI); ang += ang_step)
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2765 glVertex2d (sz*cos(ang)/2, sz*sin(ang)/2);
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2766 glEnd ();
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2767 }
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2768 break;
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2769 case 'd':
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2770 glBegin ((filled ? GL_POLYGON : GL_LINE_LOOP));
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2771 glVertex2d ( 0, -sz/2);
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2772 glVertex2d ( sz/2, 0);
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2773 glVertex2d ( 0, sz/2);
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2774 glVertex2d (-sz/2, 0);
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2775 glEnd();
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2776 break;
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2777 case '^':
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2778 glBegin ((filled ? GL_POLYGON : GL_LINE_LOOP));
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2779 glVertex2f (0 , sz/2);
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2780 glVertex2f (sz/2 , -sz/2);
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2781 glVertex2f (-sz/2 , -sz/2);
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2782 glEnd ();
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2783 break;
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2784 case 'v':
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2785 glBegin ((filled ? GL_POLYGON : GL_LINE_LOOP));
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2786 glVertex2f (0 ,-sz/2);
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2787 glVertex2f (-sz/2 ,sz/2 );
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2788 glVertex2f (sz/2 ,sz/2 );
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2789 glEnd ();
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2790 break;
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2791 case '>':
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2792 glBegin ((filled ? GL_POLYGON : GL_LINE_LOOP));
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2793 glVertex2f (sz/2 ,0 );
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2794 glVertex2f (-sz/2 ,sz/2 );
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2795 glVertex2f (-sz/2 ,-sz/2);
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2796 glEnd ();
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2797 break;
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2798 case '<':
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2799 glBegin ((filled ? GL_POLYGON : GL_LINE_LOOP));
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2800 glVertex2f (-sz/2 ,0 );
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2801 glVertex2f (sz/2 ,-sz/2);
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2802 glVertex2f (sz/2 ,sz/2 );
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2803 glEnd ();
7906
b3becd212f3f Draw markers above lines
John W. Eaton <jwe@octave.org>
parents: 7904
diff changeset
2804 break;
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2805 default:
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2806 warning ("opengl_renderer: unsupported marker `%s'",
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2807 marker.c_str ());
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2808 break;
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2809 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2810
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2811 glEndList ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2812
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2813 return ID;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2814 }
7874
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7870
diff changeset
2815
7954
3ffc34caec65 configure fixes
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
2816 #endif
3ffc34caec65 configure fixes
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
2817
7874
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7870
diff changeset
2818 /*
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7870
diff changeset
2819 ;;; Local Variables: ***
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7870
diff changeset
2820 ;;; mode: C++ ***
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7870
diff changeset
2821 ;;; End: ***
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7870
diff changeset
2822 */