annotate src/gl-render.cc @ 11586:12df7854fa7c

strip trailing whitespace from source files
author John W. Eaton <jwe@octave.org>
date Thu, 20 Jan 2011 17:24:59 -0500
parents 1473d0cf86d2
children f4689107dd8c
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
11523
fd0a3ac60b0e update copyright notices
John W. Eaton <jwe@octave.org>
parents: 11484
diff changeset
3 Copyright (C) 2008-2011 Michael Goffioul
7825
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
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
29 #include <iostream>
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
30
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
31 #include <lo-mappers.h>
8377
25bc2d31e1bf improve OCTAVE_LOCAL_BUFFER
Jaroslav Hajek <highegg@gmail.com>
parents: 8263
diff changeset
32 #include "oct-locbuf.h"
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
33 #include "gl-render.h"
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
34 #include "txt-eng.h"
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
35 #include "txt-eng-ft.h"
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
36
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
37 #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
38
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
39 // 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
40 // 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
41 // 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
42 #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
43 #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
44 #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
45
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
46 enum {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
47 AXE_ANY_DIR = 0,
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
48 AXE_DEPTH_DIR = 1,
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
49 AXE_HORZ_DIR = 2,
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
50 AXE_VERT_DIR = 3
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
51 };
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
52
7870
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
53 static octave_idx_type
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
54 xmin (octave_idx_type x, octave_idx_type y)
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
55 {
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
56 return x < y ? x : y;
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
57 }
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
58
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
59 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
60 opengl_texture
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
61 {
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
62 protected:
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
63 class texture_rep
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
64 {
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
65 public:
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
66 texture_rep (void)
11584
cda4aa780d58 Another round of initialising members in the constructor initialisation list
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11576
diff changeset
67 : id (), w (), h (), tw (), th (), tx (), ty (),
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
68 valid (false), count (1)
11584
cda4aa780d58 Another round of initialising members in the constructor initialisation list
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11576
diff changeset
69 { }
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
70
9681
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
71 texture_rep (GLuint id_arg, int w_arg, int h_arg, int tw_arg, int th_arg)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
72 : id (id_arg), w (w_arg), h (h_arg), tw (tw_arg), th (th_arg),
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
73 tx (double(w)/tw), ty (double(h)/th), valid (true),
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
74 count (1) { }
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
75
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
76 ~texture_rep (void)
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
77 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
78 if (valid)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
79 glDeleteTextures (1, &id);
7831
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
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
82 void bind (int mode) const
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
83 { if (valid) glBindTexture (mode, id); }
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
84
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
85 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
86 { 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
87
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
88 GLuint id;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
89 int w, h;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
90 int tw, th;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
91 double tx, ty;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
92 bool valid;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
93 int count;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
94 };
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
95
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
96 texture_rep *rep;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
97
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
98 private:
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
99 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
100
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
101 public:
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
102 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
103
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
104 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
105 : rep (tx.rep)
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
106 {
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
107 rep->count++;
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
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
110 ~opengl_texture (void)
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
111 {
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
112 if (--rep->count == 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
113 delete rep;
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
114 }
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
115
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
116 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
117 {
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
118 if (--rep->count == 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
119 delete rep;
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
120
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
121 rep = tx.rep;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
122 rep->count++;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
123
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
124 return *this;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
125 }
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
126
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
127 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
128
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
129 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
130 { rep->bind (mode); }
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 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
133 { rep->tex_coord (q, r); }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
134
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
135 bool is_valid (void) const
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
136 { return rep->valid; }
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
137 };
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
138
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
139 static int
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
140 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
141 {
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
142 int m = 1;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
143
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
144 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
145 m <<= 1;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
146
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
147 return m;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
148 }
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 opengl_texture
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
151 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
152 {
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
153 opengl_texture retval;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
154
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
155 dim_vector dv (data.dims ());
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 // Expect RGB data
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
158 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
159 {
9681
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
160 // FIXME -- dim_vectors hold octave_idx_type values. Should we
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
161 // check for dimensions larger than intmax?
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
162 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
163 GLuint id;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
164 bool ok = true;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
165
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
166 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
167 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
168
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
169 glGenTextures (1, &id);
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
170 glBindTexture (GL_TEXTURE_2D, id);
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 if (data.is_double_type ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
173 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
174 const NDArray xdata = data.array_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
175
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
176 OCTAVE_LOCAL_BUFFER (float, a, (3*tw*th));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
177
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
178 for (int i = 0; i < h; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
179 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
180 for (int j = 0, idx = i*tw*3; j < w; j++, idx += 3)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
181 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
182 a[idx] = xdata(i,j,0);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
183 a[idx+1] = xdata(i,j,1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
184 a[idx+2] = xdata(i,j,2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
185 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
186 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
187
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
188 glTexImage2D (GL_TEXTURE_2D, 0, 3, tw, th, 0,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
189 GL_RGB, GL_FLOAT, a);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
190 }
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
191 else if (data.is_uint8_type ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
192 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
193 const uint8NDArray xdata = data.uint8_array_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
194
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
195 OCTAVE_LOCAL_BUFFER (octave_uint8, a, (3*tw*th));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
196
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
197 for (int i = 0; i < h; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
198 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
199 for (int j = 0, idx = i*tw*3; j < w; j++, idx += 3)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
200 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
201 a[idx] = xdata(i,j,0);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
202 a[idx+1] = xdata(i,j,1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
203 a[idx+2] = xdata(i,j,2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
204 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
205 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
206
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
207 glTexImage2D (GL_TEXTURE_2D, 0, 3, tw, th, 0,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
208 GL_RGB, GL_UNSIGNED_BYTE, a);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
209 }
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
210 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
211 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
212 ok = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
213 warning ("opengl_texture::create: invalid texture data type (expected double or uint8)");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
214 }
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
215
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
216 if (ok)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
217 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
218 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
219 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
220
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
221 if (glGetError () != GL_NO_ERROR)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
222 warning ("opengl_texture::create: OpenGL error while generating texture data");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
223 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
224 retval = opengl_texture (new texture_rep (id, w, h, tw, th));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
225 }
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
226 }
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
227 else
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
228 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
229
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
230 return retval;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
231 }
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
232
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
233 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
234 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
235 {
8ff92634982d Add initial 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 public:
8724
a50228129dba Introduce new macro OCTAVE_GLUTESSCALLBACK_THREEDOTS. Use definitions HAVE_FRAMEWORK_OPENGL and HAVE_GLUTESSCALLBACK_THREEDOTS for Mac's framework OpenGL implementation.
Ben Abbott <bpabbott@mac.com>
parents: 8674
diff changeset
237 #if defined (HAVE_FRAMEWORK_OPENGL) && defined (HAVE_GLUTESSCALLBACK_THREEDOTS)
a50228129dba Introduce new macro OCTAVE_GLUTESSCALLBACK_THREEDOTS. Use definitions HAVE_FRAMEWORK_OPENGL and HAVE_GLUTESSCALLBACK_THREEDOTS for Mac's framework OpenGL implementation.
Ben Abbott <bpabbott@mac.com>
parents: 8674
diff changeset
238 typedef GLvoid (CALLBACK *fcn) (...);
a50228129dba Introduce new macro OCTAVE_GLUTESSCALLBACK_THREEDOTS. Use definitions HAVE_FRAMEWORK_OPENGL and HAVE_GLUTESSCALLBACK_THREEDOTS for Mac's framework OpenGL implementation.
Ben Abbott <bpabbott@mac.com>
parents: 8674
diff changeset
239 #else
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
240 typedef void (CALLBACK *fcn) (void);
8724
a50228129dba Introduce new macro OCTAVE_GLUTESSCALLBACK_THREEDOTS. Use definitions HAVE_FRAMEWORK_OPENGL and HAVE_GLUTESSCALLBACK_THREEDOTS for Mac's framework OpenGL implementation.
Ben Abbott <bpabbott@mac.com>
parents: 8674
diff changeset
241 #endif
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
242
8ff92634982d Add initial 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 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
244
11584
cda4aa780d58 Another round of initialising members in the constructor initialisation list
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11576
diff changeset
245 opengl_tesselator (void) : glu_tess (0), fill() { init (); }
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
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 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
248 { 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
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 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
251 {
8ff92634982d Add initial 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 gluTessProperty (glu_tess, GLU_TESS_BOUNDARY_ONLY,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
253 (filled ? GL_FALSE : GL_TRUE));
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
254 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
255 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
256 }
8ff92634982d Add initial 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
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
258 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
259 { 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
260
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
261 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
262 { 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
263
8ff92634982d Add initial 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 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
265 { 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
266
8ff92634982d Add initial 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 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
268 { 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
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 protected:
7870
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
271 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
272
8ff92634982d Add initial 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 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
274
7870
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
275 virtual void vertex (void */*data*/) { }
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
276
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
277 virtual void combine (GLdouble /*c*/[3], void */*data*/[4],
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
278 GLfloat /*w*/[4], void **/*out_data*/) { }
7870
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
279
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
280 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
281
8ff92634982d Add initial 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 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
283 { ::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
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 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
286 {
8ff92634982d Add initial 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 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
288
8ff92634982d Add initial 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 gluTessCallback (glu_tess, GLU_TESS_BEGIN_DATA,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
290 reinterpret_cast<fcn> (tess_begin));
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
291 gluTessCallback (glu_tess, GLU_TESS_END_DATA,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
292 reinterpret_cast<fcn> (tess_end));
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
293 gluTessCallback (glu_tess, GLU_TESS_VERTEX_DATA,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
294 reinterpret_cast<fcn> (tess_vertex));
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
295 gluTessCallback (glu_tess, GLU_TESS_COMBINE_DATA,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
296 reinterpret_cast<fcn> (tess_combine));
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
297 gluTessCallback (glu_tess, GLU_TESS_EDGE_FLAG_DATA,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
298 reinterpret_cast<fcn> (tess_edge_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
299 gluTessCallback (glu_tess, GLU_TESS_ERROR_DATA,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
300 reinterpret_cast<fcn> (tess_error));
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
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
8ff92634982d Add initial 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 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
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 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
306 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
307 { reinterpret_cast<opengl_tesselator *> (t)->begin (type); }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
308
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
309 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
310 { reinterpret_cast<opengl_tesselator *> (t)->end (); }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
311
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
312 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
313 { reinterpret_cast<opengl_tesselator *> (t)->vertex (v); }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
314
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
315 static void CALLBACK tess_combine (GLdouble c[3], void *v[4], GLfloat w[4],
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
316 void **out, void *t)
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
317 { reinterpret_cast<opengl_tesselator *> (t)->combine (c, v, w, out); }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
318
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
319 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
320 { reinterpret_cast<opengl_tesselator *> (t)->edge_flag (flag); }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
321
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
322 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
323 { 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
324
8ff92634982d Add initial 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 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
326 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
327 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
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
8ff92634982d Add initial 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 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
331 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
332 {
8ff92634982d Add initial 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 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
334 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
335 {
8ff92634982d Add initial 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 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
337 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
338 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
339 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
340 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
341 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
342 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
343 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
344 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
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 // 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
347 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
348
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
349 vertex_data_rep (void)
11584
cda4aa780d58 Another round of initialising members in the constructor initialisation list
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11576
diff changeset
350 : coords (), color (), normal (), alpha (),
cda4aa780d58 Another round of initialising members in the constructor initialisation list
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11576
diff changeset
351 ambient (), diffuse (), specular (), specular_exp (),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
352
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
353 vertex_data_rep (const Matrix& c, const Matrix& col, const Matrix& n,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
354 double a, float as, float ds, float ss, float se)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
355 : coords (c), color (col), normal (n), alpha (a),
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
356 ambient (as), diffuse (ds), specular (ss), specular_exp (se),
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
357 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
358 };
8ff92634982d Add initial 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
8ff92634982d Add initial 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 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
361 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
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_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
364 {
8ff92634982d Add initial 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 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
366
8ff92634982d Add initial 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 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
368 }
8ff92634982d Add initial 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
8ff92634982d Add initial 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 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
371 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
372 { 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
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 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
375 { 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
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 vertex_data (const Matrix& c, const Matrix& col, const Matrix& n,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
378 double a, float as, float ds, float ss, float se)
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
379 : 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
380 { }
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
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 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
383 : 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
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 ~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
386 {
8ff92634982d Add initial 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 if (--rep->count == 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
388 delete 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
389 }
8ff92634982d Add initial 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
8ff92634982d Add initial 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 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
392 {
8ff92634982d Add initial 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 if (--rep->count == 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
394 delete 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
395
8ff92634982d Add initial 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 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
397 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
398
8ff92634982d Add initial 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 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
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
8ff92634982d Add initial 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 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
403 };
8ff92634982d Add initial 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
8ff92634982d Add initial 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 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
406 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
407 {
8ff92634982d Add initial 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 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
409 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
410 : 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
411 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
412 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
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 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
415 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
416 {
8ff92634982d Add initial 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 //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
418 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
419
8ff92634982d Add initial 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 if (color_mode == 2 || light_mode == 2)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
421 glShadeModel (GL_SMOOTH);
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
422 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
423 glShadeModel (GL_FLAT);
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
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 if (is_filled ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
426 renderer->set_polygon_offset (true, 1+index);
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
427
8ff92634982d Add initial 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 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
429 }
8ff92634982d Add initial 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
8ff92634982d Add initial 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 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
432 {
8ff92634982d Add initial 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 //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
434 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
435 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
436 }
8ff92634982d Add initial 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
8ff92634982d Add initial 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 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
439 {
8ff92634982d Add initial 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 vertex_data::vertex_data_rep *v
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
441 = reinterpret_cast<vertex_data::vertex_data_rep *> (data);
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
442 //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
443
8ff92634982d Add initial 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 // FIXME: why did I need to keep the first vertex of the face
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
445 // in JHandles? I think it's related to the fact that the
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
446 // 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
447 // 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
448 // 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
449 if (color_mode > 0 && (first || color_mode == 2))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
450 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
451 Matrix col = v->color;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
452
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
453 if (col.numel () == 3)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
454 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
455 glColor3dv (col.data ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
456 if (light_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
457 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
458 float buf[4] = { 0, 0, 0, 1 };
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
459
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
460 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
461 buf[k] = (v->ambient * col(k));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
462 glMaterialfv (LIGHT_MODE, GL_AMBIENT, buf);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
463
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
464 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
465 buf[k] = (v->diffuse * col(k));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
466 glMaterialfv (LIGHT_MODE, GL_AMBIENT, buf);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
467 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
468 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
469 }
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
470
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
471 if (light_mode > 0 && (first || light_mode == 2))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
472 glNormal3dv (v->normal.data ());
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
473
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
474 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
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 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
477 }
8ff92634982d Add initial 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
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
479 void combine (GLdouble xyz[3], void *data[4], GLfloat w[4],
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
480 void **out_data)
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
481 {
8ff92634982d Add initial 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 //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
483
7837
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
484 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
485 int vmax = 4;
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
486
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
487 for (int i = 0; i < 4; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
488 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
489 v[i] = reinterpret_cast<vertex_data::vertex_data_rep *> (data[i]);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
490
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
491 if (vmax == 4 && ! v[i])
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
492 vmax = i;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
493 }
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
494
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
495 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
496 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
497 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
498 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
499
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
500 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
501 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
502 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
503
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
504 if (v[0]->color.numel ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
505 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
506 cc.resize (1, 3, 0.0);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
507 for (int ic = 0; ic < 3; ic++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
508 for (int iv = 0; iv < vmax; iv++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
509 cc(ic) += (w[iv] * v[iv]->color(ic));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
510 }
7837
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
511
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
512 if (v[0]->normal.numel () > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
513 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
514 for (int in = 0; in < 3; in++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
515 for (int iv = 0; iv < vmax; iv++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
516 nn(in) += (w[iv] * v[iv]->normal(in));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
517 }
7837
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
518
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
519 for (int iv = 0; iv < vmax; iv++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
520 aa += (w[iv] * v[iv]->alpha);
7837
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
521
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
522 vertex_data new_v (vv, cc, nn, aa, v[0]->ambient, v[0]->diffuse,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
523 v[0]->specular, v[0]->specular_exp);
7837
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
524 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
525
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
526 *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
527 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
528
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
529 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
530 opengl_renderer *renderer;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
531 int color_mode; // 0: uni, 1: flat, 2: interp
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
532 int light_mode; // 0: none, 1: flat, 2: gouraud
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
533 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
534 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
535 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
536 };
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
537
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
538 void
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
539 opengl_renderer::draw (const graphics_object& go)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
540 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
541 if (! go.valid_object ())
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
542 return;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
543
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
544 const base_properties& props = go.get_properties ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
545
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
546 if (go.isa ("figure"))
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9687
diff changeset
547 draw_figure (dynamic_cast<const figure::properties&> (props));
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
548 else if (go.isa ("axes"))
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9687
diff changeset
549 draw_axes (dynamic_cast<const axes::properties&> (props));
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
550 else if (go.isa ("line"))
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9687
diff changeset
551 draw_line (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
552 else if (go.isa ("surface"))
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9687
diff changeset
553 draw_surface (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
554 else if (go.isa ("patch"))
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9687
diff changeset
555 draw_patch (dynamic_cast<const patch::properties&> (props));
7866
35e8d6199455 Add hggroup support in OpenGL renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7851
diff changeset
556 else if (go.isa ("hggroup"))
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9687
diff changeset
557 draw_hggroup (dynamic_cast<const hggroup::properties&> (props));
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
558 else if (go.isa ("text"))
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9687
diff changeset
559 draw_text (dynamic_cast<const text::properties&> (props));
9680
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9616
diff changeset
560 else if (go.isa ("image"))
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9687
diff changeset
561 draw_image (dynamic_cast<const image::properties&> (props));
11186
f72e17e70378 gl-render.cc: Do not give rendering error for uimenus.
Ben Abbott <bpabbott@mac.com>
parents: 11175
diff changeset
562 else if (go.isa ("uimenu"))
f72e17e70378 gl-render.cc: Do not give rendering error for uimenus.
Ben Abbott <bpabbott@mac.com>
parents: 11175
diff changeset
563 ;
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
564 else
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
565 warning ("opengl_renderer: cannot render object of type `%s'",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
566 props.graphics_object_name ().c_str ());
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
567 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
568
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
569 void
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9687
diff changeset
570 opengl_renderer::draw_figure (const figure::properties& props)
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
571 {
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
572 toolkit = props.get_toolkit ();
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
573
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
574 // Initialize OpenGL context
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
575
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
576 glEnable (GL_DEPTH_TEST);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
577 glDepthFunc (GL_LEQUAL);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
578 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
579 glAlphaFunc (GL_GREATER, 0.0f);
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
580 glEnable (GL_NORMALIZE);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
581
7907
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
582 if (props.is___enhanced__ ())
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
583 {
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
584 glEnable (GL_BLEND);
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
585 glEnable (GL_LINE_SMOOTH);
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
586 }
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
587 else
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
588 {
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
589 glDisable (GL_BLEND);
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
590 glDisable (GL_LINE_SMOOTH);
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
591 }
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
592
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
593 // Clear background
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
594
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
595 Matrix c = props.get_color_rgb ();
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 if (c.length() >= 3)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
598 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
599 glClearColor (c(0), c(1), c(2), 1);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
600 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
601 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
602
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
603 // Draw children
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
604
8263
22c078fd926b make fltk backend figures work again
John W. Eaton <jwe@octave.org>
parents: 7954
diff changeset
605 draw (props.get_all_children ());
7825
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
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
608 void
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9687
diff changeset
609 opengl_renderer::draw_axes (const axes::properties& props)
7825
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 // setup OpenGL transformation
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 Matrix x_zlim = props.get_transform_zlim ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
614 Matrix x_mat1 = props.get_opengl_matrix_1 ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
615 Matrix x_mat2 = props.get_opengl_matrix_2 ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
616
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
617 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
618 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
619
8724
a50228129dba Introduce new macro OCTAVE_GLUTESSCALLBACK_THREEDOTS. Use definitions HAVE_FRAMEWORK_OPENGL and HAVE_GLUTESSCALLBACK_THREEDOTS for Mac's framework OpenGL implementation.
Ben Abbott <bpabbott@mac.com>
parents: 8674
diff changeset
620 #if defined (HAVE_FRAMEWORK_OPENGL)
a50228129dba Introduce new macro OCTAVE_GLUTESSCALLBACK_THREEDOTS. Use definitions HAVE_FRAMEWORK_OPENGL and HAVE_GLUTESSCALLBACK_THREEDOTS for Mac's framework OpenGL implementation.
Ben Abbott <bpabbott@mac.com>
parents: 8674
diff changeset
621 GLint vw[4];
a50228129dba Introduce new macro OCTAVE_GLUTESSCALLBACK_THREEDOTS. Use definitions HAVE_FRAMEWORK_OPENGL and HAVE_GLUTESSCALLBACK_THREEDOTS for Mac's framework OpenGL implementation.
Ben Abbott <bpabbott@mac.com>
parents: 8674
diff changeset
622 #else
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
623 int vw[4];
8724
a50228129dba Introduce new macro OCTAVE_GLUTESSCALLBACK_THREEDOTS. Use definitions HAVE_FRAMEWORK_OPENGL and HAVE_GLUTESSCALLBACK_THREEDOTS for Mac's framework OpenGL implementation.
Ben Abbott <bpabbott@mac.com>
parents: 8674
diff changeset
624 #endif
a50228129dba Introduce new macro OCTAVE_GLUTESSCALLBACK_THREEDOTS. Use definitions HAVE_FRAMEWORK_OPENGL and HAVE_GLUTESSCALLBACK_THREEDOTS for Mac's framework OpenGL implementation.
Ben Abbott <bpabbott@mac.com>
parents: 8674
diff changeset
625
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
626 glGetIntegerv (GL_VIEWPORT, vw);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
627
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
628 glMatrixMode (GL_MODELVIEW);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
629 glLoadIdentity ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
630 glScaled(1, 1, -1);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
631 glMultMatrixd (x_mat1.data ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
632 glMatrixMode (GL_PROJECTION);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
633 glLoadIdentity ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
634 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
635 glMultMatrixd (x_mat2.data ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
636 glMatrixMode (GL_MODELVIEW);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
637
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
638 glClear (GL_DEPTH_BUFFER_BIT);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
639
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
640 // store axes transformation data
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
641
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
642 xform = props.get_transform ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
643
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
644 // draw axes object
7907
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
645
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
646 GLboolean antialias;
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
647 glGetBooleanv (GL_LINE_SMOOTH, &antialias);
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
648 glDisable (GL_LINE_SMOOTH);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
649
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
650 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
651 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
652 Matrix zlim = xform.zscale (props.get_zlim ().matrix_value ());
7870
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
653 double x_min = xlim(0), x_max = xlim(1);
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
654 double y_min = ylim(0), y_max = ylim(1);
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
655 double z_min = zlim(0), z_max = zlim(1);
11484
cda6044447a0 Improve positioning of titles.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11463
diff changeset
656
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
657 double xd = (props.xdir_is ("normal") ? 1 : -1);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
658 double yd = (props.ydir_is ("normal") ? 1 : -1);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
659 double zd = (props.zdir_is ("normal") ? 1 : -1);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
660
11484
cda6044447a0 Improve positioning of titles.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11463
diff changeset
661 ColumnVector bbox(4);
cda6044447a0 Improve positioning of titles.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11463
diff changeset
662 bbox(0) = octave_Inf;
cda6044447a0 Improve positioning of titles.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11463
diff changeset
663 bbox(1) = octave_Inf;
cda6044447a0 Improve positioning of titles.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11463
diff changeset
664 bbox(2) = -octave_Inf;
cda6044447a0 Improve positioning of titles.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11463
diff changeset
665 bbox(3) = -octave_Inf;
cda6044447a0 Improve positioning of titles.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11463
diff changeset
666 for (int i = 0; i <= 1; i++)
cda6044447a0 Improve positioning of titles.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11463
diff changeset
667 for (int j = 0; j <= 1; j++)
cda6044447a0 Improve positioning of titles.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11463
diff changeset
668 for (int k = 0; k <= 1; k++)
cda6044447a0 Improve positioning of titles.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11463
diff changeset
669 {
cda6044447a0 Improve positioning of titles.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11463
diff changeset
670 ColumnVector p = xform.transform (i ? x_max : x_min, j ? y_max : y_min,
cda6044447a0 Improve positioning of titles.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11463
diff changeset
671 k ? z_max : z_min, false);
cda6044447a0 Improve positioning of titles.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11463
diff changeset
672 bbox(0) = std::min (bbox(0), p(0));
cda6044447a0 Improve positioning of titles.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11463
diff changeset
673 bbox(1) = std::min (bbox(1), p(1));
cda6044447a0 Improve positioning of titles.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11463
diff changeset
674 bbox(2) = std::max (bbox(2), p(0));
cda6044447a0 Improve positioning of titles.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11463
diff changeset
675 bbox(3) = std::max (bbox(3), p(1));
cda6044447a0 Improve positioning of titles.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11463
diff changeset
676 }
cda6044447a0 Improve positioning of titles.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11463
diff changeset
677 bbox(2) = bbox(2)-bbox(0);
cda6044447a0 Improve positioning of titles.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11463
diff changeset
678 bbox(3) = bbox(3)-bbox(1);
cda6044447a0 Improve positioning of titles.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11463
diff changeset
679
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
680 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
681 int xstate, ystate, zstate;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
682
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
683 xstate = ystate = zstate = AXE_ANY_DIR;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
684
7870
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
685 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
686 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
687 xv(0) = xround (p2(0)-p1(0));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
688 xv(1) = xround (p2(1)-p1(1));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
689 xv(2) = (p2(2)-p1(2));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
690 if (xv(0) == 0 && xv(1) == 0)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
691 xstate = AXE_DEPTH_DIR;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
692 else if (xv(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 (xv(0) == 0)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
695 xstate = AXE_VERT_DIR;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
696 else if (xv(1) == 0)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
697 xstate = 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 xPlane;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
700 if (xv(2) == 0)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
701 if (xv(1) == 0)
7870
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
702 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
703 else
7870
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
704 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
705 else
7870
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
706 xPlane = (xv(2) < 0 ? x_min : x_max);
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
707 double xPlaneN = (xPlane == x_min ? x_max : x_min);
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
708 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
709
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
710 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
711 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
712 yv(0) = xround (p2(0)-p1(0));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
713 yv(1) = xround (p2(1)-p1(1));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
714 yv(2) = (p2(2)-p1(2));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
715 if (yv(0) == 0 && yv(1) == 0)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
716 ystate = AXE_DEPTH_DIR;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
717 else if (yv(2) == 0)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
718 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
719 if (yv(0) == 0)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
720 ystate = AXE_VERT_DIR;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
721 else if (yv(1) == 0)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
722 ystate = AXE_HORZ_DIR;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
723 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
724 double yPlane;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
725 if (yv(2) == 0)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
726 if (yv(1) == 0)
7870
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
727 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
728 else
7870
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
729 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
730 else
7870
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
731 yPlane = (yv(2) < 0 ? y_min : y_max);
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
732 double yPlaneN = (yPlane == y_min ? y_max : y_min);
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
733 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
734
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
735 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
736 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
737 zv(0) = xround(p2(0)-p1(0));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
738 zv(1) = xround (p2(1)-p1(1));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
739 zv(2) = (p2(2)-p1(2));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
740 if (zv(0) == 0 && zv(1) == 0)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
741 zstate = AXE_DEPTH_DIR;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
742 else if (zv(2) == 0)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
743 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
744 if (zv(0) == 0)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
745 zstate = AXE_VERT_DIR;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
746 else if (zv(1) == 0)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
747 zstate = AXE_HORZ_DIR;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
748 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
749 double zPlane;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
750 if (zv(2) == 0)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
751 if (zv(1) == 0)
7870
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
752 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
753 else
7870
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
754 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
755 else
7870
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
756 zPlane = (zv(2) < 0 ? z_min : z_max);
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
757 double zPlaneN = (zPlane == z_min ? z_max : z_min);
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
758 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
759
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
760 bool mode2d = (((xstate > AXE_DEPTH_DIR ? 1 : 0) +
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
761 (ystate > AXE_DEPTH_DIR ? 1 : 0) +
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
762 (zstate > AXE_DEPTH_DIR ? 1 : 0)) == 2);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
763 if (props.tickdirmode_is ("auto"))
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 // FIXME: tickdir should be updated (code below comes
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
766 // from JHandles)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
767 //autoMode++;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
768 //TickDir.set(mode2d ? "in" : "out", true);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
769 //autoMode--;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
770 }
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 // FIXME: use ticklength property
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
773 double xticklen = 7, yticklen = 7, zticklen = 7;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
774
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
775 //double tickdir = (props.tickdir_is ("in") ? -1 : 1);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
776 double tickdir = (props.tickdirmode_is ("auto") ?
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
777 (mode2d ? -1 : 1) :
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
778 (props.tickdir_is ("in") ? -1 : 1));
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
779 double xtickoffset = (mode2d && tickdir < 0 ? 0 : xticklen) + 5;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
780 double ytickoffset = (mode2d && tickdir < 0 ? 0 : yticklen) + 5;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
781 double ztickoffset = (mode2d && tickdir < 0 ? 0 : zticklen) + 5;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
782
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
783 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
784 bool x2Dtop = false;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
785 bool y2Dright = false;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
786 double zpTick = zPlane;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
787
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
788 /* 2D mode */
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
789 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
790 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
791 if (props.xaxislocation_is ("top"))
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
792 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
793 double tmp = yPlane;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
794 yPlane = yPlaneN;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
795 yPlaneN = tmp;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
796 x2Dtop = true;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
797 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
798 if (props.yaxislocation_is ("right"))
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 double tmp = xPlane;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
801 xPlane = xPlaneN;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
802 xPlaneN = tmp;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
803 y2Dright = true;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
804 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
805 if (props.layer_is ("top"))
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
806 zpTick = zPlaneN;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
807 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
808
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
809 Matrix axe_color = props.get_color_rgb ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
810 bool visible = props.is_visible ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
811 bool box = props.is_box ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
812
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
813 // Axes planes
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
814
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
815 if (axe_color.numel () > 0 && visible)
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 set_color (axe_color);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
818 set_polygon_offset (true, 2.5);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
819
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
820 glBegin (GL_QUADS);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
821
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
822 // X plane
7870
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
823 glVertex3d (xPlane, y_min, z_min);
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
824 glVertex3d (xPlane, y_max, z_min);
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
825 glVertex3d (xPlane, y_max, z_max);
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
826 glVertex3d (xPlane, y_min, z_max);
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
827
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
828 // Y plane
7870
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
829 glVertex3d (x_min, yPlane, z_min);
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
830 glVertex3d (x_max, yPlane, z_min);
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
831 glVertex3d (x_max, yPlane, z_max);
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
832 glVertex3d (x_min, yPlane, z_max);
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
833
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
834 // Z plane
7870
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
835 glVertex3d (x_min, y_min, zPlane);
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
836 glVertex3d (x_max, y_min, zPlane);
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
837 glVertex3d (x_max, y_max, zPlane);
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
838 glVertex3d (x_min, y_max, zPlane);
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
839
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
840 glEnd ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
841
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
842 set_polygon_offset (false);
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
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
845 // Axes box
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
846
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
847 set_linestyle ("-", true);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
848 set_linewidth (props.get_linewidth ());
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 if (visible)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
851 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
852 glBegin (GL_LINES);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
853
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
854 // X box
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
855 set_color (props.get_xcolor_rgb ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
856 glVertex3d (xPlaneN, yPlaneN, zPlane);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
857 glVertex3d (xPlane, yPlaneN, zPlane);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
858 if (box)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
859 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
860 glVertex3d (xPlaneN, yPlane, zPlane);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
861 glVertex3d (xPlane, yPlane, zPlane);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
862 glVertex3d (xPlaneN, yPlane, zPlaneN);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
863 glVertex3d (xPlane, yPlane, zPlaneN);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
864 glVertex3d (xPlaneN, yPlaneN, zPlaneN);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
865 glVertex3d (xPlane, yPlaneN, zPlaneN);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
866 }
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 // Y box
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
869 set_color (props.get_ycolor_rgb ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
870 glVertex3d (xPlaneN, yPlaneN, zPlane);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
871 glVertex3d (xPlaneN, yPlane, zPlane);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
872 if (box)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
873 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
874 glVertex3d (xPlane, yPlaneN, zPlane);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
875 glVertex3d (xPlane, yPlane, zPlane);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
876 glVertex3d (xPlane, yPlaneN, zPlaneN);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
877 glVertex3d (xPlane, yPlane, zPlaneN);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
878 glVertex3d (xPlaneN, yPlaneN, zPlaneN);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
879 glVertex3d (xPlaneN, yPlane, zPlaneN);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
880 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
881
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
882 // Z box
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
883 set_color (props.get_zcolor_rgb ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
884 if (xySym)
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 glVertex3d (xPlaneN, yPlane, zPlaneN);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
887 glVertex3d (xPlaneN, yPlane, zPlane);
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 else
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
890 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
891 glVertex3d (xPlane, yPlaneN, zPlaneN);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
892 glVertex3d (xPlane, yPlaneN, zPlane);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
893 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
894 if (box)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
895 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
896 glVertex3d (xPlane, yPlane, zPlaneN);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
897 glVertex3d (xPlane, yPlane, zPlane);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
898 if (xySym)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
899 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
900 glVertex3d (xPlane, yPlaneN, zPlaneN);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
901 glVertex3d (xPlane, yPlaneN, zPlane);
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 else
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
904 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
905 glVertex3d (xPlaneN, yPlane, zPlaneN);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
906 glVertex3d (xPlaneN, yPlane, zPlane);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
907 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
908 glVertex3d (xPlaneN, yPlaneN, zPlaneN);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
909 glVertex3d (xPlaneN, yPlaneN, zPlane);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
910 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
911
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
912 glEnd ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
913 }
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 std::string gridstyle = props.get_gridlinestyle ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
916 std::string minorgridstyle = props.get_minorgridlinestyle ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
917
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
918 set_font (props);
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
919
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
920 // X grid
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
921
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
922 if (visible && xstate != AXE_DEPTH_DIR)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
923 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
924 bool do_xgrid = (props.is_xgrid () && (gridstyle != "none"));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
925 bool do_xminorgrid = (props.is_xminorgrid () && (minorgridstyle != "none"));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
926 bool do_xminortick = props.is_xminortick ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
927 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
928 // FIXME: use pre-computed minor ticks
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
929 Matrix xmticks;
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
930 string_vector xticklabels = props.get_xticklabel ().all_strings ();
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
931 int wmax = 0, hmax = 0;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
932 bool tick_along_z = xisinf (fy);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
933 Matrix tickpos (xticks.numel (), 3);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
934
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
935 set_color (props.get_xcolor_rgb ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
936
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
937 // grid lines
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
938 if (do_xgrid)
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 set_linestyle (gridstyle, true);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
941 glBegin (GL_LINES);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
942 for (int i = 0; i < xticks.numel (); i++)
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 double xval = xticks(i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
945
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
946 if (xlim(0) <= xval && xlim(1) >= xval)
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
947 {
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
948 glVertex3d (xval, yPlaneN, zpTick);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
949 glVertex3d (xval, yPlane, zpTick);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
950 if (zstate != AXE_DEPTH_DIR)
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
951 {
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
952 glVertex3d (xval, yPlane, zPlaneN);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
953 glVertex3d (xval, yPlane, zPlane);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
954 }
7825
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 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
957 glEnd ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
958 set_linestyle ("-", true);
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
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
961 // tick marks
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
962 if (tick_along_z)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
963 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
964 glBegin (GL_LINES);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
965 for (int i = 0; i < xticks.numel (); i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
966 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
967 double xval = xticks(i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
968
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
969 if (xlim(0) <= xval && xlim(1) >= xval)
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
970 {
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
971 glVertex3d (xval, yPlaneN, zPlane);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
972 glVertex3d (xval, yPlaneN, zPlane+signum(zPlane-zPlaneN)*fz*xticklen*tickdir);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
973 if (box && xstate != AXE_ANY_DIR)
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
974 {
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
975 glVertex3d (xval, yPlaneN, zPlaneN);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
976 glVertex3d (xval, yPlaneN,
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
977 zPlaneN+signum(zPlaneN-zPlane)*fz*xticklen*tickdir);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
978 }
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
979 tickpos(i,0) = xval;
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
980 tickpos(i,1) = yPlaneN;
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
981 tickpos(i,2) = zPlane+signum(zPlane-zPlaneN)*fz*xtickoffset;
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
982 }
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 glEnd ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
985 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
986 else
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
987 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
988 glBegin (GL_LINES);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
989 for (int i = 0; i < xticks.numel (); i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
990 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
991 double xval = xticks(i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
992
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
993 if (xlim(0) <= xval && xlim(1) >= xval)
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
994 {
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
995 glVertex3d (xval, yPlaneN, zpTick);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
996 glVertex3d (xval, yPlaneN+signum(yPlaneN-yPlane)*fy*xticklen*tickdir, zpTick);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
997 if (box && xstate != AXE_ANY_DIR)
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
998 {
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
999 glVertex3d (xval, yPlane, zpTick);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1000 glVertex3d (xval,
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1001 yPlane+signum(yPlane-yPlaneN)*fy*xticklen*tickdir, zpTick);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1002 }
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1003 tickpos(i,0) = xval;
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1004 tickpos(i,1) = yPlaneN+signum(yPlaneN-yPlane)*fy*xtickoffset;
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1005 tickpos(i,2) = zPlane;
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1006 }
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 glEnd ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1009 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1010
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
1011 // tick texts
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
1012 if (xticklabels.numel () > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1013 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1014 int n = std::min (xticklabels.numel (), xticks.numel ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1015 int halign = (xstate == AXE_HORZ_DIR ? 1 : (xySym ? 0 : 2));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1016 int valign = (xstate == AXE_VERT_DIR
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1017 ? 1
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1018 : (zd*zv(2) <= 0 && !x2Dtop ? 2 : 0));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1019
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1020 for (int i = 0; i < n; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1021 {
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1022 double xval = xticks(i);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1023
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1024 if (xlim(0) <= xval && xlim(1) >= xval)
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1025 {
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1026 // FIXME: as tick text is transparent, shouldn't be
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1027 // drawn after axes object, for correct rendering?
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1028 Matrix b = render_text (xticklabels(i),
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1029 tickpos(i,0), tickpos(i,1), tickpos(i,2),
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1030 halign, valign);
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1031
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1032 wmax = std::max (wmax, static_cast<int> (b(2)));
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1033 hmax = std::max (hmax, static_cast<int> (b(3)));
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1034 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1035 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1036 }
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1037
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1038 // minor grid lines
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1039 if (do_xminorgrid)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1040 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1041 set_linestyle (minorgridstyle, true);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1042 glBegin (GL_LINES);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1043 for (int i = 0; i < xmticks.numel (); i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1044 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1045 double xval = xmticks(i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1046
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1047 if (xlim(0) <= xval && xlim(1) >= xval)
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1048 {
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1049 glVertex3d (xval, yPlaneN, zpTick);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1050 glVertex3d (xval, yPlane, zpTick);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1051 if (zstate != AXE_DEPTH_DIR)
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1052 {
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1053 glVertex3d (xval, yPlane, zPlaneN);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1054 glVertex3d (xval, yPlane, zPlane);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1055 }
7825
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 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1058 glEnd ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1059 set_linestyle ("-", true);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1060 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1061
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1062 // minor tick marks
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1063 if (do_xminortick)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1064 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1065 if (tick_along_z)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1066 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1067 glBegin (GL_LINES);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1068 for (int i = 0; i < xmticks.numel (); i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1069 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1070 double xval = xmticks(i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1071
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1072 if (xlim(0) <= xval && xlim(1) >= xval)
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1073 {
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1074 glVertex3d (xval, yPlaneN, zPlane);
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1075 glVertex3d (xval, yPlaneN,
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1076 zPlane+signum(zPlane-zPlaneN)*fz*xticklen/2*tickdir);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1077 if (box && xstate != AXE_ANY_DIR)
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1078 {
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1079 glVertex3d (xval, yPlaneN, zPlaneN);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1080 glVertex3d (xval, yPlaneN,
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1081 zPlaneN+signum(zPlaneN-zPlane)*fz*xticklen/2*tickdir);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1082 }
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1083 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1084 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1085 glEnd ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1086 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1087 else
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 glBegin (GL_LINES);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1090 for (int i = 0; i < xmticks.numel (); i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1091 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1092 double xval = xmticks(i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1093
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1094 if (xlim(0) <= xval && xlim(1) >= xval)
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1095 {
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1096 glVertex3d (xval, yPlaneN, zpTick);
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1097 glVertex3d (xval,
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1098 yPlaneN+signum(yPlaneN-yPlane)*fy*xticklen/2*tickdir, zpTick);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1099 if (box && xstate != AXE_ANY_DIR)
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1100 {
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1101 glVertex3d (xval, yPlane, zpTick);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1102 glVertex3d (xval,
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1103 yPlane+signum(yPlane-yPlaneN)*fy*xticklen/2*tickdir, zpTick);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1104 }
7825
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 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1107 glEnd ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1108 }
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
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1111 text::properties& xlabel_props =
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1112 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
1113
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
1114 xlabel_props.set_visible ("on");
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
1115
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1116 if (! xlabel_props.get_string ().empty ())
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1117 {
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1118 if (xlabel_props.horizontalalignmentmode_is("auto"))
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1119 {
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1120 xlabel_props.set_horizontalalignment (xstate > AXE_DEPTH_DIR ? "center" : (xySym ? "left" : "right"));
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1121 xlabel_props.set_horizontalalignmentmode("auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1122 }
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1123 if (xlabel_props.verticalalignmentmode_is("auto"))
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1124 {
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1125 xlabel_props.set_verticalalignment (xstate == AXE_VERT_DIR ? "bottom" : (zd*zv(2) <= 0 ? "top" : "bottom"));
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1126 xlabel_props.set_verticalalignmentmode("auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1127 }
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1128
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1129 if (xlabel_props.positionmode_is("auto") || xlabel_props.rotationmode_is("auto"))
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1130 {
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1131 double angle = 0;
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1132 ColumnVector p = graphics_xform::xform_vector ((x_min+x_max)/2, yPlaneN, zPlane);
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1133
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1134 if (tick_along_z)
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1135 p(2) += (signum(zPlane-zPlaneN)*fz*xtickoffset);
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1136 else
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1137 p(1) += (signum(yPlaneN-yPlane)*fy*xtickoffset);
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1138 p = xform.transform (p(0), p(1), p(2), false);
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1139 switch (xstate)
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1140 {
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1141 case AXE_ANY_DIR:
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1142 p(0) += (xySym ? wmax : -wmax);
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1143 p(1) += (zd*zv(2) <= 0 ? hmax : -hmax);
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1144 break;
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1145 case AXE_VERT_DIR:
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1146 p(0) -= wmax;
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1147 angle = 90;
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1148 break;
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1149 case AXE_HORZ_DIR:
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1150 p(1) += hmax;
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1151 break;
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1152 }
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1153 if (xlabel_props.positionmode_is("auto"))
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1154 {
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1155 p = xform.untransform (p(0), p(1), p(2), true);
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1156 xlabel_props.set_position (p.extract_n (0, 3).transpose ());
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1157 xlabel_props.set_positionmode ("auto");
11585
1473d0cf86d2 untabify source files
John W. Eaton <jwe@octave.org>
parents: 11584
diff changeset
1158 }
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1159 if (xlabel_props.rotationmode_is("auto"))
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1160 {
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1161 xlabel_props.set_rotation (angle);
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1162 xlabel_props.set_rotationmode ("auto");
11585
1473d0cf86d2 untabify source files
John W. Eaton <jwe@octave.org>
parents: 11584
diff changeset
1163 }
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1164 }
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 }
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
1167 else
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
1168 {
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
1169 gh_manager::get_object (props.get_xlabel ()).set ("visible", "off");
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
1170 }
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1171
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1172 // Y grid
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1173
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1174 if (ystate != AXE_DEPTH_DIR && visible)
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 bool do_ygrid = (props.is_ygrid () && (gridstyle != "none"));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1177 bool do_yminorgrid = (props.is_yminorgrid () && (minorgridstyle != "none"));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1178 bool do_yminortick = props.is_yminortick ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1179 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
1180 // FIXME: use pre-computed minor ticks
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1181 Matrix ymticks;
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
1182 string_vector yticklabels = props.get_yticklabel ().all_strings ();
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1183 int wmax = 0, hmax = 0;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1184 bool tick_along_z = xisinf (fx);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1185 Matrix tickpos (yticks.numel (), 3);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1186
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1187 set_color (props.get_ycolor_rgb ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1188
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1189 // grid lines
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1190 if (do_ygrid)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1191 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1192 set_linestyle (gridstyle, true);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1193 glBegin (GL_LINES);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1194 for (int i = 0; i < yticks.numel (); i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1195 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1196 double yval = yticks(i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1197
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1198 if (ylim(0) <= yval && ylim(1) >= yval)
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1199 {
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1200 glVertex3d (xPlaneN, yval, zpTick);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1201 glVertex3d (xPlane, yval, zpTick);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1202 if (zstate != AXE_DEPTH_DIR)
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1203 {
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1204 glVertex3d (xPlane, yval, zPlaneN);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1205 glVertex3d (xPlane, yval, zPlane);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1206 }
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1207 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1208 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1209 glEnd ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1210 set_linestyle ("-", true);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1211 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1212
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1213 // tick marks
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1214 if (tick_along_z)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1215 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1216 glBegin (GL_LINES);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1217 for (int i = 0; i < yticks.numel (); i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1218 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1219 double yval = yticks(i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1220
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1221 if (ylim(0) <= yval && ylim(1) >= yval)
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1222 {
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1223 glVertex3d (xPlaneN, yval, zPlane);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1224 glVertex3d (xPlaneN, yval, zPlane+signum(zPlane-zPlaneN)*fz*yticklen*tickdir);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1225 if (box && ystate != AXE_ANY_DIR)
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1226 {
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1227 glVertex3d (xPlaneN, yval, zPlaneN);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1228 glVertex3d (xPlaneN, yval,
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1229 zPlaneN+signum(zPlaneN-zPlane)*fz*yticklen*tickdir);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1230 }
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1231 tickpos(i,0) = xPlaneN;
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1232 tickpos(i,1) = yval;
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1233 tickpos(i,2) = zPlane+signum(zPlane-zPlaneN)*fz*ytickoffset;
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1234 }
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 glEnd ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1237 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1238 else
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 glBegin (GL_LINES);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1241 for (int i = 0; i < yticks.numel (); i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1242 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1243 double yval = yticks(i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1244
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1245 if (ylim(0) <= yval && ylim(1) >= yval)
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1246 {
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1247 glVertex3d (xPlaneN, yval, zpTick);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1248 glVertex3d (xPlaneN+signum(xPlaneN-xPlane)*fx*yticklen*tickdir, yval, zpTick);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1249 if (box && ystate != AXE_ANY_DIR)
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1250 {
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1251 glVertex3d (xPlane, yval, zpTick);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1252 glVertex3d (xPlane+signum(xPlane-xPlaneN)*fx*yticklen*tickdir,
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1253 yval, zpTick);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1254 }
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1255 tickpos(i,0) = xPlaneN+signum(xPlaneN-xPlane)*fx*ytickoffset;
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1256 tickpos(i,1) = yval;
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1257 tickpos(i,2) = zPlane;
7825
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 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1260 glEnd ();
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
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
1263 // tick texts
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
1264 if (yticklabels.numel () > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1265 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1266 int n = std::min (yticklabels.numel (), yticks.numel ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1267 int halign = (ystate == AXE_HORZ_DIR ? 1 : (!xySym || y2Dright ? 0 : 2));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1268 int valign = (ystate == AXE_VERT_DIR ? 1 : (zd*zv(2) <= 0 ? 2 : 0));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1269
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1270 for (int i = 0; i < n; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1271 {
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1272 double yval = yticks(i);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1273
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1274 if (ylim(0) <= yval && ylim(1) >= yval)
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1275 {
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1276 // FIXME: as tick text is transparent, shouldn't be
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1277 // drawn after axes object, for correct rendering?
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1278 Matrix b = render_text (yticklabels(i),
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1279 tickpos(i,0), tickpos(i,1), tickpos(i,2),
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1280 halign, valign);
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1281
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1282 wmax = std::max (wmax, static_cast<int> (b(2)));
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1283 hmax = std::max (hmax, static_cast<int> (b(3)));
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1284 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1285 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1286 }
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1287
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1288 // minor grid lines
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1289 if (do_yminorgrid)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1290 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1291 set_linestyle (minorgridstyle, true);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1292 glBegin (GL_LINES);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1293 for (int i = 0; i < ymticks.numel (); i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1294 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1295 double yval = ymticks(i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1296
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1297 if (ylim(0) <= yval && ylim(1) >= yval)
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1298 {
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1299 glVertex3d (xPlaneN, yval, zpTick);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1300 glVertex3d (xPlane, yval, zpTick);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1301 if (zstate != AXE_DEPTH_DIR)
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1302 {
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1303 glVertex3d (xPlane, yval, zPlaneN);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1304 glVertex3d (xPlane, yval, zPlane);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1305 }
7825
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 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1308 glEnd ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1309 set_linestyle ("-", true);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1310 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1311
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1312 // minor tick marks
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1313 if (do_yminortick)
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 if (tick_along_z)
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 glBegin (GL_LINES);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1318 for (int i = 0; i < ymticks.numel (); i++)
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 double yval = ymticks(i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1321
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1322 if (ylim(0) <= yval && ylim(1) >= yval)
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1323 {
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1324 glVertex3d (xPlaneN, yval, zPlane);
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1325 glVertex3d (xPlaneN, yval,
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1326 zPlane+signum(zPlane-zPlaneN)*fz*yticklen/2*tickdir);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1327 if (box && ystate != AXE_ANY_DIR)
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1328 {
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1329 glVertex3d (xPlaneN, yval, zPlaneN);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1330 glVertex3d (xPlaneN, yval,
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1331 zPlaneN+signum(zPlaneN-zPlane)*fz*yticklen/2*tickdir);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1332 }
7825
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 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1335 glEnd ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1336 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1337 else
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1338 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1339 glBegin (GL_LINES);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1340 for (int i = 0; i < ymticks.numel (); i++)
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 double yval = ymticks(i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1343
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1344 if (ylim(0) <= yval && ylim(1) >= yval)
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1345 {
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1346 glVertex3d (xPlaneN, yval, zpTick);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1347 glVertex3d (xPlaneN+signum(xPlaneN-xPlane)*fx*yticklen/2*tickdir,
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1348 yval, zpTick);
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1349 if (box && ystate != AXE_ANY_DIR)
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1350 {
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1351 glVertex3d (xPlane, yval, zpTick);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1352 glVertex3d (xPlane+signum(xPlane-xPlaneN)*fx*yticklen/2*tickdir,
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1353 yval, zpTick);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1354 }
7825
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 glEnd ();
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 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1360
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1361 text::properties& ylabel_props =
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1362 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
1363
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
1364 ylabel_props.set_visible ("on");
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
1365
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1366 if (! ylabel_props.get_string ().empty ())
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1367 {
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1368 if (ylabel_props.horizontalalignmentmode_is("auto"))
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1369 {
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1370 ylabel_props.set_horizontalalignment (ystate > AXE_DEPTH_DIR ? "center" : (!xySym ? "left" : "right"));
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1371 ylabel_props.set_horizontalalignmentmode("auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1372 }
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1373 if (ylabel_props.verticalalignmentmode_is("auto"))
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1374 {
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1375 ylabel_props.set_verticalalignment (ystate == AXE_VERT_DIR ? "bottom" : (zd*zv(2) <= 0 ? "top" : "bottom"));
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1376 ylabel_props.set_verticalalignmentmode("auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1377 }
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1378
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1379 if (ylabel_props.positionmode_is("auto") || ylabel_props.rotationmode_is("auto"))
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1380 {
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1381 double angle = 0;
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1382 ColumnVector p = graphics_xform::xform_vector (xPlaneN, (y_min+y_max)/2, zPlane);
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1383
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1384 if (tick_along_z)
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1385 p(2) += (signum(zPlane-zPlaneN)*fz*ytickoffset);
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1386 else
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1387 p(0) += (signum(xPlaneN-xPlane)*fx*ytickoffset);
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1388 p = xform.transform (p(0), p(1), p(2), false);
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1389 switch (ystate)
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1390 {
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1391 case AXE_ANY_DIR:
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1392 p(0) += (!xySym ? wmax : -wmax);
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1393 p(1) += (zd*zv(2) <= 0 ? hmax : -hmax);
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1394 break;
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1395 case AXE_VERT_DIR:
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1396 p(0) -= wmax;
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1397 angle = 90;
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1398 break;
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1399 case AXE_HORZ_DIR:
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1400 p(1) += hmax;
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1401 break;
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1402 }
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1403 if (ylabel_props.positionmode_is("auto"))
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1404 {
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1405 p = xform.untransform (p(0), p(1), p(2), true);
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1406 ylabel_props.set_position (p.extract_n (0, 3).transpose ());
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1407 ylabel_props.set_positionmode ("auto");
11585
1473d0cf86d2 untabify source files
John W. Eaton <jwe@octave.org>
parents: 11584
diff changeset
1408 }
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1409 if (ylabel_props.rotationmode_is("auto"))
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1410 {
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1411 ylabel_props.set_rotation (angle);
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1412 ylabel_props.set_rotationmode ("auto");
11585
1473d0cf86d2 untabify source files
John W. Eaton <jwe@octave.org>
parents: 11584
diff changeset
1413 }
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1414 }
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 }
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
1417 else
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
1418 {
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
1419 gh_manager::get_object (props.get_ylabel ()).set ("visible", "off");
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
1420 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1421
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1422 // Z Grid
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1423
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1424 if (zstate != AXE_DEPTH_DIR && visible)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1425 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1426 bool do_zgrid = (props.is_zgrid () && (gridstyle != "none"));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1427 bool do_zminorgrid = (props.is_zminorgrid () && (minorgridstyle != "none"));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1428 bool do_zminortick = props.is_zminortick ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1429 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
1430 // FIXME: use pre-computed minor ticks
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1431 Matrix zmticks;
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
1432 string_vector zticklabels = props.get_zticklabel ().all_strings ();
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1433 int wmax = 0, hmax = 0;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1434 Matrix tickpos (zticks.numel (), 3);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1435
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1436 set_color (props.get_zcolor_rgb ());
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 // grid lines
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1439 if (do_zgrid)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1440 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1441 set_linestyle (gridstyle, true);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1442 glBegin (GL_LINES);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1443 for (int i = 0; i < zticks.numel (); i++)
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 double zval = zticks(i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1446
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1447 if (zlim(0) <= zval && zlim(1) >= zval)
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1448 {
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1449 glVertex3d (xPlaneN, yPlane, zval);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1450 glVertex3d (xPlane, yPlane, zval);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1451 glVertex3d (xPlane, yPlaneN, zval);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1452 glVertex3d (xPlane, yPlane, zval);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1453 }
7825
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 glEnd ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1456 set_linestyle ("-", true);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1457 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1458
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1459 // tick marks
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1460 if (xySym)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1461 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1462 if (xisinf (fy))
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1463 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1464 glBegin (GL_LINES);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1465 for (int i = 0; i < zticks.numel (); i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1466 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1467 double zval = zticks(i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1468
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1469 if (zlim(0) <= zval && zlim(1) >= zval)
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1470 {
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1471 glVertex3d (xPlaneN, yPlane, zval);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1472 glVertex3d (xPlaneN+signum(xPlaneN-xPlane)*fx*zticklen*tickdir,
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1473 yPlane, zval);
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1474 if (box && zstate != AXE_ANY_DIR)
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1475 {
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1476 glVertex3d (xPlane, yPlane, zval);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1477 glVertex3d (xPlane+signum(xPlane-xPlaneN)*fx*zticklen*tickdir,
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1478 yPlane, zval);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1479 }
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1480 tickpos(i,0) = xPlaneN+signum(xPlaneN-xPlane)*fx*ztickoffset;
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1481 tickpos(i,1) = yPlane;
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1482 tickpos(i,2) = zval;
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1483 }
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 glEnd ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1486 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1487 else
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1488 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1489 glBegin (GL_LINES);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1490 for (int i = 0; i < zticks.numel (); i++)
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 double zval = zticks(i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1493
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1494 if (zlim(0) <= zval && zlim(1) >= zval)
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1495 {
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1496 glVertex3d (xPlaneN, yPlane, zval);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1497 glVertex3d (xPlaneN, yPlane+signum(yPlane-yPlaneN)*fy*zticklen*tickdir, zval);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1498 tickpos(i,0) = xPlaneN;
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1499 tickpos(i,1) = yPlane+signum(yPlane-yPlaneN)*fy*ztickoffset;
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1500 tickpos(i,2) = zval;
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1501 }
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1502 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1503 glEnd ();
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 else
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1507 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1508 if (xisinf (fx))
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1509 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1510 glBegin (GL_LINES);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1511 for (int i = 0; i < zticks.numel (); i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1512 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1513 double zval = zticks(i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1514
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1515 if (zlim(0) <= zval && zlim(1) >= zval)
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1516 {
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1517 glVertex3d (xPlane, yPlaneN, zval);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1518 glVertex3d (xPlane, yPlaneN+signum(yPlaneN-yPlane)*fy*zticklen*tickdir, zval);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1519 if (box && zstate != AXE_ANY_DIR)
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1520 {
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1521 glVertex3d (xPlane, yPlane, zval);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1522 glVertex3d (xPlane, yPlane+signum(yPlane-yPlaneN)*fy*zticklen*tickdir, zval);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1523 }
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1524 tickpos(i,0) = xPlane;
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1525 tickpos(i,1) = yPlaneN+signum(yPlaneN-yPlane)*fy*ztickoffset;
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1526 tickpos(i,2) = zval;
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1527 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1528 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1529 glEnd ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1530 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1531 else
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1532 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1533 glBegin (GL_LINES);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1534 for (int i = 0; i < zticks.numel (); i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1535 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1536 double zval = zticks(i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1537
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1538 if (zlim(0) <= zval && zlim(1) >= zval)
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1539 {
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1540 glVertex3d (xPlane, yPlaneN, zval);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1541 glVertex3d (xPlane+signum(xPlane-xPlaneN)*fx*zticklen*tickdir, yPlaneN, zval);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1542 tickpos(i,0) = xPlane+signum(xPlane-xPlaneN)*fx*ztickoffset;
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1543 tickpos(i,1) = yPlaneN;
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1544 tickpos(i,2) = zval;
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1545 }
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1546 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1547 glEnd ();
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
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1551 // FIXME: tick texts
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
1552 if (zticklabels.numel () > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1553 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1554 int n = std::min (zticklabels.numel (), zticks.numel ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1555 int halign = 2;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1556 int valign = (zstate == AXE_VERT_DIR ? 1 : (zd*zv(2) < 0 ? 3 : 2));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1557
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1558 for (int i = 0; i < n; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1559 {
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1560 double zval = zticks(i);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1561
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1562 if (zlim(0) <= zval && zlim(1) >= zval)
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1563 {
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1564 // FIXME: as tick text is transparent, shouldn't be
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1565 // drawn after axes object, for correct rendering?
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1566 Matrix b = render_text (zticklabels(i),
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1567 tickpos(i,0), tickpos(i,1), tickpos(i,2),
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1568 halign, valign);
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1569
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1570 wmax = std::max (wmax, static_cast<int> (b(2)));
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1571 hmax = std::max (hmax, static_cast<int> (b(3)));
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1572 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1573 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1574 }
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1575
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1576 // minor grid lines
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1577 if (do_zminorgrid)
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_linestyle (minorgridstyle, true);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1580 glBegin (GL_LINES);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1581 for (int i = 0; i < zmticks.numel (); i++)
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 double zval = zmticks(i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1584
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1585 if (zlim(0) <= zval && zlim(1) >= zval)
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1586 {
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1587 glVertex3d (xPlaneN, yPlane, zval);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1588 glVertex3d (xPlane, yPlane, zval);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1589 glVertex3d (xPlane, yPlaneN, zval);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1590 glVertex3d (xPlane, yPlane, zval);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1591 }
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1592 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1593 glEnd ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1594 set_linestyle ("-", true);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1595 }
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 // minor tick marks
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1598 if (do_zminortick)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1599 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1600 if (xySym)
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 if (xisinf (fy))
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 glBegin (GL_LINES);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1605 for (int i = 0; i < zmticks.numel (); i++)
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 double zval = zmticks(i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1608
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1609 if (zlim(0) <= zval && zlim(1) >= zval)
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1610 {
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1611 glVertex3d (xPlaneN, yPlane, zval);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1612 glVertex3d (xPlaneN+signum(xPlaneN-xPlane)*fx*zticklen/2*tickdir,
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1613 yPlane, zval);
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1614 if (box && zstate != AXE_ANY_DIR)
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1615 {
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1616 glVertex3d (xPlane, yPlane, zval);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1617 glVertex3d (xPlane+signum(xPlane-xPlaneN)*fx*zticklen/2*tickdir,
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1618 yPlane, zval);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1619 }
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1620 }
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 glEnd ();
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 else
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1625 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1626 glBegin (GL_LINES);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1627 for (int i = 0; i < zmticks.numel (); i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1628 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1629 double zval = zmticks(i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1630
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1631 if (zlim(0) <= zval && zlim(1) >= zval)
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1632 {
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1633 glVertex3d (xPlaneN, yPlane, zval);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1634 glVertex3d (xPlaneN, yPlane+signum(yPlane-yPlaneN)*fy*zticklen/2*tickdir, zval);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1635 }
7825
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 glEnd ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1638 }
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 if (xisinf (fx))
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 glBegin (GL_LINES);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1645 for (int i = 0; i < zmticks.numel (); i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1646 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1647 double zval = zmticks(i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1648
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1649 if (zlim(0) <= zval && zlim(1) >= zval)
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1650 {
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1651 glVertex3d (xPlane, yPlaneN, zval);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1652 glVertex3d (xPlane, yPlaneN+signum(yPlaneN-yPlane)*fy*zticklen/2*tickdir, zval);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1653 if (box && zstate != AXE_ANY_DIR)
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1654 {
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1655 glVertex3d (xPlane, yPlane, zval);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1656 glVertex3d (xPlane, yPlane+signum(yPlane-yPlaneN)*fy*zticklen/2*tickdir, zval);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1657 }
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1658 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1659 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1660 glEnd ();
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 else
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1663 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1664 glBegin (GL_LINES);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1665 for (int i = 0; i < zmticks.numel (); i++)
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 double zval = zmticks(i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1668
11166
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1669 if (zlim(0) <= zval && zlim(1) >= zval)
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1670 {
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1671 glVertex3d (xPlane, yPlaneN, zval);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1672 glVertex3d (xPlane+signum(xPlane-xPlaneN)*fx*zticklen/2*tickdir, yPlaneN, zval);
9cdf43d1fa16 gl-render.cc: Crop ticks, ticklabels, and gridlines for OpenGL backend.
Ben Abbott <bpabbott@mac.com>
parents: 11163
diff changeset
1673 }
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1674 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1675 glEnd ();
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 }
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
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1680 text::properties& zlabel_props =
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1681 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
1682
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
1683 zlabel_props.set_visible ("on");
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
1684
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1685 if (! zlabel_props.get_string ().empty ())
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1686 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1687 bool camAuto = props.cameraupvectormode_is ("auto");
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1688
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1689 if (zlabel_props.horizontalalignmentmode_is("auto"))
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1690 {
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1691 zlabel_props.set_horizontalalignment ((zstate > AXE_DEPTH_DIR || camAuto) ? "center" : "right");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1692 zlabel_props.set_horizontalalignmentmode("auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1693 }
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1694 if (zlabel_props.verticalalignmentmode_is("auto"))
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1695 {
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1696 zlabel_props.set_verticalalignment(zstate == AXE_VERT_DIR ? "bottom" : ((zd*zv(2) < 0 || camAuto) ? "bottom" : "top"));
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1697 zlabel_props.set_verticalalignmentmode("auto");
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1698 }
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1699
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1700 if (zlabel_props.positionmode_is("auto") || zlabel_props.rotationmode_is("auto"))
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1701 {
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1702 double angle = 0;
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1703 ColumnVector p;
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1704
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1705 if (xySym)
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1706 {
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1707 p = graphics_xform::xform_vector (xPlaneN, yPlane, (z_min+z_max)/2);
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1708 if (xisinf (fy))
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1709 p(0) += (signum(xPlaneN-xPlane)*fx*ztickoffset);
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1710 else
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1711 p(1) += (signum(yPlane-yPlaneN)*fy*ztickoffset);
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1712 }
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1713 else
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1714 {
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1715 p = graphics_xform::xform_vector (xPlane, yPlaneN, (z_min+z_max)/2);
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1716 if (xisinf (fx))
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1717 p(1) += (signum(yPlaneN-yPlane)*fy*ztickoffset);
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1718 else
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1719 p(0) += (signum(xPlane-xPlaneN)*fx*ztickoffset);
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1720 }
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1721 p = xform.transform (p(0), p(1), p(2), false);
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1722 switch (zstate)
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1723 {
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1724 case AXE_ANY_DIR:
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1725 if (camAuto)
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1726 {
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1727 p(0) -= wmax;
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1728 angle = 90;
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1729 }
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1730 /* FIXME: what's the correct offset?
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1731 p[0] += (!xySym ? wmax : -wmax);
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1732 p[1] += (zd*zv[2] <= 0 ? hmax : -hmax);
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1733 */
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1734 break;
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1735 case AXE_VERT_DIR:
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1736 p(0) -= wmax;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1737 angle = 90;
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1738 break;
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1739 case AXE_HORZ_DIR:
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1740 p(1) += hmax;
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1741 break;
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1742 }
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1743 if (zlabel_props.positionmode_is("auto"))
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1744 {
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1745 p = xform.untransform (p(0), p(1), p(2), true);
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1746 zlabel_props.set_position (p.extract_n (0, 3).transpose ());
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1747 zlabel_props.set_positionmode ("auto");
11585
1473d0cf86d2 untabify source files
John W. Eaton <jwe@octave.org>
parents: 11584
diff changeset
1748 }
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1749 if (zlabel_props.rotationmode_is("auto"))
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1750 {
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1751 zlabel_props.set_rotation (angle);
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1752 zlabel_props.set_rotationmode ("auto");
11585
1473d0cf86d2 untabify source files
John W. Eaton <jwe@octave.org>
parents: 11584
diff changeset
1753 }
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1754 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1755 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1756 }
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
1757 else
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
1758 {
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
1759 gh_manager::get_object (props.get_zlabel ()).set ("visible", "off");
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
1760 }
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1761
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1762 set_linestyle ("-");
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1763
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1764 // Title
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1765
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1766 text::properties& title_props =
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1767 reinterpret_cast<text::properties&> (gh_manager::get_object (props.get_title ()).get_properties ());
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1768
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11266
diff changeset
1769 if (! title_props.get_string ().empty () && title_props.positionmode_is("auto"))
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1770 {
11484
cda6044447a0 Improve positioning of titles.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11463
diff changeset
1771 ColumnVector p = xform.untransform (bbox(0)+bbox(2)/2, (bbox(1)-10),
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1772 (x_zlim(0)+x_zlim(1))/2, true);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1773 title_props.set_position (p.extract_n(0, 3).transpose ());
11463
ae96756561d0 fixing bug #32074
Konstantinos Poulios <logari81@googlemail.com>
parents: 11455
diff changeset
1774 title_props.set_positionmode ("auto");
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1775 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1776
7874
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7870
diff changeset
1777 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
1778
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1779 // Children
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1780
7907
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
1781 if (antialias == GL_TRUE)
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
1782 glEnable (GL_LINE_SMOOTH);
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
1783
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
1784 Matrix children = props.get_all_children ();
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1785 std::list<graphics_object> obj_list;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1786 std::list<graphics_object>::iterator it;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1787
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1788 // 1st pass: draw light objects
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1789
11026
811d8f113423 reverse order in which child objects are processed in OpenGL renderer
John W. Eaton <jwe@octave.org>
parents: 10924
diff changeset
1790 // Start with the last element of the array of child objects to
811d8f113423 reverse order in which child objects are processed in OpenGL renderer
John W. Eaton <jwe@octave.org>
parents: 10924
diff changeset
1791 // display them in the oder they were added to the array.
811d8f113423 reverse order in which child objects are processed in OpenGL renderer
John W. Eaton <jwe@octave.org>
parents: 10924
diff changeset
1792
811d8f113423 reverse order in which child objects are processed in OpenGL renderer
John W. Eaton <jwe@octave.org>
parents: 10924
diff changeset
1793 for (octave_idx_type i = children.numel () - 1; i >= 0; i--)
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1794 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1795 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
1796
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1797 if (go.get_properties ().is_visible ())
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1798 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1799 if (go.isa ("light"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1800 draw (go);
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1801 else
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1802 obj_list.push_back (go);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1803 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1804 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1805
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1806 // 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
1807
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1808 it = obj_list.begin ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1809 while (it != obj_list.end ())
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1810 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1811 graphics_object go = (*it);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1812
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1813 // FIXME: check whether object has "units" property and it is set to "data"
9616
2093499ec9f4 avoid crash if default font can't be found
John W. Eaton <jwe@octave.org>
parents: 9406
diff changeset
1814 if (! go.isa ("text") || go.get ("units").string_value () == "data")
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1815 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1816 set_clipping (go.get_properties ().is_clipping ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1817 draw (go);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1818
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1819 it = obj_list.erase (it);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1820 }
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1821 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1822 it++;
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1823 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1824
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1825 // 3rd pass: draw remaining objects
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1826
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10350
diff changeset
1827 glDisable (GL_DEPTH_TEST);
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1828 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
1829 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1830 graphics_object go = (*it);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1831
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1832 set_clipping (go.get_properties ().is_clipping ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1833 draw (go);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1834 }
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10350
diff changeset
1835 glEnable (GL_DEPTH_TEST);
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1836
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1837 set_clipping (false);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1838 // FIXME: finalize rendering (transparency processing)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1839 // FIXME: draw zoom box, if needed
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1840 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1841
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1842 void
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9687
diff changeset
1843 opengl_renderer::draw_line (const line::properties& props)
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1844 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1845 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
1846 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
1847 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
1848
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1849 bool has_z = (z.numel () > 0);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1850 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
1851 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
1852
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1853 std::vector<octave_uint8> clip (n);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1854
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1855 if (has_z)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1856 for (int i = 0; i < n; i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1857 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
1858 else
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1859 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1860 double z_mid = (zmin+zmax)/2;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1861
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1862 for (int i = 0; i < n; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1863 clip[i] = (clip_code (x(i), y(i), z_mid) & clip_mask);
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1864 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1865
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1866 if (! props.linestyle_is ("none"))
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1867 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1868 set_color (props.get_color_rgb ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1869 set_linestyle (props.get_linestyle (), false);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1870 set_linewidth (props.get_linewidth ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1871
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1872 if (has_z)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1873 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1874 bool flag = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1875
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1876 for (int i = 1; i < n; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1877 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1878 if ((clip[i-1] & clip[i]) == clip_ok)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1879 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1880 if (! flag)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1881 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1882 flag = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1883 glBegin (GL_LINE_STRIP);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1884 glVertex3d (x(i-1), y(i-1), z(i-1));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1885 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1886 glVertex3d (x(i), y(i), z(i));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1887 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1888 else if (flag)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1889 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1890 flag = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1891 glEnd ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1892 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1893 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1894
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1895 if (flag)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1896 glEnd ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1897 }
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1898 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1899 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1900 bool flag = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1901
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1902 for (int i = 1; i < n; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1903 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1904 if ((clip[i-1] & clip[i]) == clip_ok)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1905 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1906 if (! flag)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1907 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1908 flag = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1909 glBegin (GL_LINE_STRIP);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1910 glVertex2d (x(i-1), y(i-1));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1911 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1912 glVertex2d (x(i), y(i));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1913 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1914 else if (flag)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1915 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1916 flag = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1917 glEnd ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1918 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1919 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1920
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1921 if (flag)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1922 glEnd ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1923 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1924
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1925 set_linewidth (0.5);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1926 set_linestyle ("-");
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1927 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1928
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1929 set_clipping (false);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1930
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1931 if (! props.marker_is ("none") &&
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1932 ! (props.markeredgecolor_is ("none")
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1933 && props.markerfacecolor_is ("none")))
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1934 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1935 Matrix lc, fc;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1936
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1937 if (props.markeredgecolor_is ("auto"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1938 lc = props.get_color_rgb ();
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1939 else if (! props.markeredgecolor_is ("none"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1940 lc = props.get_markeredgecolor_rgb ();
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1941
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1942 if (props.markerfacecolor_is ("auto"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1943 fc = props.get_color_rgb ();
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1944 else if (! props.markerfacecolor_is ("none"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1945 fc = props.get_markerfacecolor_rgb ();
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1946
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1947 init_marker (props.get_marker (), props.get_markersize (),
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1948 props.get_linewidth ());
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1949
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1950 for (int i = 0; i < n; i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1951 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1952 if (clip[i] == clip_ok)
11266
be710ed252ff gl-render.cc (opengl_renderer::draw_line): layer markers in 2D plots
Daisuke TAKAGO <takago@neptune.kanazawa-it.ac.jp>
parents: 11209
diff changeset
1953 draw_marker (x(i), y(i),
be710ed252ff gl-render.cc (opengl_renderer::draw_line): layer markers in 2D plots
Daisuke TAKAGO <takago@neptune.kanazawa-it.ac.jp>
parents: 11209
diff changeset
1954 has_z ? z(i) : static_cast<double> (i) / n,
be710ed252ff gl-render.cc (opengl_renderer::draw_line): layer markers in 2D plots
Daisuke TAKAGO <takago@neptune.kanazawa-it.ac.jp>
parents: 11209
diff changeset
1955 lc, fc);
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1956 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1957
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1958 end_marker ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1959 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1960
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1961 set_clipping (props.is_clipping ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1962 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1963
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1964 void
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9687
diff changeset
1965 opengl_renderer::draw_surface (const surface::properties& props)
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1966 {
9681
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
1967 const Matrix x = xform.xscale (props.get_xdata ().matrix_value ());
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
1968 const Matrix y = xform.yscale (props.get_ydata ().matrix_value ());
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
1969 const Matrix z = xform.zscale (props.get_zdata ().matrix_value ());
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1970
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1971 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
1972
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1973 NDArray c;
9681
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
1974 const NDArray n = props.get_vertexnormals ().array_value ();
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1975
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1976 // FIXME: handle transparency
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1977 Matrix a;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1978
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1979 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
1980 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
1981
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1982 int fc_mode = (props.facecolor_is_rgb () ? 0 :
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1983 (props.facecolor_is ("flat") ? 1 :
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1984 (props.facecolor_is ("interp") ? 2 :
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1985 (props.facecolor_is ("texturemap") ? 3 : -1))));
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1986 int fl_mode = (props.facelighting_is ("none") ? 0 :
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1987 (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
1988 int fa_mode = (props.facealpha_is_double () ? 0 :
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1989 (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
1990 int ec_mode = (props.edgecolor_is_rgb () ? 0 :
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1991 (props.edgecolor_is ("flat") ? 1 :
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1992 (props.edgecolor_is ("interp") ? 2 : -1)));
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1993 int el_mode = (props.edgelighting_is ("none") ? 0 :
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1994 (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
1995 int ea_mode = (props.edgealpha_is_double () ? 0 :
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1996 (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
1997
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1998 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
1999 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
2000
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2001 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
2002 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
2003 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
2004 float se = props.get_specularexponent ();
8674
0d263850d582 Fix calculation of diffuse reflectance. Calculate surface normals here now.
Kai Habel
parents: 8377
diff changeset
2005 float cb[4] = { 0.0, 0.0, 0.0, 1.0 };
0d263850d582 Fix calculation of diffuse reflectance. Calculate surface normals here now.
Kai Habel
parents: 8377
diff changeset
2006 double d = 1.0;
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2007
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
2008 opengl_texture tex;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
2009
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2010 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
2011 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
2012 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
2013
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2014 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
2015
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
2016 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
2017
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2018 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
2019 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2020 if (x_mat)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2021 i1 = i;
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2022
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
2023 for (int j = 0; j < zc; j++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2024 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2025 if (y_mat)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2026 j1 = j;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2027
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2028 clip(i,j) = is_nan_or_inf (x(i1,j), y(i,j1), z(i,j));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2029 }
7829
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
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2032 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
2033 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
2034
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2035 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
2036 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2037 // FIXME: implement alphadata conversion
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2038 //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
2039 }
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 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
2042 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2043 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
2044
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2045 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
2046 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
2047 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2048
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
2049 // 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
2050 // 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
2051 if (fc_mode == 3)
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
2052 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
2053
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2054 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
2055 {
7846
d7737a4268b7 Fix typos in property names (edgealpha/facealpha).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7838
diff changeset
2056 if (props.get_facealpha_double () == 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2057 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2058 if (fc_mode == 0 || fc_mode == 3)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2059 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2060 glColor3dv (fcolor.data ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2061 if (fl_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2062 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2063 for (int i = 0; i < 3; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2064 cb[i] = as * fcolor(i);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2065 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2066
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2067 for (int i = 0; i < 3; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2068 cb[i] = ds * fcolor(i);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2069 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2070 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2071 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2072
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2073 if (fl_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2074 glEnable (GL_LIGHTING);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2075 glShadeModel ((fc_mode == 2 || fl_mode == 2) ? GL_SMOOTH : GL_FLAT);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2076 set_polygon_offset (true, 1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2077 if (fc_mode == 3)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2078 glEnable (GL_TEXTURE_2D);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2079
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2080 for (int i = 1; i < zc; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2081 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2082 if (y_mat)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2083 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2084 i1 = i-1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2085 i2 = i;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2086 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2087
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2088 for (int j = 1; j < zr; j++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2089 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2090 if (clip(j-1, i-1) || clip (j, i-1)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2091 || clip (j-1, i) || clip (j, i))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2092 continue;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2093
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2094 if (x_mat)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2095 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2096 j1 = j-1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2097 j2 = j;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2098 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2099
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2100 glBegin (GL_QUADS);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2101
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2102 // Vertex 1
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2103 if (fc_mode == 3)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2104 tex.tex_coord (double (i-1) / (zc-1), double (j-1) / (zr-1));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2105 else if (fc_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2106 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2107 // FIXME: is there a smarter way to do this?
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2108 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2109 cb[k] = c(j-1, i-1, k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2110 glColor3fv (cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2111
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2112 if (fl_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2113 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2114 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2115 cb[k] *= as;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2116 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2117
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2118 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2119 cb[k] = ds * c(j-1, i-1, k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2120 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2121 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2122 }
8674
0d263850d582 Fix calculation of diffuse reflectance. Calculate surface normals here now.
Kai Habel
parents: 8377
diff changeset
2123 if (fl_mode > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2124 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2125 d = sqrt (n(j-1,i-1,0) * n(j-1,i-1,0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2126 + n(j-1,i-1,1) * n(j-1,i-1,1)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2127 + n(j-1,i-1,2) * n(j-1,i-1,2));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2128 glNormal3d (n(j-1,i-1,0)/d, n(j-1,i-1,1)/d, n(j-1,i-1,2)/d);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2129 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2130 glVertex3d (x(j1,i-1), y(j-1,i1), z(j-1,i-1));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2131
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2132 // Vertex 2
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2133 if (fc_mode == 3)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2134 tex.tex_coord (double (i) / (zc-1), double (j-1) / (zr-1));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2135 else if (fc_mode == 2)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2136 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2137 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2138 cb[k] = c(j-1, i, k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2139 glColor3fv (cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2140
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2141 if (fl_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2142 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2143 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2144 cb[k] *= as;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2145 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2146
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2147 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2148 cb[k] = ds * c(j-1, i, k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2149 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2150 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2151 }
8674
0d263850d582 Fix calculation of diffuse reflectance. Calculate surface normals here now.
Kai Habel
parents: 8377
diff changeset
2152
0d263850d582 Fix calculation of diffuse reflectance. Calculate surface normals here now.
Kai Habel
parents: 8377
diff changeset
2153 if (fl_mode == 2)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2154 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2155 d = sqrt (n(j-1,i,0) * n(j-1,i,0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2156 + n(j-1,i,1) * n(j-1,i,1)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2157 + n(j-1,i,2) * n(j-1,i,2));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2158 glNormal3d (n(j-1,i,0)/d, n(j-1,i,1)/d, n(j-1,i,2)/d);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2159 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2160
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2161 glVertex3d (x(j1,i), y(j-1,i2), z(j-1,i));
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2162
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2163 // Vertex 3
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2164 if (fc_mode == 3)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2165 tex.tex_coord (double (i) / (zc-1), double (j) / (zr-1));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2166 else if (fc_mode == 2)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2167 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2168 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2169 cb[k] = c(j, i, k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2170 glColor3fv (cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2171
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2172 if (fl_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2173 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2174 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2175 cb[k] *= as;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2176 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2177
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2178 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2179 cb[k] = ds * c(j, i, k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2180 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2181 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2182 }
8674
0d263850d582 Fix calculation of diffuse reflectance. Calculate surface normals here now.
Kai Habel
parents: 8377
diff changeset
2183 if (fl_mode == 2)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2184 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2185 d = sqrt (n(j,i,0) * n(j,i,0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2186 + n(j,i,1) * n(j,i,1)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2187 + n(j,i,2) * n(j,i,2));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2188 glNormal3d (n(j,i,0)/d, n(j,i,1)/d, n(j,i,2)/d);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2189 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2190 glVertex3d (x(j2,i), y(j,i2), z(j,i));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2191
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2192 // Vertex 4
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2193 if (fc_mode == 3)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2194 tex.tex_coord (double (i-1) / (zc-1), double (j) / (zr-1));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2195 else if (fc_mode == 2)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2196 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2197 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2198 cb[k] = c(j, i-1, k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2199 glColor3fv (cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2200
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2201 if (fl_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2202 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2203 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2204 cb[k] *= as;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2205 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2206
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2207 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2208 cb[k] = ds * c(j, i-1, k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2209 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2210 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2211 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2212 if (fl_mode == 2)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2213 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2214 d = sqrt (n(j,i-1,0) * n(j,i-1,0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2215 + n(j,i-1,1) * n(j,i-1,1)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2216 + n(j,i-1,2) * n(j,i-1,2));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2217 glNormal3d (n(j,i-1,0)/d, n(j,i-1,1)/d, n(j,i-1,2)/d);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2218 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2219 glVertex3d (x(j2,i-1), y(j,i1), z(j,i-1));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2220
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2221 glEnd ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2222 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2223 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2224
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2225 set_polygon_offset (false);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2226 if (fc_mode == 3)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2227 glDisable (GL_TEXTURE_2D);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2228
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2229 if (fl_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2230 glDisable (GL_LIGHTING);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2231 }
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2232 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2233 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2234 // FIXME: implement transparency
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2235 }
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2236 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2237
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2238 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
2239 {
7846
d7737a4268b7 Fix typos in property names (edgealpha/facealpha).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7838
diff changeset
2240 if (props.get_edgealpha_double () == 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2241 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2242 if (ec_mode == 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2243 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2244 glColor3dv (ecolor.data ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2245 if (fl_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2246 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2247 for (int i = 0; i < 3; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2248 cb[i] = as * ecolor(i);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2249 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2250
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2251 for (int i = 0; i < 3; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2252 cb[i] = ds * ecolor(i);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2253 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2254 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2255 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2256
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2257 if (el_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2258 glEnable (GL_LIGHTING);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2259 glShadeModel ((ec_mode == 2 || el_mode == 2) ? GL_SMOOTH : GL_FLAT);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2260
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2261 set_linestyle (props.get_linestyle (), false);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2262 set_linewidth (props.get_linewidth ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2263
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2264 // Mesh along Y-axis
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2265
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2266 if (props.meshstyle_is ("both") || props.meshstyle_is ("column"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2267 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2268 for (int i = 0; i < zc; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2269 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2270 if (y_mat)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2271 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2272 i1 = i-1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2273 i2 = i;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2274 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2275
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2276 for (int j = 1; j < zr; j++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2277 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2278 if (clip(j-1,i) || clip(j,i))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2279 continue;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2280
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2281 if (x_mat)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2282 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2283 j1 = j-1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2284 j2 = j;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2285 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2286
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2287 glBegin (GL_LINES);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2288
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2289 // Vertex 1
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2290 if (ec_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2291 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2292 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2293 cb[k] = c(j-1, i, k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2294 glColor3fv (cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2295
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2296 if (fl_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2297 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2298 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2299 cb[k] *= as;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2300 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2301
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2302 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2303 cb[k] = ds * c(j-1, i, k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2304 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2305 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2306 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2307 if (el_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2308 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2309 d = sqrt (n(j-1,i,0) * n(j-1,i,0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2310 + n(j-1,i,1) * n(j-1,i,1)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2311 + n(j-1,i,2) * n(j-1,i,2));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2312 glNormal3d (n(j-1,i,0)/d, n(j-1,i,1)/d, n(j-1,i,2)/d);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2313 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2314 glVertex3d (x(j1,i), y(j-1,i2), z(j-1,i));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2316 // Vertex 2
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2317 if (ec_mode == 2)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2318 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2319 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2320 cb[k] = c(j, i, k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2321 glColor3fv (cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2322
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2323 if (fl_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2324 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2325 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2326 cb[k] *= as;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2327 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2328
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2329 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2330 cb[k] = ds * c(j, i, k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2331 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2332 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2333 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2334 if (el_mode == 2)
8674
0d263850d582 Fix calculation of diffuse reflectance. Calculate surface normals here now.
Kai Habel
parents: 8377
diff changeset
2335 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2336 d = sqrt (n(j,i,0) * n(j,i,0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2337 + n(j,i,1) * n(j,i,1)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2338 + n(j,i,2) * n(j,i,2));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2339 glNormal3d (n(j,i,0)/d, n(j,i,1)/d, n(j,i,2)/d);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2340 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2341 glVertex3d (x(j2,i), y(j,i2), z(j,i));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2342
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2343 glEnd ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2344 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2345 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2346 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2347
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2348 // Mesh along X-axis
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2349
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2350 if (props.meshstyle_is ("both") || props.meshstyle_is ("row"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2351 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2352 for (int j = 0; j < zr; j++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2353 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2354 if (x_mat)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2355 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2356 j1 = j-1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2357 j2 = j;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2358 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2359
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2360 for (int i = 1; i < zc; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2361 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2362 if (clip(j,i-1) || clip(j,i))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2363 continue;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2364
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2365 if (y_mat)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2366 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2367 i1 = i-1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2368 i2 = i;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2369 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2370
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2371 glBegin (GL_LINES);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2372
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2373 // Vertex 1
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2374 if (ec_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2375 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2376 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2377 cb[k] = c(j, i-1, k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2378 glColor3fv (cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2379
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2380 if (fl_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2381 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2382 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2383 cb[k] *= as;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2384 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2385
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2386 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2387 cb[k] = ds * c(j, i-1, k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2388 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2389 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2390 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2391 if (el_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2392 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2393 d = sqrt (n(j,i-1,0) * n(j,i-1,0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2394 + n(j,i-1,1) * n(j,i-1,1)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2395 + n(j,i-1,2) * n(j,i-1,2));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2396 glNormal3d (n(j,i-1,0)/d, n(j,i-1,1)/d, n(j,i-1,2)/d);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2397 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2398 glVertex3d (x(j2,i-1), y(j,i1), z(j,i-1));
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2399
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2400 // Vertex 2
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2401 if (ec_mode == 2)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2402 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2403 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2404 cb[k] = c(j, i, k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2405 glColor3fv (cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2406
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2407 if (fl_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2408 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2409 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2410 cb[k] *= as;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2411 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2412
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2413 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2414 cb[k] = ds * c(j, i, k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2415 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2416 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2417 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2418 if (el_mode == 2)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2419 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2420 d = sqrt (n(j,i,0) * n(j,i,0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2421 + n(j,i,1) * n(j,i,1)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2422 + n(j,i,2) * n(j,i,2));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2423 glNormal3d (n(j,i,0)/d, n(j,i,1)/d, n(j,i,2)/d);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2424 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2425 glVertex3d (x(j2,i), y(j,i2), z(j,i));
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2426
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2427 glEnd ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2428 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2429 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2430 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2431
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2432 set_linestyle ("-");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2433 set_linewidth (0.5);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2434
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2435 if (el_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2436 glDisable (GL_LIGHTING);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2437 }
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2438 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2439 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2440 // FIXME: implement transparency
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2441 }
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2442 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2443
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2444 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
2445 ! (props.markeredgecolor_is ("none")
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2446 && props.markerfacecolor_is ("none")))
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2447 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2448 // 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
2449 // 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
2450 // 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
2451
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2452 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
2453 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
2454
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2455 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
2456 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
2457 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
2458
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2459 if (mecolor.numel () == 0 && props.markeredgecolor_is ("auto"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2460 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2461 mecolor = props.get_edgecolor_rgb ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2462 do_edge = ! props.edgecolor_is ("none");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2463 }
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2464
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2465 if (mfcolor.numel () == 0 && props.markerfacecolor_is ("auto"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2466 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2467 mfcolor = props.get_facecolor_rgb ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2468 do_face = ! props.facecolor_is ("none");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2469 }
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2470
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2471 if ((mecolor.numel () == 0 || mfcolor.numel () == 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2472 && c.numel () == 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2473 c = props.get_color_data ().array_value ();
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2474
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2475 init_marker (props.get_marker (), props.get_markersize (),
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2476 props.get_linewidth ());
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2477
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2478 for (int i = 0; i < zc; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2479 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2480 if (y_mat)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2481 i1 = i;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2482
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2483 for (int j = 0; j < zr; j++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2484 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2485 if (clip(j,i))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2486 continue;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2487
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2488 if (x_mat)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2489 j1 = j;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2490
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2491 if ((do_edge && mecolor.numel () == 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2492 || (do_face && mfcolor.numel () == 0))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2493 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2494 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2495 cc(k) = c(j,i,k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2496 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2497
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2498 Matrix lc = (do_edge ? (mecolor.numel () == 0 ? cc : mecolor) : Matrix ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2499 Matrix fc = (do_face ? (mfcolor.numel () == 0 ? cc : mfcolor) : Matrix ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2500
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2501 draw_marker (x(j1,i), y(j,i1), z(j,i), lc, fc);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2502 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2503 }
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2504
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2505 end_marker ();
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2506 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2507 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2508
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
2509 // 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
2510 // 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
2511 void
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9687
diff changeset
2512 opengl_renderer::draw_patch (const patch::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
2513 {
9681
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
2514 const Matrix f = props.get_faces ().matrix_value ();
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
2515 const Matrix v = xform.scale (props.get_vertices ().matrix_value ());
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
2516 Matrix c;
9681
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
2517 const Matrix n = props.get_vertexnormals ().matrix_value ();
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
2518 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
2519
7870
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
2520 int nv = v.rows ();
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
2521 // int vmax = v.columns ();
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
2522 int nf = f.rows ();
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
2523 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
2524
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2525 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
2526 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
2527 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
2528
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2529 int fc_mode = ((props.facecolor_is("none")
11168
36442102c340 Fix treatment of facevertexcdata if facecolor is 'none' with the fltk backend
David Bateman <dbateman@free.fr>
parents: 11166
diff changeset
2530 || props.facecolor_is_rgb ()) ? 0 :
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2531 (props.facecolor_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
2532 int fl_mode = (props.facelighting_is ("none") ? 0 :
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2533 (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
2534 int fa_mode = (props.facealpha_is_double () ? 0 :
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2535 (props.facealpha_is ("flat") ? 1 : 2));
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2536 int ec_mode = ((props.edgecolor_is("none")
11168
36442102c340 Fix treatment of facevertexcdata if facecolor is 'none' with the fltk backend
David Bateman <dbateman@free.fr>
parents: 11166
diff changeset
2537 || props.edgecolor_is_rgb ()) ? 0 :
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2538 (props.edgecolor_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
2539 int el_mode = (props.edgelighting_is ("none") ? 0 :
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2540 (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
2541 int ea_mode = (props.edgealpha_is_double () ? 0 :
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2542 (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
2543
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2544 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
2545 Matrix ecolor = props.get_edgecolor_rgb ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2546
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
2547 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
2548 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
2549 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
2550 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
2551
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2552 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
2553
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2554 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
2555 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
2556 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
2557 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
2558 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
2559 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
2560
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2561 boolMatrix clip_f (1, nf, false);
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
2562 Array<int> count_f (dim_vector (nf, 1), 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
2563
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2564 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
2565 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2566 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
2567 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
2568
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2569 for (int j = 0; j < fcmax && ! xisnan (f(i,j)); j++, count++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2570 fclip = (fclip || clip(int (f(i,j) - 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
2571
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2572 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
2573 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
2574 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2575
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2576 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
2577 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2578 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
2579
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2580 if (c.rows () == 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2581 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2582 // Single color specifications, we can simplify a little bit
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2583
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2584 if (fc_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2585 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2586 fcolor = c;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2587 fc_mode = 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2588 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2589
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2590 if (ec_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2591 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2592 ecolor = c;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2593 ec_mode = 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2594 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2595
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2596 c = Matrix ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2597 }
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
2598 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2599 has_facecolor = ((c.numel () > 0) && (c.rows () == f.rows ()));
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
2600 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2601
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2602 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
2603 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2604 // 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
2605 //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
2606 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
2607 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2608
7924
4976f66d469b miscellaneous cleanup
John W. Eaton <jwe@octave.org>
parents: 7914
diff changeset
2609 octave_idx_type fr = f.rows ();
7914
e998e81224b5 Various compilation fixes for MSVC.
John W. Eaton <jwe@octave.org>
parents: 7907
diff changeset
2610 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
2611
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2612 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
2613 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
2614 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2615 int idx = int (f(i,j) - 1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2616
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2617 Matrix vv (1, 3, 0.0);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2618 Matrix cc;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2619 Matrix nn(1, 3, 0.0);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2620 double aa = 1.0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2621
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2622 vv(0) = v(idx,0); vv(1) = v(idx,1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2623 if (has_z)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2624 vv(2) = v(idx,2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2625 // FIXME: uncomment when patch object has normal computation
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2626 //nn(0) = n(idx,0); nn(1) = n(idx,1); nn(2) = n(idx,2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2627 if (c.numel () > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2628 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2629 cc.resize (1, 3);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2630 if (has_facecolor)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2631 cc(0) = c(i,0), cc(1) = c(i,1), cc(2) = c(i,2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2632 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2633 cc(0) = c(idx,0), cc(1) = c(idx,1), cc(2) = c(idx,2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2634 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2635 if (a.numel () > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2636 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2637 if (has_facealpha)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2638 aa = a(i);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2639 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2640 aa = a(idx);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2641 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2642
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2643 vdata[i+j*fr] =
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2644 vertex_data (vv, cc, nn, aa, as, ds, ss, se);
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
2645 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2646
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2647 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
2648 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2649 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
2650
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2651 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
2652 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
2653 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2654
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2655 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
2656 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2657 // 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
2658 if (props.get_facealpha_double () == 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2659 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2660 if (fc_mode == 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2661 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2662 glColor3dv (fcolor.data ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2663 if (fl_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2664 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2665 float cb[4] = { 0, 0, 0, 1 };
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2666
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2667 for (int i = 0; i < 3; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2668 cb[i] = (as * fcolor(i));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2669 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2670
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2671 for (int i = 0; i < 3; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2672 cb[i] = ds * fcolor(i);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2673 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2674 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2675 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2676
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2677 if (fl_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2678 glEnable (GL_LIGHTING);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2679
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2680 // FIXME: use __index__ property from patch object
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2681 patch_tesselator tess (this, fc_mode, fl_mode, 0);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2682
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2683 for (int i = 0; i < nf; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2684 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2685 if (clip_f(i))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2686 continue;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2687
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2688 tess.begin_polygon (true);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2689 tess.begin_contour ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2690
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2691 for (int j = 0; j < count_f(i); j++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2692 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2693 vertex_data::vertex_data_rep *vv = vdata[i+j*fr].get_rep ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2694
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2695 tess.add_vertex (vv->coords.fortran_vec (), vv);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2696 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2697
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2698 tess.end_contour ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2699 tess.end_polygon ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2700 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2701
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2702 if (fl_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2703 glDisable (GL_LIGHTING);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2704 }
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
2705 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2706 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2707 // FIXME: implement transparency
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2708 }
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
2709 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2710
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2711 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
2712 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2713 // 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
2714 if (props.get_edgealpha_double () == 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2715 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2716 if (ec_mode == 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2717 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2718 glColor3dv (ecolor.data ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2719 if (el_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2720 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2721 float cb[4] = { 0, 0, 0, 1 };
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2722
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2723 for (int i = 0; i < 3; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2724 cb[i] = (as * ecolor(i));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2725 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2726
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2727 for (int i = 0; i < 3; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2728 cb[i] = ds * ecolor(i);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2729 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2730 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2731 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2732
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2733 if (el_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2734 glEnable (GL_LIGHTING);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2735
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2736 set_linestyle (props.get_linestyle (), false);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2737 set_linewidth (props.get_linewidth ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2738
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2739
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2740 // FIXME: use __index__ property from patch object; should we
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2741 // offset patch contour as well?
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2742 patch_tesselator tess (this, ec_mode, el_mode);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2743
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2744 for (int i = 0; i < nf; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2745 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2746 if (clip_f(i))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2747 {
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2748 // This is an unclosed contour. Draw it as a line
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2749 bool flag = false;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2750
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2751 for (int j = 0; j < count_f(i); j++)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2752 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2753 if (! clip(int (f(i,j) - 1)))
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2754 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2755 vertex_data::vertex_data_rep *vv = vdata[i+j*fr].get_rep ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2756 const Matrix m = vv->coords;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2757 if (! flag)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2758 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2759 flag = true;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2760 glBegin (GL_LINE_STRIP);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2761 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2762 glVertex3d (m(0), m(1), m(2));
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2763 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2764 else if (flag)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2765 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2766 flag = false;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2767 glEnd ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2768 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2769 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2770
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2771 if (flag)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2772 glEnd ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2773 }
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2774 else
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2775 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2776 tess.begin_polygon (false);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2777 tess.begin_contour ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2778
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2779 for (int j = 0; j < count_f(i); j++)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2780 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2781 vertex_data::vertex_data_rep *vv = vdata[i+j*fr].get_rep ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2782 tess.add_vertex (vv->coords.fortran_vec (), vv);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2783 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2784
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2785 tess.end_contour ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2786 tess.end_polygon ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2787 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2788 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2789
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2790 set_linestyle ("-");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2791 set_linewidth (0.5);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2792
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2793 if (el_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2794 glDisable (GL_LIGHTING);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2795 }
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
2796 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2797 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2798 // FIXME: implement transparency
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2799 }
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
2800 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2801
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2802 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
2803 ! (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
2804 {
7838
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2805 bool do_edge = ! props.markeredgecolor_is ("none");
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2806 bool do_face = ! props.markerfacecolor_is ("none");
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2807
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2808 Matrix mecolor = props.get_markeredgecolor_rgb ();
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2809 Matrix mfcolor = props.get_markerfacecolor_rgb ();
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2810 Matrix cc (1, 3, 0.0);
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2811
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2812 if (mecolor.numel () == 0 && props.markeredgecolor_is ("auto"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2813 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2814 mecolor = props.get_edgecolor_rgb ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2815 do_edge = ! props.edgecolor_is ("none");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2816 }
7838
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2817
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2818 if (mfcolor.numel () == 0 && props.markerfacecolor_is ("auto"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2819 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2820 mfcolor = props.get_facecolor_rgb ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2821 do_face = ! props.facecolor_is ("none");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2822 }
7838
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2823
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2824 init_marker (props.get_marker (), props.get_markersize (),
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2825 props.get_linewidth ());
7838
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2826
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2827 for (int i = 0; i < nf; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2828 for (int j = 0; j < count_f(i); j++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2829 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2830 int idx = int (f(i,j) - 1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2831
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2832 if (clip(idx))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2833 continue;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2834
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2835 Matrix lc = (do_edge ? (mecolor.numel () == 0 ?
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2836 vdata[i+j*fr].get_rep ()->color : mecolor)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2837 : Matrix ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2838 Matrix fc = (do_face ? (mfcolor.numel () == 0 ?
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2839 vdata[i+j*fr].get_rep ()->color : mfcolor)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2840 : Matrix ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2841
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2842 draw_marker (v(idx,0), v(idx,1), (has_z ? v(idx,2) : 0), lc, fc);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2843 }
7838
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2844
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2845 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
2846 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2847 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2848
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2849 void
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9687
diff changeset
2850 opengl_renderer::draw_hggroup (const hggroup::properties &props)
7866
35e8d6199455 Add hggroup support in OpenGL renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7851
diff changeset
2851 {
35e8d6199455 Add hggroup support in OpenGL renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7851
diff changeset
2852 draw (props.get_children ());
35e8d6199455 Add hggroup support in OpenGL renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7851
diff changeset
2853 }
35e8d6199455 Add hggroup support in OpenGL renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7851
diff changeset
2854
35e8d6199455 Add hggroup support in OpenGL renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7851
diff changeset
2855 void
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9687
diff changeset
2856 opengl_renderer::draw_text (const text::properties& props)
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
2857 {
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
2858 if (props.get_string ().empty ())
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
2859 return;
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
2860
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
2861 set_font (props);
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
2862 set_color (props.get_color_rgb ());
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
2863
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10350
diff changeset
2864 const Matrix pos = xform.scale (props.get_data_position ());
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
2865 const Matrix bbox = props.get_extent_matrix ();
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
2866
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
2867 // FIXME: handle margin and surrounding box
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
2868 bool blend = glIsEnabled (GL_BLEND);
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
2869
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
2870 glEnable (GL_BLEND);
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
2871 glEnable (GL_ALPHA_TEST);
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
2872 glRasterPos3d (pos(0), pos(1), pos(2));
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
2873 glBitmap(0, 0, 0, 0, bbox(0), bbox(1), 0);
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
2874 glDrawPixels (bbox(2), bbox(3),
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
2875 GL_RGBA, GL_UNSIGNED_BYTE, props.get_pixels ().data ());
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
2876 glDisable (GL_ALPHA_TEST);
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
2877 if (! blend)
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
2878 glDisable (GL_BLEND);
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
2879
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
2880 }
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
2881
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
2882 void
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9687
diff changeset
2883 opengl_renderer::draw_image (const image::properties& props)
9680
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9616
diff changeset
2884 {
9884
fed4aad2cdca handle indexed images in opengl renderer
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
2885 octave_value cdata = props.get_color_data ();
9680
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9616
diff changeset
2886 dim_vector dv (cdata.dims ());
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9616
diff changeset
2887 int h = dv(0), w = dv(1);
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9616
diff changeset
2888 bool ok = true;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2889
11093
d748acc75658 gl-render.cc: Treat images with scalar unique(x/ydata) like Matlab.
Ben Abbott <bpabbott@mac.com>
parents: 11026
diff changeset
2890 Matrix x = props.get_xdata ().matrix_value ();
d748acc75658 gl-render.cc: Treat images with scalar unique(x/ydata) like Matlab.
Ben Abbott <bpabbott@mac.com>
parents: 11026
diff changeset
2891 Matrix y = props.get_ydata ().matrix_value ();
d748acc75658 gl-render.cc: Treat images with scalar unique(x/ydata) like Matlab.
Ben Abbott <bpabbott@mac.com>
parents: 11026
diff changeset
2892
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2893 if (w > 1 && x(1) == x(0))
11093
d748acc75658 gl-render.cc: Treat images with scalar unique(x/ydata) like Matlab.
Ben Abbott <bpabbott@mac.com>
parents: 11026
diff changeset
2894 x(1) = x(1) + (w-1);
d748acc75658 gl-render.cc: Treat images with scalar unique(x/ydata) like Matlab.
Ben Abbott <bpabbott@mac.com>
parents: 11026
diff changeset
2895
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2896 if (h > 1 && y(1) == y(0))
11093
d748acc75658 gl-render.cc: Treat images with scalar unique(x/ydata) like Matlab.
Ben Abbott <bpabbott@mac.com>
parents: 11026
diff changeset
2897 y(1) = y(1) + (h-1);
d748acc75658 gl-render.cc: Treat images with scalar unique(x/ydata) like Matlab.
Ben Abbott <bpabbott@mac.com>
parents: 11026
diff changeset
2898
9681
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
2899 const ColumnVector p0 = xform.transform (x(0), y(0), 0);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
2900 const ColumnVector p1 = xform.transform (x(1), y(1), 0);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
2901
9687
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2902 // image pixel size in screen pixel units
9950
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
2903 float pix_dx, pix_dy;
9687
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2904 // image pixel size in normalized units
9950
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
2905 float nor_dx, nor_dy;
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
2906
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2907 if (w > 1)
9950
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
2908 {
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
2909 pix_dx = (p1(0) - p0(0))/(w-1);
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
2910 nor_dx = (x(1) - x(0))/(w-1);
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
2911 }
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
2912 else
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
2913 {
10076
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9950
diff changeset
2914 const ColumnVector p1w = xform.transform (x(1) + 1, y(1), 0);
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9950
diff changeset
2915 pix_dx = p1w(0) - p0(0);
9950
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
2916 nor_dx = 1;
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
2917 }
10076
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9950
diff changeset
2918
9950
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
2919 if (h > 1)
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
2920 {
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
2921 pix_dy = (p1(1) - p0(1))/(h-1);
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
2922 nor_dy = (y(1) - y(0))/(h-1);
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
2923 }
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
2924 else
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
2925 {
10076
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9950
diff changeset
2926 const ColumnVector p1h = xform.transform (x(1), y(1) + 1, 0);
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9950
diff changeset
2927 pix_dy = p1h(1) - p0(1);
9950
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
2928 nor_dy = 1;
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
2929 }
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
2930
9687
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2931
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2932 // OpenGL won't draw the image if it's origin is outside the
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2933 // viewport/clipping plane so we must do the clipping
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2934 // ourselfes - only draw part of the image
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2935
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2936 int j0 = 0, j1 = w;
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2937 int i0 = 0, i1 = h;
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2938
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2939 float im_xmin = x(0) - nor_dx/2;
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2940 float im_xmax = x(1) + nor_dx/2;
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2941 float im_ymin = y(0) - nor_dy/2;
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2942 float im_ymax = y(1) + nor_dy/2;
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2943 if (props.is_clipping ()) // clip to axes
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2944 {
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2945 if (im_xmin < xmin)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2946 j0 += (xmin - im_xmin)/nor_dx + 1;
9687
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2947 if (im_xmax > xmax)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2948 j1 -= (im_xmax - xmax)/nor_dx ;
9687
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2949
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2950 if (im_ymin < ymin)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2951 i0 += (ymin - im_ymin)/nor_dy + 1;
9687
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2952 if (im_ymax > ymax)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2953 i1 -= (im_ymax - ymax)/nor_dy;
9687
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2954 }
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2955 else // clip to viewport
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2956 {
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2957 GLfloat vp[4];
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2958 glGetFloatv(GL_VIEWPORT, vp);
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2959 // FIXME -- actually add the code to do it!
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2960
9687
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2961 }
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2962
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2963 if (i0 >= i1 || j0 >= j1)
9687
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2964 return;
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2965
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2966 glPixelZoom (pix_dx, -pix_dy);
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2967 glRasterPos3d (im_xmin + nor_dx*j0, im_ymin + nor_dy*i0, 0);
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2968
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2969 // by default this is 4
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2970 glPixelStorei (GL_UNPACK_ALIGNMENT,1);
9680
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9616
diff changeset
2971
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9616
diff changeset
2972 // Expect RGB data
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9616
diff changeset
2973 if (dv.length () == 3 && dv(2) == 3)
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9616
diff changeset
2974 {
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9616
diff changeset
2975 if (cdata.is_double_type ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2976 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2977 const NDArray xcdata = cdata.array_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2978
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2979 OCTAVE_LOCAL_BUFFER (GLfloat, a, 3*(j1-j0)*(i1-i0));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2980
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2981 for (int i = i0; i < i1; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2982 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2983 for (int j = j0, idx = (i-i0)*(j1-j0)*3; j < j1; j++, idx += 3)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2984 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2985 a[idx] = xcdata(i,j,0);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2986 a[idx+1] = xcdata(i,j,1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2987 a[idx+2] = xcdata(i,j,2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2988 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2989 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2990
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2991 draw_pixels (j1-j0, i1-i0, GL_RGB, GL_FLOAT, a);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2992
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2993 }
9680
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9616
diff changeset
2994 else if (cdata.is_uint16_type ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2995 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2996 const uint16NDArray xcdata = cdata.uint16_array_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2997
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2998 OCTAVE_LOCAL_BUFFER (GLushort, a, 3*(j1-j0)*(i1-i0));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2999
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3000 for (int i = i0; i < i1; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3001 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3002 for (int j = j0, idx = (i-i0)*(j1-j0)*3; j < j1; j++, idx += 3)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3003 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3004 a[idx] = xcdata(i,j,0);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3005 a[idx+1] = xcdata(i,j,1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3006 a[idx+2] = xcdata(i,j,2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3007 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3008 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3009
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3010 draw_pixels (j1-j0, i1-i0, GL_RGB, GL_UNSIGNED_SHORT, a);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3011
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3012 }
9680
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9616
diff changeset
3013 else if (cdata.is_uint8_type ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3014 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3015 const uint8NDArray xcdata = cdata.uint8_array_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3016
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3017 OCTAVE_LOCAL_BUFFER (GLubyte, a, 3*(j1-j0)*(i1-i0));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3018
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3019 for (int i = i0; i < i1; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3020 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3021 for (int j = j0, idx = (i-i0)*(j1-j0)*3; j < j1; j++, idx += 3)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3022 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3023 a[idx] = xcdata(i,j,0);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3024 a[idx+1] = xcdata(i,j,1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3025 a[idx+2] = xcdata(i,j,2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3026 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3027 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3028
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3029 draw_pixels (j1-j0, i1-i0, GL_RGB, GL_UNSIGNED_BYTE, a);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3030 }
9680
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9616
diff changeset
3031 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3032 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3033 ok = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3034 warning ("opengl_texture::draw: invalid image data type (expected double, uint16, or uint8)");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3035 }
9680
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9616
diff changeset
3036 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
3037 else
9680
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9616
diff changeset
3038 {
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9616
diff changeset
3039 ok = false;
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9616
diff changeset
3040 warning ("opengl_texture::draw: invalid image size (expected n*m*3 or n*m)");
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9616
diff changeset
3041 }
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9616
diff changeset
3042 glPixelZoom (1, 1);
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9616
diff changeset
3043 }
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9616
diff changeset
3044
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9616
diff changeset
3045 void
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3046 opengl_renderer::set_viewport (int w, int h)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3047 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3048 glViewport (0, 0, w, h);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3049 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3050
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3051 void
9950
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
3052 opengl_renderer::draw_pixels (GLsizei width, GLsizei height, GLenum format,
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
3053 GLenum type, const GLvoid *data)
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
3054 {
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
3055 glDrawPixels (width, height, format, type, data);
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
3056 }
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
3057
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
3058 void
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3059 opengl_renderer::set_color (const Matrix& c)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3060 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3061 glColor3dv (c.data ());
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3062 #if HAVE_FREETYPE
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3063 text_renderer.set_color (c);
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3064 #endif
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3065 }
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3066
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3067 void
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3068 opengl_renderer::set_font (const base_properties& props)
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3069 {
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3070 #if HAVE_FREETYPE
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
3071 text_renderer.set_font (props.get ("fontname").string_value (),
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
3072 props.get ("fontweight").string_value (),
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
3073 props.get ("fontangle").string_value (),
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
3074 props.get ("fontsize").double_value ());
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3075 #endif
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3076 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3077
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3078 void
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3079 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
3080 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3081 if (on)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3082 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3083 glPolygonOffset (offset, offset);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3084 glEnable (GL_POLYGON_OFFSET_FILL);
7906
b3becd212f3f Draw markers above lines
John W. Eaton <jwe@octave.org>
parents: 7904
diff changeset
3085 glEnable (GL_POLYGON_OFFSET_LINE);
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3086 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3087 else
7906
b3becd212f3f Draw markers above lines
John W. Eaton <jwe@octave.org>
parents: 7904
diff changeset
3088 {
b3becd212f3f Draw markers above lines
John W. Eaton <jwe@octave.org>
parents: 7904
diff changeset
3089 glDisable (GL_POLYGON_OFFSET_FILL);
b3becd212f3f Draw markers above lines
John W. Eaton <jwe@octave.org>
parents: 7904
diff changeset
3090 glDisable (GL_POLYGON_OFFSET_LINE);
b3becd212f3f Draw markers above lines
John W. Eaton <jwe@octave.org>
parents: 7904
diff changeset
3091 }
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3092 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3093
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3094 void
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3095 opengl_renderer::set_linewidth (float w)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3096 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3097 glLineWidth (w);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3098 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3099
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3100 void
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3101 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
3102 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3103 bool solid = false;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3104
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3105 if (s == "-")
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3106 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3107 glLineStipple (1, static_cast<unsigned short> (0xFFFF));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3108 solid = true;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3109 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3110 else if (s == ":")
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3111 glLineStipple (1, static_cast<unsigned short> (0x8888));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3112 else if (s == "--")
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3113 glLineStipple (1, static_cast<unsigned short> (0x0FFF));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3114 else if (s == "-.")
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3115 glLineStipple (1, static_cast<unsigned short> (0x020F));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3116 else
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3117 glLineStipple (1, static_cast<unsigned short> (0x0000));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3118
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3119 if (solid && ! use_stipple)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3120 glDisable (GL_LINE_STIPPLE);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3121 else
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3122 glEnable (GL_LINE_STIPPLE);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3123 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3124
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3125 void
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3126 opengl_renderer::set_clipbox (double x1, double x2, double y1, double y2,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3127 double z1, double z2)
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3128 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3129 double dx = (x2-x1);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3130 double dy = (y2-y1);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3131 double dz = (z2-z1);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3132
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3133 x1 -= 0.001*dx; x2 += 0.001*dx;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3134 y1 -= 0.001*dy; y2 += 0.001*dy;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3135 z1 -= 0.001*dz; z2 += 0.001*dz;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3136
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3137 ColumnVector p (4, 0.0);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3138
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3139 p(0) = -1; p(3) = x2;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3140 glClipPlane (GL_CLIP_PLANE0, p.data ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3141 p(0) = 1; p(3) = -x1;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3142 glClipPlane (GL_CLIP_PLANE1, p.data ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3143 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
3144 glClipPlane (GL_CLIP_PLANE2, p.data ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3145 p(1) = 1; p(3) = -y1;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3146 glClipPlane (GL_CLIP_PLANE3, p.data ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3147 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
3148 glClipPlane (GL_CLIP_PLANE4, p.data ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3149 p(2) = 1; p(3) = -z1;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3150 glClipPlane (GL_CLIP_PLANE5, p.data ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3151
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3152 xmin = x1; xmax = x2;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3153 ymin = y1; ymax = y2;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3154 zmin = z1; zmax = z2;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3155 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3156
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3157 void
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3158 opengl_renderer::set_clipping (bool enable)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3159 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3160 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
3161
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3162 if (enable != has_clipping)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3163 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3164 if (enable)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3165 for (int i = 0; i < 6; i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3166 glEnable (GL_CLIP_PLANE0+i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3167 else
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3168 for (int i = 0; i < 6; i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3169 glDisable (GL_CLIP_PLANE0+i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3170 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3171 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3172
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3173 void
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3174 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
3175 {
8724
a50228129dba Introduce new macro OCTAVE_GLUTESSCALLBACK_THREEDOTS. Use definitions HAVE_FRAMEWORK_OPENGL and HAVE_GLUTESSCALLBACK_THREEDOTS for Mac's framework OpenGL implementation.
Ben Abbott <bpabbott@mac.com>
parents: 8674
diff changeset
3176 #if defined (HAVE_FRAMEWORK_OPENGL)
a50228129dba Introduce new macro OCTAVE_GLUTESSCALLBACK_THREEDOTS. Use definitions HAVE_FRAMEWORK_OPENGL and HAVE_GLUTESSCALLBACK_THREEDOTS for Mac's framework OpenGL implementation.
Ben Abbott <bpabbott@mac.com>
parents: 8674
diff changeset
3177 GLint vw[4];
a50228129dba Introduce new macro OCTAVE_GLUTESSCALLBACK_THREEDOTS. Use definitions HAVE_FRAMEWORK_OPENGL and HAVE_GLUTESSCALLBACK_THREEDOTS for Mac's framework OpenGL implementation.
Ben Abbott <bpabbott@mac.com>
parents: 8674
diff changeset
3178 #else
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3179 int vw[4];
8724
a50228129dba Introduce new macro OCTAVE_GLUTESSCALLBACK_THREEDOTS. Use definitions HAVE_FRAMEWORK_OPENGL and HAVE_GLUTESSCALLBACK_THREEDOTS for Mac's framework OpenGL implementation.
Ben Abbott <bpabbott@mac.com>
parents: 8674
diff changeset
3180 #endif
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3181
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3182 glGetIntegerv (GL_VIEWPORT, vw);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3183
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3184 glMatrixMode (GL_PROJECTION);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3185 glPushMatrix ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3186 glLoadIdentity ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3187 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
3188 glMatrixMode (GL_MODELVIEW);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3189 glPushMatrix ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3190
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3191 set_clipping (false);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3192 set_linewidth (width);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3193
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3194 marker_id = make_marker_list (m, size, false);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3195 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
3196 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3197
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3198 void
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3199 opengl_renderer::end_marker (void)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3200 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3201 glDeleteLists (marker_id, 1);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3202 glDeleteLists (filled_marker_id, 1);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3203
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3204 glMatrixMode (GL_MODELVIEW);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3205 glPopMatrix ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3206 glMatrixMode (GL_PROJECTION);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3207 glPopMatrix ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3208 set_linewidth (0.5f);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3209 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3210
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3211 void
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3212 opengl_renderer::draw_marker (double x, double y, double z,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3213 const Matrix& lc, const Matrix& fc)
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3214 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3215 ColumnVector tmp = xform.transform (x, y, z, false);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
3216
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3217 glLoadIdentity ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3218 glTranslated (tmp(0), tmp(1), -tmp(2));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3219
7907
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
3220 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
3221 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3222 glColor3dv (fc.data ());
7906
b3becd212f3f Draw markers above lines
John W. Eaton <jwe@octave.org>
parents: 7904
diff changeset
3223 set_polygon_offset (true, -1.0);
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3224 glCallList (filled_marker_id);
7906
b3becd212f3f Draw markers above lines
John W. Eaton <jwe@octave.org>
parents: 7904
diff changeset
3225 if (lc.numel () > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3226 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3227 glColor3dv (lc.data ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3228 glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3229 glEdgeFlag (GL_TRUE);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3230 set_polygon_offset (true, -2.0);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3231 glCallList (filled_marker_id);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3232 glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3233 }
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3234 set_polygon_offset (false);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3235 }
7907
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
3236 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
3237 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3238 glColor3dv (lc.data ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3239 glCallList (marker_id);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3240 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3241 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3242
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3243 unsigned int
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3244 opengl_renderer::make_marker_list (const std::string& marker, double size,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3245 bool filled) const
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3246 {
7907
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
3247 char c = marker[0];
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
3248
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
3249 if (filled && (c == '+' || c == 'x' || c == '*' || c == '.'))
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
3250 return 0;
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
3251
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3252 unsigned int ID = glGenLists (1);
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
3253 double sz = size * toolkit.get_screen_resolution () / 72.0;
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3254
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3255 // constants for the * marker
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3256 const double sqrt2d4 = 0.35355339059327;
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3257 double tt = sz*sqrt2d4;
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3258
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3259 glNewList (ID, GL_COMPILE);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3260
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3261 switch (marker[0])
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3262 {
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3263 case '+':
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3264 glBegin (GL_LINES);
9681
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
3265 glVertex2f (-sz/2, 0);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
3266 glVertex2f (sz/2, 0);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
3267 glVertex2f (0, -sz/2);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
3268 glVertex2f (0, sz/2);
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3269 glEnd ();
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3270 break;
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3271 case 'x':
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3272 glBegin(GL_LINES);
9681
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
3273 glVertex2f (-sz/2, -sz/2);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
3274 glVertex2f (sz/2, sz/2);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
3275 glVertex2f (-sz/2, sz/2);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
3276 glVertex2f (sz/2, -sz/2);
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3277 glEnd ();
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3278 break;
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3279 case '*':
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3280 glBegin (GL_LINES);
9681
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
3281 glVertex2f (-sz/2, 0);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
3282 glVertex2f (sz/2, 0);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
3283 glVertex2f (0, -sz/2);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
3284 glVertex2f (0, sz/2);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
3285 glVertex2f (-tt, -tt);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
3286 glVertex2f (+tt, +tt);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
3287 glVertex2f (-tt, +tt);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
3288 glVertex2f (+tt, -tt);
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3289 glEnd ();
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3290 break;
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3291 case '.':
10924
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3292 {
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3293 double ang_step = M_PI / 5;
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3294
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3295 glBegin (GL_POLYGON);
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3296 for (double ang = 0; ang < (2*M_PI); ang += ang_step)
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3297 glVertex2d (sz*cos(ang)/6, sz*sin(ang)/6);
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3298 glEnd ();
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3299 }
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3300 break;
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3301 case 's':
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3302 glBegin ((filled ? GL_POLYGON : GL_LINE_LOOP));
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3303 glVertex2d (-sz/2, -sz/2);
9681
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
3304 glVertex2d (-sz/2, sz/2);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
3305 glVertex2d (sz/2, sz/2);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
3306 glVertex2d (sz/2, -sz/2);
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3307 glEnd();
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3308 break;
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3309 case 'o':
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3310 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3311 double ang_step = M_PI / 5;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3312
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3313 glBegin ((filled ? GL_POLYGON : GL_LINE_LOOP));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3314 for (double ang = 0; ang < (2*M_PI); ang += ang_step)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3315 glVertex2d (sz*cos(ang)/2, sz*sin(ang)/2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3316 glEnd ();
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3317 }
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3318 break;
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3319 case 'd':
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3320 glBegin ((filled ? GL_POLYGON : GL_LINE_LOOP));
9681
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
3321 glVertex2d (0, -sz/2);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
3322 glVertex2d (sz/2, 0);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
3323 glVertex2d (0, sz/2);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
3324 glVertex2d (-sz/2, 0);
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3325 glEnd();
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3326 break;
10835
4bbd6f75f173 gl-render.cc: Transpose markers '^' and 'v'.
Ben Abbott <bpabbott@mac.com>
parents: 10402
diff changeset
3327 case 'v':
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3328 glBegin ((filled ? GL_POLYGON : GL_LINE_LOOP));
9681
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
3329 glVertex2f (0, sz/2);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
3330 glVertex2f (sz/2, -sz/2);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
3331 glVertex2f (-sz/2, -sz/2);
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3332 glEnd ();
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3333 break;
10835
4bbd6f75f173 gl-render.cc: Transpose markers '^' and 'v'.
Ben Abbott <bpabbott@mac.com>
parents: 10402
diff changeset
3334 case '^':
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3335 glBegin ((filled ? GL_POLYGON : GL_LINE_LOOP));
9681
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
3336 glVertex2f (0, -sz/2);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
3337 glVertex2f (-sz/2, sz/2);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
3338 glVertex2f (sz/2, sz/2);
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3339 glEnd ();
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3340 break;
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3341 case '>':
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3342 glBegin ((filled ? GL_POLYGON : GL_LINE_LOOP));
9681
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
3343 glVertex2f (sz/2, 0);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
3344 glVertex2f (-sz/2, sz/2);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
3345 glVertex2f (-sz/2, -sz/2);
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3346 glEnd ();
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3347 break;
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3348 case '<':
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3349 glBegin ((filled ? GL_POLYGON : GL_LINE_LOOP));
9681
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
3350 glVertex2f (-sz/2, 0);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
3351 glVertex2f (sz/2, -sz/2);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
3352 glVertex2f (sz/2, sz/2);
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3353 glEnd ();
7906
b3becd212f3f Draw markers above lines
John W. Eaton <jwe@octave.org>
parents: 7904
diff changeset
3354 break;
10924
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3355 case 'p':
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3356 {
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3357 double ang;
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3358 double r;
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3359 double dr = 1.0 - sin(M_PI/10)/sin(3*M_PI/10)*1.02;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
3360
10924
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3361 glBegin ((filled ? GL_POLYGON : GL_LINE_LOOP));
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3362 for (int i = 0; i < 2*5; i++)
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3363 {
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3364 ang = (-0.5 + double(i+1)/5) * M_PI;
11209
94d9d412a2a0 improve Matlab compatibility of rem and mod
John W. Eaton <jwe@octave.org>
parents: 11186
diff changeset
3365 r = 1.0 - (dr * fmod(double(i+1), 2.0));
10924
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3366 glVertex2d (sz*r*cos(ang)/2, sz*r*sin(ang)/2);
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3367 }
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3368 glEnd ();
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3369 }
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3370 break;
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3371 case 'h':
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3372 {
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3373 double ang;
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3374 double r;
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3375 double dr = 1.0 - 0.5/sin(M_PI/3)*1.02;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
3376
10924
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3377 glBegin ((filled ? GL_POLYGON : GL_LINE_LOOP));
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3378 for (int i = 0; i < 2*6; i++)
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3379 {
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3380 ang = (0.5 + double(i+1)/6.0) * M_PI;
11209
94d9d412a2a0 improve Matlab compatibility of rem and mod
John W. Eaton <jwe@octave.org>
parents: 11186
diff changeset
3381 r = 1.0 - (dr * fmod(double(i+1), 2.0));
10924
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3382 glVertex2d (sz*r*cos(ang)/2, sz*r*sin(ang)/2);
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3383 }
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3384 glEnd ();
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3385 }
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3386 break;
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3387 default:
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3388 warning ("opengl_renderer: unsupported marker `%s'",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3389 marker.c_str ());
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3390 break;
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3391 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3392
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3393 glEndList ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3394
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3395 return ID;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3396 }
7874
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7870
diff changeset
3397
9834
92d8f35ff217 compute bounding boxes for text in opengl graphics backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
3398 void
92d8f35ff217 compute bounding boxes for text in opengl graphics backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
3399 opengl_renderer::text_to_pixels (const std::string& txt,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3400 uint8NDArray& pixels,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3401 Matrix& bbox,
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
3402 int halign, int valign, double rotation)
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3403 {
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
3404 text_renderer.text_to_pixels (txt, pixels, bbox,
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
3405 halign, valign, rotation);
9834
92d8f35ff217 compute bounding boxes for text in opengl graphics backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
3406 }
92d8f35ff217 compute bounding boxes for text in opengl graphics backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
3407
92d8f35ff217 compute bounding boxes for text in opengl graphics backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
3408 Matrix
92d8f35ff217 compute bounding boxes for text in opengl graphics backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
3409 opengl_renderer::render_text (const std::string& txt,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3410 double x, double y, double z,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3411 int halign, int valign, double rotation)
9834
92d8f35ff217 compute bounding boxes for text in opengl graphics backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
3412 {
92d8f35ff217 compute bounding boxes for text in opengl graphics backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
3413 #if HAVE_FREETYPE
92d8f35ff217 compute bounding boxes for text in opengl graphics backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
3414 if (txt.empty ())
92d8f35ff217 compute bounding boxes for text in opengl graphics backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
3415 return Matrix (1, 4, 0.0);
92d8f35ff217 compute bounding boxes for text in opengl graphics backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
3416
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
3417 uint8NDArray pixels;
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3418 Matrix bbox;
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
3419 text_to_pixels (txt, pixels, bbox, halign, valign, rotation);
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3420
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3421 bool blend = glIsEnabled (GL_BLEND);
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3422
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3423 glEnable (GL_BLEND);
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3424 glEnable (GL_ALPHA_TEST);
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3425 glRasterPos3d (x, y, z);
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
3426 glBitmap(0, 0, 0, 0, bbox(0), bbox(1), 0);
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
3427 glDrawPixels (bbox(2), bbox(3),
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3428 GL_RGBA, GL_UNSIGNED_BYTE, pixels.data ());
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3429 glDisable (GL_ALPHA_TEST);
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3430 if (! blend)
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3431 glDisable (GL_BLEND);
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3432
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3433 return bbox;
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3434 #else
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9687
diff changeset
3435 ::warning ("render_text: cannot render text, Freetype library not available");
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3436 return Matrix (1, 4, 0.0);
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3437 #endif
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3438 }
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3439
7954
3ffc34caec65 configure fixes
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
3440 #endif