annotate src/gl-render.cc @ 15069:7a3957ca99c3

Handle complex arguments in imagesc (bug #36866) * image.m: Don't error out with complex images, show real part and warn, like imshow. * graphics.in.h (array_property): Change type_constraint to std::set instead of std::list. (array_property::add_constraint): Use std::set::insert instead of std::list::push_back. (image::properties::init): Add new "real" constraint. * graphics.cc (array_property::validate): Check for new "real" type constraint. * gl-render.cc (opengl_renderer::draw_image): Abort if no image data is found.
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Tue, 31 Jul 2012 18:06:54 -0400
parents f7afecdd87ef
children
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
14138
72c96de7a403 maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents: 13985
diff changeset
3 Copyright (C) 2008-2012 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"
13985
43cc49c7abd1 Use thread-safe atomic reference counting (GCC and MSVC).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13961
diff changeset
33 #include "oct-refcount.h"
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
34 #include "gl-render.h"
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
35 #include "txt-eng.h"
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
36 #include "txt-eng-ft.h"
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
37
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
38 #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
39
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
40 // 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
41 // 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
42 // 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
43 #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
44 #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
45 #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
46
7870
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
47 static octave_idx_type
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
48 xmin (octave_idx_type x, octave_idx_type y)
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
49 {
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
50 return x < y ? x : y;
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
51 }
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
52
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
53 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
54 opengl_texture
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
55 {
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
56 protected:
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
57 class texture_rep
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
58 {
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
59 public:
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
60 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
61 : 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
62 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
63 { }
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
64
9681
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
65 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
66 : 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
67 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
68 count (1) { }
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
69
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
70 ~texture_rep (void)
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
71 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
72 if (valid)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
73 glDeleteTextures (1, &id);
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
74 }
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
75
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
76 void bind (int mode) const
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
77 { if (valid) glBindTexture (mode, id); }
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
78
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
79 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
80 { 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
81
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
82 GLuint id;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
83 int w, h;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
84 int tw, th;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
85 double tx, ty;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
86 bool valid;
12125
a21a3875ca83 implement a common class for reference counts
Jaroslav Hajek <highegg@gmail.com>
parents: 12122
diff changeset
87 octave_refcount<int> count;
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
88 };
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
89
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
90 texture_rep *rep;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
91
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
92 private:
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
93 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
94
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
95 public:
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
96 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
97
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
98 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
99 : rep (tx.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 rep->count++;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
102 }
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
103
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
104 ~opengl_texture (void)
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
105 {
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
106 if (--rep->count == 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
107 delete rep;
7831
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& operator = (const opengl_texture& tx)
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 rep = tx.rep;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
116 rep->count++;
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 return *this;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
119 }
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
120
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
121 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
122
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
123 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
124 { rep->bind (mode); }
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 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
127 { rep->tex_coord (q, r); }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
128
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
129 bool is_valid (void) const
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
130 { return rep->valid; }
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
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
133 static int
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
134 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
135 {
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
136 int m = 1;
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 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
139 m <<= 1;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
140
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
141 return m;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
142 }
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
143
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
144 opengl_texture
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
145 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
146 {
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
147 opengl_texture retval;
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 dim_vector dv (data.dims ());
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
150
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
151 // Expect RGB data
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
152 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
153 {
9681
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
154 // 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
155 // 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
156 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
157 GLuint id;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
158 bool ok = true;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
159
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
160 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
161 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
162
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
163 glGenTextures (1, &id);
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
164 glBindTexture (GL_TEXTURE_2D, id);
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 if (data.is_double_type ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
167 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
168 const NDArray xdata = data.array_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
169
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
170 OCTAVE_LOCAL_BUFFER (float, a, (3*tw*th));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
171
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
172 for (int i = 0; i < h; i++)
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 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
175 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
176 a[idx] = xdata(i,j,0);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
177 a[idx+1] = xdata(i,j,1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
178 a[idx+2] = xdata(i,j,2);
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 }
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 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
183 GL_RGB, GL_FLOAT, a);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
184 }
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
185 else if (data.is_uint8_type ())
10315
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 const uint8NDArray xdata = data.uint8_array_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
188
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
189 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
190
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
191 for (int i = 0; i < h; i++)
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 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
194 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
195 a[idx] = xdata(i,j,0);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
196 a[idx+1] = xdata(i,j,1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
197 a[idx+2] = xdata(i,j,2);
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 }
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 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
202 GL_RGB, GL_UNSIGNED_BYTE, a);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
203 }
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
204 else
10315
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 ok = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
207 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
208 }
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
209
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
210 if (ok)
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 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
213 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
214
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
215 if (glGetError () != GL_NO_ERROR)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
216 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
217 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
218 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
219 }
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
220 }
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
221 else
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
222 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
223
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
224 return retval;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
225 }
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
226
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
227 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
228 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
229 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
230 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
231 #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
232 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
233 #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
234 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
235 #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
236
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
237 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
238
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14838
diff changeset
239 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
240
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
241 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
242 { 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
243
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
244 void begin_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
245 {
8ff92634982d Add initial 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 gluTessProperty (glu_tess, GLU_TESS_BOUNDARY_ONLY,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
247 (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
248 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
249 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
250 }
8ff92634982d Add initial 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 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
253 { 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
254
8ff92634982d Add initial 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 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
256 { 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
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_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
259 { 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
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 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
262 { 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
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 protected:
7870
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
265 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
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 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
268
7870
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
269 virtual void vertex (void */*data*/) { }
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
270
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
271 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
272 GLfloat /*w*/[4], void **/*out_data*/) { }
7870
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
273
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
274 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
275
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
276 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
277 { ::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
278
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
279 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
280 {
8ff92634982d Add initial 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 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
282
8ff92634982d Add initial 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 gluTessCallback (glu_tess, GLU_TESS_BEGIN_DATA,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
284 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
285 gluTessCallback (glu_tess, GLU_TESS_END_DATA,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
286 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
287 gluTessCallback (glu_tess, GLU_TESS_VERTEX_DATA,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
288 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
289 gluTessCallback (glu_tess, GLU_TESS_COMBINE_DATA,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
290 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
291 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
292 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
293 gluTessCallback (glu_tess, GLU_TESS_ERROR_DATA,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
294 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
295 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
296
8ff92634982d Add initial 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 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
298
8ff92634982d Add initial 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 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
300 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
301 { 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
302
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
303 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
304 { reinterpret_cast<opengl_tesselator *> (t)->end (); }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
305
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
306 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
307 { 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
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_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
310 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
311 { 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
312
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
313 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
314 { 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
315
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
316 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
317 { 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
318
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
319 private:
12122
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11586
diff changeset
320
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11586
diff changeset
321 // No copying!
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11586
diff changeset
322
12174
db1f49eaba6b whitespace fixes
John W. Eaton <jwe@octave.org>
parents: 12164
diff changeset
323 opengl_tesselator (const opengl_tesselator&);
db1f49eaba6b whitespace fixes
John W. Eaton <jwe@octave.org>
parents: 12164
diff changeset
324
db1f49eaba6b whitespace fixes
John W. Eaton <jwe@octave.org>
parents: 12164
diff changeset
325 opengl_tesselator operator = (const opengl_tesselator&);
12122
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11586
diff changeset
326
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
327 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
328 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
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
8ff92634982d Add initial 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 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
332 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
333 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
334 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
335 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
336 {
8ff92634982d Add initial 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 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
338 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
339 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
340 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
341 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
342 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
343 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
344 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
345 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
346
8ff92634982d Add initial 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 // reference counter
12125
a21a3875ca83 implement a common class for reference counts
Jaroslav Hajek <highegg@gmail.com>
parents: 12122
diff changeset
348 octave_refcount<int> 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
349
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
350 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
351 : 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
352 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
353
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
354 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
355 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
356 : coords (c), color (col), normal (n), alpha (a),
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
357 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
358 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
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
8ff92634982d Add initial 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 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
362 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
363
8ff92634982d Add initial 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 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
365 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
366 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
367
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
368 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
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
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
371 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
372 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
373 { 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
374
8ff92634982d Add initial 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 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
376 { 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
377
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
378 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
379 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
380 : 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
381 { }
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
382
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
383 vertex_data (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
384 : 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
385
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
386 ~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
387 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
388 if (--rep->count == 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
389 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
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
8ff92634982d Add initial 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 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
393 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
394 if (--rep->count == 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
395 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
396
8ff92634982d Add initial 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 = 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
398 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
399
8ff92634982d Add initial 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 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
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
8ff92634982d Add initial 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 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
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
8ff92634982d Add initial 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 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
407 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
408 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
409 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
410 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
411 : 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
412 color_mode (cmode), light_mode (lmode), index (idx),
12164
18e9a8da7d18 eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 12126
diff changeset
413 first (true), tmp_vdata ()
18e9a8da7d18 eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 12126
diff changeset
414 { }
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
415
8ff92634982d Add initial 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 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
417 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
418 {
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
419 //printf ("patch_tesselator::begin (%d)\n", 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
420 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
421
8ff92634982d Add initial 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 if (color_mode == 2 || light_mode == 2)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
423 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
424 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
425 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
426
8ff92634982d Add initial 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 if (is_filled ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
428 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
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 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
431 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
432
8ff92634982d Add initial 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 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
434 {
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
435 //printf ("patch_tesselator::end\n");
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
436 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
437 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
438 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
439
8ff92634982d Add initial 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 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
441 {
8ff92634982d Add initial 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 vertex_data::vertex_data_rep *v
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
443 = reinterpret_cast<vertex_data::vertex_data_rep *> (data);
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
444 //printf ("patch_tesselator::vertex (%g, %g, %g)\n", v->coords(0), v->coords(1), v->coords(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
445
8ff92634982d Add initial 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 // 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
447 // 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
448 // 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
449 // 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
450 // 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
451 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
452 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
453 Matrix col = v->color;
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 if (col.numel () == 3)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
456 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
457 glColor3dv (col.data ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
458 if (light_mode > 0)
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 float buf[4] = { 0, 0, 0, 1 };
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
461
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
462 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
463 buf[k] = (v->ambient * col(k));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
464 glMaterialfv (LIGHT_MODE, GL_AMBIENT, buf);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
465
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
466 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
467 buf[k] = (v->diffuse * col(k));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
468 glMaterialfv (LIGHT_MODE, GL_AMBIENT, buf);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
469 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
470 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
471 }
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
472
8ff92634982d Add initial 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 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
474 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
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 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
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 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
479 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
480
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
481 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
482 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
483 {
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
484 //printf ("patch_tesselator::combine\n");
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
485
7837
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
486 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
487 int vmax = 4;
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
488
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
489 for (int i = 0; i < 4; i++)
10315
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 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
492
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
493 if (vmax == 4 && ! v[i])
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
494 vmax = i;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
495 }
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
496
8ff92634982d Add initial 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 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
498 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
499 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
500 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
501
8ff92634982d Add initial 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(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
503 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
504 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
505
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
506 if (v[0]->color.numel ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
507 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
508 cc.resize (1, 3, 0.0);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
509 for (int ic = 0; ic < 3; ic++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
510 for (int iv = 0; iv < vmax; iv++)
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
511 cc(ic) += (w[iv] * v[iv]->color (ic));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
512 }
7837
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
513
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
514 if (v[0]->normal.numel () > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
515 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
516 for (int in = 0; in < 3; in++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
517 for (int iv = 0; iv < vmax; iv++)
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
518 nn(in) += (w[iv] * v[iv]->normal (in));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
519 }
7837
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
520
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
521 for (int iv = 0; iv < vmax; iv++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
522 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
523
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
524 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
525 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
526 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
527
57095ca98533 Make OpenGL tessellation combine callback robust against NULL vertex data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7834
diff changeset
528 *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
529 }
8ff92634982d Add initial 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
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
531 private:
12122
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11586
diff changeset
532
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11586
diff changeset
533 // No copying!
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11586
diff changeset
534
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11586
diff changeset
535 patch_tesselator (const patch_tesselator&);
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11586
diff changeset
536
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11586
diff changeset
537 patch_tesselator& operator = (const patch_tesselator&);
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11586
diff changeset
538
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
539 opengl_renderer *renderer;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
540 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
541 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
542 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
543 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
544 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
545 };
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
546
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
547 void
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
548 opengl_renderer::draw (const graphics_object& go, bool toplevel)
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
549 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
550 if (! go.valid_object ())
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
551 return;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
552
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
553 const base_properties& props = go.get_properties ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
554
14838
1abb7c083171 Make sure opengl_renderer::toolkit is defined.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 14138
diff changeset
555 if (! toolkit)
1abb7c083171 Make sure opengl_renderer::toolkit is defined.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 14138
diff changeset
556 toolkit = props.get_toolkit ();
1abb7c083171 Make sure opengl_renderer::toolkit is defined.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 14138
diff changeset
557
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
558 if (go.isa ("figure"))
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9687
diff changeset
559 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
560 else if (go.isa ("axes"))
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9687
diff changeset
561 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
562 else if (go.isa ("line"))
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9687
diff changeset
563 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
564 else if (go.isa ("surface"))
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9687
diff changeset
565 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
566 else if (go.isa ("patch"))
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9687
diff changeset
567 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
568 else if (go.isa ("hggroup"))
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9687
diff changeset
569 draw_hggroup (dynamic_cast<const hggroup::properties&> (props));
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
570 else if (go.isa ("text"))
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9687
diff changeset
571 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
572 else if (go.isa ("image"))
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9687
diff changeset
573 draw_image (dynamic_cast<const image::properties&> (props));
13703
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13281
diff changeset
574 else if (go.isa ("uimenu") || go.isa ("uicontrol")
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13281
diff changeset
575 || go.isa ("uicontextmenu") || go.isa ("uitoolbar")
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13281
diff changeset
576 || go.isa ("uipushtool") || go.isa ("uitoggletool"))
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
577 /* SKIP */;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
578 else if (go.isa ("uipanel"))
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
579 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
580 if (toplevel)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
581 draw_uipanel (dynamic_cast<const uipanel::properties&> (props), go);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
582 }
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
583 else
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
584 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
585 warning ("opengl_renderer: cannot render object of type `%s'",
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
586 props.graphics_object_name ().c_str ());
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
587 }
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
588 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
589
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
590 void
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9687
diff changeset
591 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
592 {
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
593 // Initialize OpenGL context
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
594
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
595 init_gl_context (props.is___enhanced__ (), props.get_color_rgb ());
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
596
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
597 // Draw children
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
598
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
599 draw (props.get_all_children (), false);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
600 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
601
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
602 void
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
603 opengl_renderer::draw_uipanel (const uipanel::properties& props,
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
604 const graphics_object& go)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
605 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
606 graphics_object fig = go.get_ancestor ("figure");
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
607 const figure::properties& figProps =
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
608 dynamic_cast<const figure::properties&> (fig.get_properties ());
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
609
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
610 // Initialize OpenGL context
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
611
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
612 init_gl_context (figProps.is___enhanced__ (),
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
613 props.get_backgroundcolor_rgb ());
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
614
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
615 // Draw children
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
616
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
617 draw (props.get_all_children (), false);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
618 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
619
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
620 void
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
621 opengl_renderer::init_gl_context (bool enhanced, const Matrix& c)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
622 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
623 // Initialize OpenGL context
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
624
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
625 glEnable (GL_DEPTH_TEST);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
626 glDepthFunc (GL_LEQUAL);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
627 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
628 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
629 glEnable (GL_NORMALIZE);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
630
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
631 if (enhanced)
7907
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
632 {
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
633 glEnable (GL_BLEND);
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
634 glEnable (GL_LINE_SMOOTH);
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
635 }
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
636 else
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
637 {
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
638 glDisable (GL_BLEND);
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
639 glDisable (GL_LINE_SMOOTH);
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
640 }
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
641
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
642 // Clear background
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
643
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14838
diff changeset
644 if (c.length () >= 3)
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
645 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
646 glClearColor (c(0), c(1), c(2), 1);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
647 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
648 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
649 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
650
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
651 void
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
652 opengl_renderer::render_grid (const std::string& gridstyle,
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
653 const Matrix& ticks, double lim1, double lim2,
12126
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
654 double p1, double p1N, double p2, double p2N,
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
655 int xyz, bool is_3D)
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
656 {
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
657 set_linestyle (gridstyle, true);
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
658 glBegin (GL_LINES);
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
659 for (int i = 0; i < ticks.numel (); i++)
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
660 {
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
661 double val = ticks(i);
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
662 if (lim1 <= val && val <= lim2)
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
663 {
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
664 if (xyz == 0) // X
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
665 {
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
666 glVertex3d (val, p1N, p2);
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
667 glVertex3d (val, p1, p2);
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
668 if (is_3D)
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
669 {
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
670 glVertex3d (val, p1, p2N);
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
671 glVertex3d (val, p1, p2);
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
672 }
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
673 }
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
674 else if (xyz == 1) // Y
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
675 {
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
676 glVertex3d (p1N, val, p2);
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
677 glVertex3d (p1, val, p2);
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
678 if (is_3D)
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
679 {
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
680 glVertex3d (p1, val, p2N);
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
681 glVertex3d (p1, val, p2);
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
682 }
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
683 }
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
684 else if (xyz == 2) // Z
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
685 {
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
686 glVertex3d (p1N, p2, val);
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
687 glVertex3d (p1, p2, val);
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
688 glVertex3d (p1, p2N, val);
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
689 glVertex3d (p1, p2, val);
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
690 }
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
691 }
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
692 }
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
693 glEnd ();
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
694 set_linestyle ("-", true);
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
695 }
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
696
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
697 void
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
698 opengl_renderer::render_tickmarks (const Matrix& ticks,
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
699 double lim1, double lim2,
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
700 double p1, double p1N,
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
701 double p2, double p2N,
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
702 double dx, double dy, double dz,
12684
abfcb5d5641b Disable mirrored axes ticks for plottyy in ftlk
Konstantinos Poulios <logari81@googlemail.com>
parents: 12446
diff changeset
703 int xyz, bool mirror)
12126
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
704 {
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
705 glBegin (GL_LINES);
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
706
12126
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
707 for (int i = 0; i < ticks.numel (); i++)
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
708 {
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
709 double val = ticks(i);
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
710
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
711 if (lim1 <= val && val <= lim2)
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
712 {
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
713 if (xyz == 0) // X
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
714 {
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
715 glVertex3d (val, p1, p2);
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
716 glVertex3d (val, p1+dy, p2+dz);
12684
abfcb5d5641b Disable mirrored axes ticks for plottyy in ftlk
Konstantinos Poulios <logari81@googlemail.com>
parents: 12446
diff changeset
717 if (mirror)
12126
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
718 {
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
719 glVertex3d (val, p1N, p2N);
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
720 glVertex3d (val, p1N-dy, p2N-dz);
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
721 }
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
722 }
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
723 else if (xyz == 1) // Y
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
724 {
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
725 glVertex3d (p1, val, p2);
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
726 glVertex3d (p1+dx, val, p2+dz);
12684
abfcb5d5641b Disable mirrored axes ticks for plottyy in ftlk
Konstantinos Poulios <logari81@googlemail.com>
parents: 12446
diff changeset
727 if (mirror)
12126
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
728 {
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
729 glVertex3d (p1N, val, p2N);
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
730 glVertex3d (p1N-dx, val, p2N-dz);
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
731 }
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
732 }
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
733 else if (xyz == 2) // Z
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
734 {
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
735 glVertex3d (p1, p2, val);
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
736 glVertex3d (p1+dx, p2+dy, val);
12684
abfcb5d5641b Disable mirrored axes ticks for plottyy in ftlk
Konstantinos Poulios <logari81@googlemail.com>
parents: 12446
diff changeset
737 if (mirror)
12126
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
738 {
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
739 glVertex3d (p1N, p2N, val);
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
740 glVertex3d (p1N-dx, p2N-dy, val);
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
741 }
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
742 }
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
743 }
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
744 }
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
745
12126
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
746 glEnd ();
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
747 }
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
748
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
749 void
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
750 opengl_renderer::render_ticktexts (const Matrix& ticks,
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
751 const string_vector& ticklabels,
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
752 double lim1, double lim2,
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
753 double p1, double p2,
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
754 int xyz, int ha, int va,
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
755 int& wmax, int& hmax)
12126
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
756 {
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
757 int n = std::min (ticklabels.numel (), ticks.numel ());
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
758
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
759 for (int i = 0; i < n; i++)
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
760 {
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
761 double val = ticks(i);
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
762
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
763 if (lim1 <= val && val <= lim2)
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
764 {
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
765 Matrix b;
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
766 // FIXME: as tick text is transparent, shouldn't be
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
767 // drawn after axes object, for correct rendering?
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
768 if (xyz == 0) // X
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
769 {
12174
db1f49eaba6b whitespace fixes
John W. Eaton <jwe@octave.org>
parents: 12164
diff changeset
770 b = render_text (ticklabels(i), val, p1, p2, ha, va);
12126
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
771 }
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
772 else if (xyz == 1) // Y
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
773 {
12174
db1f49eaba6b whitespace fixes
John W. Eaton <jwe@octave.org>
parents: 12164
diff changeset
774 b = render_text (ticklabels(i), p1, val, p2, ha, va);
12126
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
775 }
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
776 else if (xyz == 2) // Z
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
777 {
12174
db1f49eaba6b whitespace fixes
John W. Eaton <jwe@octave.org>
parents: 12164
diff changeset
778 b = render_text (ticklabels(i), p1, p2, val, ha, va);
12126
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
779 }
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
780
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
781 wmax = std::max (wmax, static_cast<int> (b(2)));
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
782 hmax = std::max (hmax, static_cast<int> (b(3)));
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
783 }
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
784 }
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
785 }
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
786
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
787 void
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
788 opengl_renderer::setup_opengl_transformation (const axes::properties& props)
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
789 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
790 // setup OpenGL transformation
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
791
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
792 Matrix x_zlim = props.get_transform_zlim ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
793
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
794 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
795 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
796
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
797 Matrix x_mat1 = props.get_opengl_matrix_1 ();
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
798 Matrix x_mat2 = props.get_opengl_matrix_2 ();
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
799
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
800 #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
801 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
802 #else
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
803 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
804 #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
805
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
806 glGetIntegerv (GL_VIEWPORT, vw);
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 glMatrixMode (GL_MODELVIEW);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
809 glLoadIdentity ();
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
810 glScaled (1, 1, -1);
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
811 glMultMatrixd (x_mat1.data ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
812 glMatrixMode (GL_PROJECTION);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
813 glLoadIdentity ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
814 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
815 glMultMatrixd (x_mat2.data ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
816 glMatrixMode (GL_MODELVIEW);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
817
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
818 glClear (GL_DEPTH_BUFFER_BIT);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
819
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
820 glDisable (GL_LINE_SMOOTH);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
821
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
822 // store axes transformation data
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
823
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
824 xform = props.get_transform ();
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
825 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
826
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
827 void
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
828 opengl_renderer::draw_axes_planes (const axes::properties& props)
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
829 {
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
830 double xPlane = props.get_xPlane ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
831 double yPlane = props.get_yPlane ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
832 double zPlane = props.get_zPlane ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
833 double xPlaneN = props.get_xPlaneN ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
834 double yPlaneN = props.get_yPlaneN ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
835 double zPlaneN = props.get_zPlaneN ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
836
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
837 // Axes planes
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
838 Matrix axe_color = props.get_color_rgb ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
839 if (axe_color.numel () > 0 && props.is_visible ())
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
840 {
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
841 set_color (axe_color);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
842 set_polygon_offset (true, 2.5);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
843
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
844 glBegin (GL_QUADS);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
845
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
846 // X plane
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
847 glVertex3d (xPlane, yPlaneN, zPlaneN);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
848 glVertex3d (xPlane, yPlane, zPlaneN);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
849 glVertex3d (xPlane, yPlane, zPlane);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
850 glVertex3d (xPlane, yPlaneN, zPlane);
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
851
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
852 // Y plane
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
853 glVertex3d (xPlaneN, yPlane, zPlaneN);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
854 glVertex3d (xPlane, yPlane, zPlaneN);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
855 glVertex3d (xPlane, yPlane, zPlane);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
856 glVertex3d (xPlaneN, yPlane, zPlane);
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
857
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
858 // Z plane
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
859 glVertex3d (xPlaneN, yPlaneN, zPlane);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
860 glVertex3d (xPlane, yPlaneN, zPlane);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
861 glVertex3d (xPlane, yPlane, zPlane);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
862 glVertex3d (xPlaneN, yPlane, zPlane);
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
863
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
864 glEnd ();
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
865
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
866 set_polygon_offset (false);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
867 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
868 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
869
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
870 void
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
871 opengl_renderer::draw_axes_boxes (const axes::properties& props)
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
872 {
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
873 bool xySym = props.get_xySym ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
874 double xPlane = props.get_xPlane ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
875 double yPlane = props.get_yPlane ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
876 double zPlane = props.get_zPlane ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
877 double xPlaneN = props.get_xPlaneN ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
878 double yPlaneN = props.get_yPlaneN ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
879 double zPlaneN = props.get_zPlaneN ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
880 double xpTick = props.get_xpTick ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
881 double ypTick = props.get_ypTick ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
882 double zpTick = props.get_zpTick ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
883 double xpTickN = props.get_xpTickN ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
884 double ypTickN = props.get_ypTickN ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
885 double zpTickN = props.get_zpTickN ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
886
13216
434e227b100b Improvements to plotyy.
Ben Abbott <bpabbott@mac.com>
parents: 13141
diff changeset
887 bool plotyy = (props.has_property ("__plotyy_axes__"));
12443
24b38afd6a45 fix plotyy bugs #31800, #32211
Konstantinos Poulios <logari81@googlemail.com>
parents: 12334
diff changeset
888
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
889 // Axes box
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
890
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
891 set_linestyle ("-", true);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
892 set_linewidth (props.get_linewidth ());
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
893
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
894 if (props.is_visible ())
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
895 {
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
896 glBegin (GL_LINES);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
897
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
898 // X box
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
899 set_color (props.get_xcolor_rgb ());
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
900 glVertex3d (xPlaneN, ypTick, zpTick);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
901 glVertex3d (xPlane, ypTick, zpTick);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
902
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
903 if (props.is_box ())
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
904 {
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
905 glVertex3d (xPlaneN, ypTickN, zpTick);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
906 glVertex3d (xPlane, ypTickN, zpTick);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
907 glVertex3d (xPlaneN, ypTickN, zpTickN);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
908 glVertex3d (xPlane, ypTickN, zpTickN);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
909 glVertex3d (xPlaneN, ypTick, zpTickN);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
910 glVertex3d (xPlane, ypTick, zpTickN);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
911 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
912
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
913 // Y box
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
914 set_color (props.get_ycolor_rgb ());
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
915 glVertex3d (xpTick, yPlaneN, zpTick);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
916 glVertex3d (xpTick, yPlane, zpTick);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
917
12443
24b38afd6a45 fix plotyy bugs #31800, #32211
Konstantinos Poulios <logari81@googlemail.com>
parents: 12334
diff changeset
918 if (props.is_box () && ! plotyy)
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
919 {
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
920 glVertex3d (xpTickN, yPlaneN, zpTick);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
921 glVertex3d (xpTickN, yPlane, zpTick);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
922 glVertex3d (xpTickN, yPlaneN, zpTickN);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
923 glVertex3d (xpTickN, yPlane, zpTickN);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
924 glVertex3d (xpTick, yPlaneN, zpTickN);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
925 glVertex3d (xpTick, yPlane, zpTickN);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
926 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
927
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
928 // Z box
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
929 set_color (props.get_zcolor_rgb ());
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
930
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
931 if (xySym)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
932 {
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
933 glVertex3d (xPlaneN, yPlane, zPlaneN);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
934 glVertex3d (xPlaneN, yPlane, zPlane);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
935 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
936 else
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
937 {
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
938 glVertex3d (xPlane, yPlaneN, zPlaneN);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
939 glVertex3d (xPlane, yPlaneN, zPlane);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
940 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
941
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
942 if (props.is_box ())
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
943 {
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
944 glVertex3d (xPlane, yPlane, zPlaneN);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
945 glVertex3d (xPlane, yPlane, zPlane);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
946
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
947 if (xySym)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
948 {
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
949 glVertex3d (xPlane, yPlaneN, zPlaneN);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
950 glVertex3d (xPlane, yPlaneN, zPlane);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
951 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
952 else
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
953 {
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
954 glVertex3d (xPlaneN, yPlane, zPlaneN);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
955 glVertex3d (xPlaneN, yPlane, zPlane);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
956 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
957
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
958 glVertex3d (xPlaneN, yPlaneN, zPlaneN);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
959 glVertex3d (xPlaneN, yPlaneN, zPlane);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
960 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
961
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
962 glEnd ();
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
963 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
964 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
965
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
966 void
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
967 opengl_renderer::draw_axes_x_grid (const axes::properties& props)
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
968 {
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
969 int xstate = props.get_xstate ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
970 int zstate = props.get_zstate ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
971 bool x2Dtop = props.get_x2Dtop ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
972 bool layer2Dtop = props.get_layer2Dtop ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
973 bool xyzSym = props.get_xyzSym ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
974 bool nearhoriz = props.get_nearhoriz ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
975 double xticklen = props.get_xticklen ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
976 double xtickoffset = props.get_xtickoffset ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
977 double fy = props.get_fy ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
978 double fz = props.get_fz ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
979 double x_min = props.get_x_min ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
980 double x_max = props.get_x_max ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
981 double yPlane = props.get_yPlane ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
982 double yPlaneN = props.get_yPlaneN ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
983 double ypTick = props.get_ypTick ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
984 double ypTickN = props.get_ypTickN ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
985 double zPlane = props.get_zPlane ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
986 double zPlaneN = props.get_zPlaneN ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
987 double zpTick = props.get_zpTick ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
988 double zpTickN = props.get_zpTickN ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
989
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
990 // X grid
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
991
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
992 if (props.is_visible () && xstate != AXE_DEPTH_DIR)
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
993 {
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
994 std::string gridstyle = props.get_gridlinestyle ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
995 std::string minorgridstyle = props.get_minorgridlinestyle ();
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
996 bool do_xgrid = (props.is_xgrid () && (gridstyle != "none"));
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
997 bool do_xminorgrid = (props.is_xminorgrid () && (minorgridstyle != "none"));
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
998 bool do_xminortick = props.is_xminortick ();
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
999 Matrix xticks = xform.xscale (props.get_xtick ().matrix_value ());
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1000 Matrix xmticks = xform.xscale (props.get_xmtick ().matrix_value ());
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1001 string_vector xticklabels = props.get_xticklabel ().all_strings ();
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1002 int wmax = 0, hmax = 0;
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1003 bool tick_along_z = nearhoriz || xisinf (fy);
12684
abfcb5d5641b Disable mirrored axes ticks for plottyy in ftlk
Konstantinos Poulios <logari81@googlemail.com>
parents: 12446
diff changeset
1004 bool mirror = props.is_box () && xstate != AXE_ANY_DIR;
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1005
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1006 set_color (props.get_xcolor_rgb ());
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1007
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1008 // grid lines
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1009 if (do_xgrid)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1010 render_grid (gridstyle, xticks, x_min, x_max,
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1011 yPlane, yPlaneN, layer2Dtop ? zPlaneN : zPlane,
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1012 zPlaneN, 0, (zstate != AXE_DEPTH_DIR));
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1013
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1014 // tick marks
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1015 if (tick_along_z)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1016 {
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1017 render_tickmarks (xticks, x_min, x_max, ypTick, ypTick,
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1018 zpTick, zpTickN, 0., 0.,
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1019 signum (zpTick-zpTickN)*fz*xticklen,
12684
abfcb5d5641b Disable mirrored axes ticks for plottyy in ftlk
Konstantinos Poulios <logari81@googlemail.com>
parents: 12446
diff changeset
1020 0, mirror);
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1021 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1022 else
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1023 {
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1024 render_tickmarks (xticks, x_min, x_max, ypTick, ypTickN,
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1025 zpTick, zpTick, 0.,
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1026 signum (ypTick-ypTickN)*fy*xticklen,
12684
abfcb5d5641b Disable mirrored axes ticks for plottyy in ftlk
Konstantinos Poulios <logari81@googlemail.com>
parents: 12446
diff changeset
1027 0., 0, mirror);
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1028 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1029
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1030 // tick texts
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1031 if (xticklabels.numel () > 0)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1032 {
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1033 int halign = (xstate == AXE_HORZ_DIR ? 1 : (xyzSym ? 0 : 2));
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1034 int valign = (xstate == AXE_VERT_DIR ? 1 : (x2Dtop ? 0 : 2));
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1035
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1036 if (tick_along_z)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1037 render_ticktexts (xticks, xticklabels, x_min, x_max, ypTick,
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1038 zpTick+signum (zpTick-zpTickN)*fz*xtickoffset,
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1039 0, halign, valign, wmax, hmax);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1040 else
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1041 render_ticktexts (xticks, xticklabels, x_min, x_max,
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1042 ypTick+signum (ypTick-ypTickN)*fy*xtickoffset,
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1043 zpTick, 0, halign, valign, wmax, hmax);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1044 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1045
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1046 // minor grid lines
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1047 if (do_xminorgrid)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1048 render_grid (minorgridstyle, xmticks, x_min, x_max,
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1049 yPlane, yPlaneN, layer2Dtop ? zPlaneN : zPlane,
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1050 zPlaneN, 0, (zstate != AXE_DEPTH_DIR));
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1051
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1052 // minor tick marks
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1053 if (do_xminortick)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1054 {
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1055 if (tick_along_z)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1056 render_tickmarks (xmticks, x_min, x_max, ypTick, ypTick,
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1057 zpTick, zpTickN, 0., 0.,
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1058 signum (zpTick-zpTickN)*fz*xticklen/2,
12684
abfcb5d5641b Disable mirrored axes ticks for plottyy in ftlk
Konstantinos Poulios <logari81@googlemail.com>
parents: 12446
diff changeset
1059 0, mirror);
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1060 else
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1061 render_tickmarks (xmticks, x_min, x_max, ypTick, ypTickN,
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1062 zpTick, zpTick, 0.,
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1063 signum (ypTick-ypTickN)*fy*xticklen/2,
12684
abfcb5d5641b Disable mirrored axes ticks for plottyy in ftlk
Konstantinos Poulios <logari81@googlemail.com>
parents: 12446
diff changeset
1064 0., 0, mirror);
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1065 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1066
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12333
diff changeset
1067 gh_manager::get_object (props.get_xlabel ()).set ("visible", "on");
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1068 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1069 else
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1070 gh_manager::get_object (props.get_xlabel ()).set ("visible", "off");
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1071 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1072
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1073 void
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1074 opengl_renderer::draw_axes_y_grid (const axes::properties& props)
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1075 {
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1076 int ystate = props.get_ystate ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1077 int zstate = props.get_zstate ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1078 bool y2Dright = props.get_y2Dright ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1079 bool layer2Dtop = props.get_layer2Dtop ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1080 bool xyzSym = props.get_xyzSym ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1081 bool nearhoriz = props.get_nearhoriz ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1082 double yticklen = props.get_yticklen ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1083 double ytickoffset = props.get_ytickoffset ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1084 double fx = props.get_fx ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1085 double fz = props.get_fz ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1086 double xPlane = props.get_xPlane ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1087 double xPlaneN = props.get_xPlaneN ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1088 double xpTick = props.get_xpTick ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1089 double xpTickN = props.get_xpTickN ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1090 double y_min = props.get_y_min ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1091 double y_max = props.get_y_max ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1092 double zPlane = props.get_zPlane ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1093 double zPlaneN = props.get_zPlaneN ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1094 double zpTick = props.get_zpTick ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1095 double zpTickN = props.get_zpTickN ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1096
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1097 // Y grid
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1098
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1099 if (ystate != AXE_DEPTH_DIR && props.is_visible ())
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1100 {
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1101 std::string gridstyle = props.get_gridlinestyle ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1102 std::string minorgridstyle = props.get_minorgridlinestyle ();
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1103 bool do_ygrid = (props.is_ygrid () && (gridstyle != "none"));
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1104 bool do_yminorgrid = (props.is_yminorgrid () && (minorgridstyle != "none"));
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1105 bool do_yminortick = props.is_yminortick ();
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1106 Matrix yticks = xform.yscale (props.get_ytick ().matrix_value ());
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1107 Matrix ymticks = xform.yscale (props.get_ymtick ().matrix_value ());
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1108 string_vector yticklabels = props.get_yticklabel ().all_strings ();
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1109 int wmax = 0, hmax = 0;
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1110 bool tick_along_z = nearhoriz || xisinf (fx);
12684
abfcb5d5641b Disable mirrored axes ticks for plottyy in ftlk
Konstantinos Poulios <logari81@googlemail.com>
parents: 12446
diff changeset
1111 bool mirror = props.is_box () && ystate != AXE_ANY_DIR
13216
434e227b100b Improvements to plotyy.
Ben Abbott <bpabbott@mac.com>
parents: 13141
diff changeset
1112 && (! props.has_property ("__plotyy_axes__"));
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1113
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1114 set_color (props.get_ycolor_rgb ());
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1115
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1116 // grid lines
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1117 if (do_ygrid)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1118 render_grid (gridstyle, yticks, y_min, y_max,
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1119 xPlane, xPlaneN, layer2Dtop ? zPlaneN : zPlane,
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1120 zPlaneN, 1, (zstate != AXE_DEPTH_DIR));
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1121
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1122 // tick marks
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1123 if (tick_along_z)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1124 render_tickmarks (yticks, y_min, y_max, xpTick, xpTick,
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1125 zpTick, zpTickN, 0., 0.,
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1126 signum (zpTick-zpTickN)*fz*yticklen,
12684
abfcb5d5641b Disable mirrored axes ticks for plottyy in ftlk
Konstantinos Poulios <logari81@googlemail.com>
parents: 12446
diff changeset
1127 1, mirror);
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1128 else
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1129 render_tickmarks (yticks, y_min, y_max, xpTick, xpTickN,
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1130 zpTick, zpTick,
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1131 signum (xPlaneN-xPlane)*fx*yticklen,
12684
abfcb5d5641b Disable mirrored axes ticks for plottyy in ftlk
Konstantinos Poulios <logari81@googlemail.com>
parents: 12446
diff changeset
1132 0., 0., 1, mirror);
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1133
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1134 // tick texts
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1135 if (yticklabels.numel () > 0)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1136 {
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1137 int halign = (ystate == AXE_HORZ_DIR
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1138 ? 1 : (!xyzSym || y2Dright ? 0 : 2));
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1139 int valign = (ystate == AXE_VERT_DIR ? 1 : 2);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1140
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1141 if (tick_along_z)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1142 render_ticktexts (yticks, yticklabels, y_min, y_max, xpTick,
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1143 zpTick+signum (zpTick-zpTickN)*fz*ytickoffset,
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1144 1, halign, valign, wmax, hmax);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1145 else
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1146 render_ticktexts (yticks, yticklabels, y_min, y_max,
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1147 xpTick+signum (xpTick-xpTickN)*fx*ytickoffset,
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1148 zpTick, 1, halign, valign, wmax, hmax);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1149 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1150
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1151 // minor grid lines
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1152 if (do_yminorgrid)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1153 render_grid (minorgridstyle, ymticks, y_min, y_max,
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1154 xPlane, xPlaneN, layer2Dtop ? zPlaneN : zPlane,
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1155 zPlaneN, 1, (zstate != AXE_DEPTH_DIR));
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1156
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1157 // minor tick marks
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1158 if (do_yminortick)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1159 {
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1160 if (tick_along_z)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1161 render_tickmarks (ymticks, y_min, y_max, xpTick, xpTick,
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1162 zpTick, zpTickN, 0., 0.,
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1163 signum (zpTick-zpTickN)*fz*yticklen/2,
12684
abfcb5d5641b Disable mirrored axes ticks for plottyy in ftlk
Konstantinos Poulios <logari81@googlemail.com>
parents: 12446
diff changeset
1164 1, mirror);
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1165 else
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1166 render_tickmarks (ymticks, y_min, y_max, xpTick, xpTickN,
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1167 zpTick, zpTick,
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1168 signum (xpTick-xpTickN)*fx*yticklen/2,
12684
abfcb5d5641b Disable mirrored axes ticks for plottyy in ftlk
Konstantinos Poulios <logari81@googlemail.com>
parents: 12446
diff changeset
1169 0., 0., 1, mirror);
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1170 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1171
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12333
diff changeset
1172 gh_manager::get_object (props.get_ylabel ()).set ("visible", "on");
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1173 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1174 else
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1175 gh_manager::get_object (props.get_ylabel ()).set ("visible", "off");
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1176 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1177
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1178 void
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1179 opengl_renderer::draw_axes_z_grid (const axes::properties& props)
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1180 {
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1181 int zstate = props.get_zstate ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1182 bool xySym = props.get_xySym ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1183 bool zSign = props.get_zSign ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1184 double zticklen = props.get_zticklen ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1185 double ztickoffset = props.get_ztickoffset ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1186 double fx = props.get_fx ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1187 double fy = props.get_fy ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1188 double xPlane = props.get_xPlane ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1189 double xPlaneN = props.get_xPlaneN ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1190 double yPlane = props.get_yPlane ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1191 double yPlaneN = props.get_yPlaneN ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1192 double z_min = props.get_z_min ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1193 double z_max = props.get_z_max ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1194
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1195 // Z Grid
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1196
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1197 if (zstate != AXE_DEPTH_DIR && props.is_visible ())
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1198 {
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1199 std::string gridstyle = props.get_gridlinestyle ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1200 std::string minorgridstyle = props.get_minorgridlinestyle ();
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1201 bool do_zgrid = (props.is_zgrid () && (gridstyle != "none"));
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1202 bool do_zminorgrid = (props.is_zminorgrid () && (minorgridstyle != "none"));
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1203 bool do_zminortick = props.is_zminortick ();
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1204 Matrix zticks = xform.zscale (props.get_ztick ().matrix_value ());
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1205 Matrix zmticks = xform.zscale (props.get_zmtick ().matrix_value ());
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1206 string_vector zticklabels = props.get_zticklabel ().all_strings ();
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1207 int wmax = 0, hmax = 0;
12684
abfcb5d5641b Disable mirrored axes ticks for plottyy in ftlk
Konstantinos Poulios <logari81@googlemail.com>
parents: 12446
diff changeset
1208 bool mirror = props.is_box () && zstate != AXE_ANY_DIR;
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1209
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1210 set_color (props.get_zcolor_rgb ());
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1211
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1212 // grid lines
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1213 if (do_zgrid)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1214 render_grid (gridstyle, zticks, z_min, z_max,
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1215 xPlane, xPlaneN, yPlane, yPlaneN, 2, true);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1216
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1217 // tick marks
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1218 if (xySym)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1219 {
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1220 if (xisinf (fy))
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1221 render_tickmarks (zticks, z_min, z_max, xPlaneN, xPlane,
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1222 yPlane, yPlane,
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1223 signum (xPlaneN-xPlane)*fx*zticklen,
12684
abfcb5d5641b Disable mirrored axes ticks for plottyy in ftlk
Konstantinos Poulios <logari81@googlemail.com>
parents: 12446
diff changeset
1224 0., 0., 2, mirror);
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1225 else
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1226 render_tickmarks (zticks, z_min, z_max, xPlaneN, xPlaneN,
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1227 yPlane, yPlane, 0.,
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1228 signum (yPlane-yPlaneN)*fy*zticklen,
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1229 0., 2, false);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1230 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1231 else
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1232 {
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1233 if (xisinf (fx))
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1234 render_tickmarks (zticks, z_min, z_max, xPlaneN, xPlane,
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1235 yPlaneN, yPlane, 0.,
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1236 signum (yPlaneN-yPlane)*fy*zticklen,
12684
abfcb5d5641b Disable mirrored axes ticks for plottyy in ftlk
Konstantinos Poulios <logari81@googlemail.com>
parents: 12446
diff changeset
1237 0., 2, mirror);
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1238 else
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1239 render_tickmarks (zticks, z_min, z_max, xPlane, xPlane,
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1240 yPlaneN, yPlane,
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1241 signum (xPlane-xPlaneN)*fx*zticklen,
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1242 0., 0., 2, false);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1243 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1244
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1245 // FIXME: tick texts
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1246 if (zticklabels.numel () > 0)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1247 {
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1248 int halign = 2;
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1249 int valign = (zstate == AXE_VERT_DIR ? 1 : (zSign ? 3 : 2));
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1250
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1251 if (xySym)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1252 {
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1253 if (xisinf (fy))
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1254 render_ticktexts (zticks, zticklabels, z_min, z_max,
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1255 xPlaneN+signum (xPlaneN-xPlane)*fx*ztickoffset,
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1256 yPlane, 2, halign, valign, wmax, hmax);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1257 else
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1258 render_ticktexts (zticks, zticklabels, z_min, z_max, xPlaneN,
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1259 yPlane+signum (yPlane-yPlaneN)*fy*ztickoffset,
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1260 2, halign, valign, wmax, hmax);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1261 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1262 else
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1263 {
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1264 if (xisinf (fx))
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1265 render_ticktexts (zticks, zticklabels, z_min, z_max, xPlane,
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1266 yPlaneN+signum (yPlaneN-yPlane)*fy*ztickoffset,
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1267 2, halign, valign, wmax, hmax);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1268 else
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1269 render_ticktexts (zticks, zticklabels, z_min, z_max,
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1270 xPlane+signum (xPlane-xPlaneN)*fx*ztickoffset,
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1271 yPlaneN, 2, halign, valign, wmax, hmax);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1272 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1273 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1274
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1275 // minor grid lines
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1276 if (do_zminorgrid)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1277 render_grid (minorgridstyle, zmticks, z_min, z_max,
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1278 xPlane, xPlaneN, yPlane, yPlaneN, 2, true);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1279
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1280 // minor tick marks
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1281 if (do_zminortick)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1282 {
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1283 if (xySym)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1284 {
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1285 if (xisinf (fy))
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1286 render_tickmarks (zmticks, z_min, z_max, xPlaneN, xPlane,
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1287 yPlane, yPlane,
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1288 signum (xPlaneN-xPlane)*fx*zticklen/2,
12684
abfcb5d5641b Disable mirrored axes ticks for plottyy in ftlk
Konstantinos Poulios <logari81@googlemail.com>
parents: 12446
diff changeset
1289 0., 0., 2, mirror);
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1290 else
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1291 render_tickmarks (zmticks, z_min, z_max, xPlaneN, xPlaneN,
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1292 yPlane, yPlane, 0.,
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1293 signum (yPlane-yPlaneN)*fy*zticklen/2,
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1294 0., 2, false);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1295 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1296 else
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1297 {
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1298 if (xisinf (fx))
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1299 render_tickmarks (zmticks, z_min, z_max, xPlane, xPlane,
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1300 yPlaneN, yPlane, 0.,
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1301 signum (yPlaneN-yPlane)*fy*zticklen/2,
12684
abfcb5d5641b Disable mirrored axes ticks for plottyy in ftlk
Konstantinos Poulios <logari81@googlemail.com>
parents: 12446
diff changeset
1302 0., 2, mirror);
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1303 else
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1304 render_tickmarks (zmticks, z_min, z_max, xPlane, xPlane,
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1305 yPlaneN, yPlaneN,
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1306 signum (xPlane-xPlaneN)*fx*zticklen/2,
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1307 0., 0., 2, false);
13141
e81ddf9cacd5 maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 12965
diff changeset
1308 }
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1309 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1310
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12333
diff changeset
1311 gh_manager::get_object (props.get_zlabel ()).set ("visible", "on");
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1312 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1313 else
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1314 gh_manager::get_object (props.get_zlabel ()).set ("visible", "off");
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1315 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1316
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1317 void
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1318 opengl_renderer::draw_axes_children (const axes::properties& props)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1319 {
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1320 // Children
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1322 GLboolean antialias;
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1323 glGetBooleanv (GL_LINE_SMOOTH, &antialias);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1324
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1325 if (antialias == GL_TRUE)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1326 glEnable (GL_LINE_SMOOTH);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1327
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1328 Matrix children = props.get_all_children ();
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1329 std::list<graphics_object> obj_list;
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1330 std::list<graphics_object>::iterator it;
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1331
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1332 // 1st pass: draw light objects
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1333
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1334 // Start with the last element of the array of child objects to
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1335 // display them in the oder they were added to the array.
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1336
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1337 for (octave_idx_type i = children.numel () - 1; i >= 0; i--)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1338 {
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1339 graphics_object go = gh_manager::get_object (children (i));
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1340
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1341 if (go.get_properties ().is_visible ())
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1342 {
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1343 if (go.isa ("light"))
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1344 draw (go);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1345 else
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1346 obj_list.push_back (go);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1347 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1348 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1349
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1350 // 2nd pass: draw other objects (with units set to "data")
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1351
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1352 it = obj_list.begin ();
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1353 while (it != obj_list.end ())
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1354 {
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1355 graphics_object go = (*it);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1356
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1357 // FIXME: check whether object has "units" property and it is set
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1358 // to "data"
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1359 if (! go.isa ("text") || go.get ("units").string_value () == "data")
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1360 {
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1361 set_clipping (go.get_properties ().is_clipping ());
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1362 draw (go);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1363
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1364 it = obj_list.erase (it);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1365 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1366 else
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1367 it++;
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1368 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1369
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1370 // 3rd pass: draw remaining objects
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1371
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1372 glDisable (GL_DEPTH_TEST);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1373
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1374 for (it = obj_list.begin (); it != obj_list.end (); it++)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1375 {
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1376 graphics_object go = (*it);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1377
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1378 set_clipping (go.get_properties ().is_clipping ());
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1379 draw (go);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1380 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1381
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1382 glEnable (GL_DEPTH_TEST);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1383
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1384 set_clipping (false);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1385
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1386 // FIXME: finalize rendering (transparency processing)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1387 // FIXME: draw zoom box, if needed
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1388 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1389
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1390 void
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1391 opengl_renderer::draw_axes (const axes::properties& props)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1392 {
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12333
diff changeset
1393 double x_min = props.get_x_min ();
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12333
diff changeset
1394 double x_max = props.get_x_max ();
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12333
diff changeset
1395 double y_min = props.get_y_min ();
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12333
diff changeset
1396 double y_max = props.get_y_max ();
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12333
diff changeset
1397 double z_min = props.get_z_min ();
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12333
diff changeset
1398 double z_max = props.get_z_max ();
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12333
diff changeset
1399
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1400 setup_opengl_transformation (props);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1401
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1402 // draw axes object
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1403
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1404 draw_axes_planes (props);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1405 draw_axes_boxes (props);
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1406
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
1407 set_font (props);
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
1408
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1409 draw_axes_x_grid (props);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1410 draw_axes_y_grid (props);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1411 draw_axes_z_grid (props);
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1412
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1413 set_linestyle ("-");
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1414
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12333
diff changeset
1415 set_clipbox (x_min, x_max, y_min, y_max, z_min, z_max);
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1416
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1417 draw_axes_children (props);
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1418 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1419
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1420 void
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9687
diff changeset
1421 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
1422 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1423 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
1424 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
1425 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
1426
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1427 bool has_z = (z.numel () > 0);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1428 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
1429 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
1430
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1431 std::vector<octave_uint8> clip (n);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1432
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1433 if (has_z)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1434 for (int i = 0; i < n; i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1435 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
1436 else
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1437 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1438 double z_mid = (zmin+zmax)/2;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1439
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1440 for (int i = 0; i < n; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1441 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
1442 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1443
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1444 if (! props.linestyle_is ("none"))
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1445 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1446 set_color (props.get_color_rgb ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1447 set_linestyle (props.get_linestyle (), false);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1448 set_linewidth (props.get_linewidth ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1449
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1450 if (has_z)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1451 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1452 bool flag = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1453
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1454 for (int i = 1; i < n; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1455 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1456 if ((clip[i-1] & clip[i]) == clip_ok)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1457 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1458 if (! flag)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1459 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1460 flag = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1461 glBegin (GL_LINE_STRIP);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1462 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
1463 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1464 glVertex3d (x(i), y(i), z(i));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1465 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1466 else if (flag)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1467 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1468 flag = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1469 glEnd ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1470 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1471 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1472
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1473 if (flag)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1474 glEnd ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1475 }
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1476 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1477 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1478 bool flag = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1479
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1480 for (int i = 1; i < n; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1481 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1482 if ((clip[i-1] & clip[i]) == clip_ok)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1483 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1484 if (! flag)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1485 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1486 flag = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1487 glBegin (GL_LINE_STRIP);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1488 glVertex2d (x(i-1), y(i-1));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1489 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1490 glVertex2d (x(i), y(i));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1491 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1492 else if (flag)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1493 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1494 flag = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1495 glEnd ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1496 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1497 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1498
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1499 if (flag)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1500 glEnd ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1501 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1502
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1503 set_linewidth (0.5);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1504 set_linestyle ("-");
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1505 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1506
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1507 set_clipping (false);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1508
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1509 if (! props.marker_is ("none") &&
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1510 ! (props.markeredgecolor_is ("none")
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1511 && props.markerfacecolor_is ("none")))
7825
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 Matrix lc, fc;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1514
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1515 if (props.markeredgecolor_is ("auto"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1516 lc = props.get_color_rgb ();
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1517 else if (! props.markeredgecolor_is ("none"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1518 lc = props.get_markeredgecolor_rgb ();
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1519
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1520 if (props.markerfacecolor_is ("auto"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1521 fc = props.get_color_rgb ();
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1522 else if (! props.markerfacecolor_is ("none"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1523 fc = props.get_markerfacecolor_rgb ();
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1524
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1525 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
1526 props.get_linewidth ());
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 for (int i = 0; i < n; i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1529 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1530 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
1531 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
1532 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
1533 lc, fc);
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1534 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1535
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1536 end_marker ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1537 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1538
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1539 set_clipping (props.is_clipping ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1540 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1541
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1542 void
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9687
diff changeset
1543 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
1544 {
9681
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
1545 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
1546 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
1547 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
1548
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1549 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
1550
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1551 NDArray c;
9681
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
1552 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
1553
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1554 // FIXME: handle transparency
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1555 Matrix a;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1556
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1557 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
1558 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
1559
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1560 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
1561 (props.facecolor_is ("flat") ? 1 :
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1562 (props.facecolor_is ("interp") ? 2 :
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1563 (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
1564 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
1565 (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
1566 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
1567 (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
1568 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
1569 (props.edgecolor_is ("flat") ? 1 :
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1570 (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
1571 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
1572 (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
1573 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
1574 (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
1575
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1576 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
1577 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
1578
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1579 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
1580 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
1581 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
1582 float se = props.get_specularexponent ();
8674
0d263850d582 Fix calculation of diffuse reflectance. Calculate surface normals here now.
Kai Habel
parents: 8377
diff changeset
1583 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
1584 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
1585
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
1586 opengl_texture tex;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
1587
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1588 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
1589 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
1590 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
1591
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1592 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
1593
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
1594 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
1595
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1596 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
1597 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1598 if (x_mat)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1599 i1 = i;
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1600
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
1601 for (int j = 0; j < zc; j++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1602 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1603 if (y_mat)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1604 j1 = j;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1605
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1606 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
1607 }
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1608 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1609
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1610 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
1611 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
1612
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1613 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
1614 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1615 // FIXME: implement alphadata conversion
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1616 //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
1617 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1618
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1619 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
1620 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1621 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
1622
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1623 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
1624 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
1625 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1626
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
1627 // 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
1628 // 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
1629 if (fc_mode == 3)
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
1630 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
1631
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1632 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
1633 {
7846
d7737a4268b7 Fix typos in property names (edgealpha/facealpha).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7838
diff changeset
1634 if (props.get_facealpha_double () == 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1635 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1636 if (fc_mode == 0 || fc_mode == 3)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1637 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1638 glColor3dv (fcolor.data ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1639 if (fl_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1640 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1641 for (int i = 0; i < 3; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1642 cb[i] = as * fcolor(i);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1643 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1644
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1645 for (int i = 0; i < 3; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1646 cb[i] = ds * fcolor(i);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1647 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1648 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1649 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1650
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1651 if (fl_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1652 glEnable (GL_LIGHTING);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1653 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
1654 set_polygon_offset (true, 1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1655 if (fc_mode == 3)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1656 glEnable (GL_TEXTURE_2D);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1657
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1658 for (int i = 1; i < zc; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1659 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1660 if (y_mat)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1661 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1662 i1 = i-1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1663 i2 = i;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1664 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1665
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1666 for (int j = 1; j < zr; j++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1667 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1668 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
1669 || clip (j-1, i) || clip (j, i))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1670 continue;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1671
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1672 if (x_mat)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1673 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1674 j1 = j-1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1675 j2 = j;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1676 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1677
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1678 glBegin (GL_QUADS);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1679
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1680 // Vertex 1
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1681 if (fc_mode == 3)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1682 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
1683 else if (fc_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1684 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1685 // 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
1686 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1687 cb[k] = c(j-1, i-1, k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1688 glColor3fv (cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1689
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1690 if (fl_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1691 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1692 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1693 cb[k] *= as;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1694 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1695
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1696 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1697 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
1698 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1699 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1700 }
8674
0d263850d582 Fix calculation of diffuse reflectance. Calculate surface normals here now.
Kai Habel
parents: 8377
diff changeset
1701 if (fl_mode > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1702 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1703 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
1704 + 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
1705 + 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
1706 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
1707 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1708 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
1709
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1710 // Vertex 2
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1711 if (fc_mode == 3)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1712 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
1713 else if (fc_mode == 2)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1714 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1715 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1716 cb[k] = c(j-1, i, k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1717 glColor3fv (cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1718
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1719 if (fl_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1720 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1721 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1722 cb[k] *= as;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1723 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1724
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1725 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1726 cb[k] = ds * c(j-1, i, k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1727 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1728 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1729 }
8674
0d263850d582 Fix calculation of diffuse reflectance. Calculate surface normals here now.
Kai Habel
parents: 8377
diff changeset
1730
0d263850d582 Fix calculation of diffuse reflectance. Calculate surface normals here now.
Kai Habel
parents: 8377
diff changeset
1731 if (fl_mode == 2)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1732 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1733 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
1734 + 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
1735 + 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
1736 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
1737 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1738
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1739 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
1740
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1741 // Vertex 3
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1742 if (fc_mode == 3)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1743 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
1744 else if (fc_mode == 2)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1745 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1746 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1747 cb[k] = c(j, i, k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1748 glColor3fv (cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1749
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1750 if (fl_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1751 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1752 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1753 cb[k] *= as;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1754 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1755
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1756 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1757 cb[k] = ds * c(j, i, k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1758 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1759 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1760 }
8674
0d263850d582 Fix calculation of diffuse reflectance. Calculate surface normals here now.
Kai Habel
parents: 8377
diff changeset
1761 if (fl_mode == 2)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1762 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1763 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
1764 + n(j,i,1) * n(j,i,1)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1765 + n(j,i,2) * n(j,i,2));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1766 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
1767 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1768 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
1769
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1770 // Vertex 4
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1771 if (fc_mode == 3)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1772 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
1773 else if (fc_mode == 2)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1774 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1775 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1776 cb[k] = c(j, i-1, k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1777 glColor3fv (cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1778
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1779 if (fl_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1780 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1781 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1782 cb[k] *= as;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1783 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1784
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1785 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1786 cb[k] = ds * c(j, i-1, k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1787 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1788 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1789 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1790 if (fl_mode == 2)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1791 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1792 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
1793 + 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
1794 + 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
1795 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
1796 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1797 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
1798
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1799 glEnd ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1800 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1801 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1802
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1803 set_polygon_offset (false);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1804 if (fc_mode == 3)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1805 glDisable (GL_TEXTURE_2D);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1806
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1807 if (fl_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1808 glDisable (GL_LIGHTING);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1809 }
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1810 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1811 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1812 // FIXME: implement transparency
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1813 }
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1814 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1815
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1816 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
1817 {
7846
d7737a4268b7 Fix typos in property names (edgealpha/facealpha).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7838
diff changeset
1818 if (props.get_edgealpha_double () == 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1819 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1820 if (ec_mode == 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1821 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1822 glColor3dv (ecolor.data ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1823 if (fl_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1824 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1825 for (int i = 0; i < 3; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1826 cb[i] = as * ecolor(i);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1827 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1828
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1829 for (int i = 0; i < 3; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1830 cb[i] = ds * ecolor(i);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1831 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1832 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1833 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1834
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1835 if (el_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1836 glEnable (GL_LIGHTING);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1837 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
1838
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1839 set_linestyle (props.get_linestyle (), false);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1840 set_linewidth (props.get_linewidth ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1841
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1842 // Mesh along Y-axis
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1843
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1844 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
1845 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1846 for (int i = 0; i < zc; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1847 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1848 if (y_mat)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1849 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1850 i1 = i-1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1851 i2 = i;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1852 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1853
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1854 for (int j = 1; j < zr; j++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1855 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1856 if (clip(j-1,i) || clip(j,i))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1857 continue;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1858
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1859 if (x_mat)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1860 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1861 j1 = j-1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1862 j2 = j;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1863 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1864
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1865 glBegin (GL_LINES);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1866
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1867 // Vertex 1
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1868 if (ec_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1869 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1870 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1871 cb[k] = c(j-1, i, k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1872 glColor3fv (cb);
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 if (fl_mode > 0)
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 k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1877 cb[k] *= as;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1878 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
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 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1881 cb[k] = ds * c(j-1, i, k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1882 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1883 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1884 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1885 if (el_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1886 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1887 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
1888 + 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
1889 + 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
1890 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
1891 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1892 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
1893
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1894 // Vertex 2
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1895 if (ec_mode == 2)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1896 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1897 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1898 cb[k] = c(j, i, k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1899 glColor3fv (cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1900
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1901 if (fl_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1902 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1903 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1904 cb[k] *= as;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1905 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1906
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1907 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1908 cb[k] = ds * c(j, i, k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1909 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1910 }
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 if (el_mode == 2)
8674
0d263850d582 Fix calculation of diffuse reflectance. Calculate surface normals here now.
Kai Habel
parents: 8377
diff changeset
1913 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1914 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
1915 + n(j,i,1) * n(j,i,1)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1916 + n(j,i,2) * n(j,i,2));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1917 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
1918 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1919 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
1920
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1921 glEnd ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1922 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1923 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1924 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1925
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1926 // Mesh along X-axis
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1927
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1928 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
1929 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1930 for (int j = 0; j < zr; j++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1931 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1932 if (x_mat)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1933 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1934 j1 = j-1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1935 j2 = j;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1936 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1937
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1938 for (int i = 1; i < zc; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1939 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1940 if (clip(j,i-1) || clip(j,i))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1941 continue;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1942
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1943 if (y_mat)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1944 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1945 i1 = i-1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1946 i2 = i;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1947 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1948
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1949 glBegin (GL_LINES);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1950
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1951 // Vertex 1
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1952 if (ec_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1953 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1954 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1955 cb[k] = c(j, i-1, k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1956 glColor3fv (cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1957
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1958 if (fl_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1959 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1960 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1961 cb[k] *= as;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1962 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1963
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1964 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1965 cb[k] = ds * c(j, i-1, k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1966 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1967 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1968 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1969 if (el_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1970 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1971 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
1972 + 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
1973 + 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
1974 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
1975 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1976 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
1977
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1978 // Vertex 2
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1979 if (ec_mode == 2)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1980 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1981 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1982 cb[k] = c(j, i, k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1983 glColor3fv (cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1984
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1985 if (fl_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1986 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1987 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1988 cb[k] *= as;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1989 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1990
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1991 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1992 cb[k] = ds * c(j, i, k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1993 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1994 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1995 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1996 if (el_mode == 2)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1997 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1998 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
1999 + n(j,i,1) * n(j,i,1)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2000 + n(j,i,2) * n(j,i,2));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2001 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
2002 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2003 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
2004
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2005 glEnd ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2006 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2007 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2008 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2009
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2010 set_linestyle ("-");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2011 set_linewidth (0.5);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2012
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2013 if (el_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2014 glDisable (GL_LIGHTING);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2015 }
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2016 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2017 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2018 // FIXME: implement transparency
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2019 }
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2020 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2021
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2022 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
2023 ! (props.markeredgecolor_is ("none")
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2024 && 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
2025 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2026 // 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
2027 // 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
2028 // 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
2029
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2030 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
2031 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
2032
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2033 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
2034 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
2035 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
2036
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2037 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
2038 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2039 mecolor = props.get_edgecolor_rgb ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2040 do_edge = ! props.edgecolor_is ("none");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2041 }
7829
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 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
2044 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2045 mfcolor = props.get_facecolor_rgb ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2046 do_face = ! props.facecolor_is ("none");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2047 }
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2048
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2049 if ((mecolor.numel () == 0 || mfcolor.numel () == 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2050 && c.numel () == 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2051 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
2052
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2053 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
2054 props.get_linewidth ());
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2055
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2056 for (int i = 0; i < zc; i++)
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 (y_mat)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2059 i1 = i;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2060
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2061 for (int j = 0; j < zr; j++)
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 if (clip(j,i))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2064 continue;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2065
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2066 if (x_mat)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2067 j1 = j;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2068
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2069 if ((do_edge && mecolor.numel () == 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2070 || (do_face && mfcolor.numel () == 0))
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 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2073 cc(k) = c(j,i,k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2074 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2075
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2076 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
2077 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
2078
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2079 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
2080 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2081 }
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2082
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2083 end_marker ();
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2084 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2085 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2086
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
2087 // 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
2088 // 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
2089 void
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9687
diff changeset
2090 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
2091 {
9681
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
2092 const Matrix f = props.get_faces ().matrix_value ();
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
2093 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
2094 Matrix c;
9681
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
2095 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
2096 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
2097
7870
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
2098 int nv = v.rows ();
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
2099 // int vmax = v.columns ();
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
2100 int nf = f.rows ();
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
2101 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
2102
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2103 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
2104 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
2105 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
2106
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
2107 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
2108 || props.facecolor_is_rgb ()) ? 0 :
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
2109 (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
2110 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
2111 (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
2112 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
2113 (props.facealpha_is ("flat") ? 1 : 2));
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
2114 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
2115 || props.edgecolor_is_rgb ()) ? 0 :
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
2116 (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
2117 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
2118 (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
2119 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
2120 (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
2121
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2122 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
2123 Matrix ecolor = props.get_edgecolor_rgb ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2124
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
2125 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
2126 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
2127 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
2128 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
2129
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2130 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
2131
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2132 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
2133 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
2134 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
2135 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
2136 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
2137 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
2138
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2139 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
2140 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
2141
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2142 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
2143 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2144 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
2145 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
2146
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2147 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
2148 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
2149
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2150 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
2151 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
2152 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2153
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2154 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
2155 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2156 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
2157
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2158 if (c.rows () == 1)
10315
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 // 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
2161
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2162 if (fc_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2163 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2164 fcolor = c;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2165 fc_mode = 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2166 }
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 if (ec_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2169 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2170 ecolor = c;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2171 ec_mode = 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2172 }
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 c = Matrix ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2175 }
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
2176 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2177 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
2178 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2179
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2180 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
2181 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2182 // 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
2183 //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
2184 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
2185 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2186
7924
4976f66d469b miscellaneous cleanup
John W. Eaton <jwe@octave.org>
parents: 7914
diff changeset
2187 octave_idx_type fr = f.rows ();
7914
e998e81224b5 Various compilation fixes for MSVC.
John W. Eaton <jwe@octave.org>
parents: 7907
diff changeset
2188 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
2189
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2190 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
2191 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
2192 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2193 int idx = int (f(i,j) - 1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2194
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2195 Matrix vv (1, 3, 0.0);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2196 Matrix cc;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2197 Matrix nn(1, 3, 0.0);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2198 double aa = 1.0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2199
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2200 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
2201 if (has_z)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2202 vv(2) = v(idx,2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2203 // FIXME: uncomment when patch object has normal computation
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2204 //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
2205 if (c.numel () > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2206 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2207 cc.resize (1, 3);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2208 if (has_facecolor)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2209 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
2210 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2211 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
2212 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2213 if (a.numel () > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2214 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2215 if (has_facealpha)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2216 aa = a(i);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2217 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2218 aa = a(idx);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2219 }
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 vdata[i+j*fr] =
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2222 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
2223 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2224
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2225 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
2226 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2227 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
2228
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2229 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
2230 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
2231 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2232
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2233 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
2234 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2235 // 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
2236 if (props.get_facealpha_double () == 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2237 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2238 if (fc_mode == 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2239 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2240 glColor3dv (fcolor.data ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2241 if (fl_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2242 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2243 float cb[4] = { 0, 0, 0, 1 };
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2244
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2245 for (int i = 0; i < 3; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2246 cb[i] = (as * fcolor(i));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2247 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2248
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2249 for (int i = 0; i < 3; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2250 cb[i] = ds * fcolor(i);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2251 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2252 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2253 }
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 if (fl_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2256 glEnable (GL_LIGHTING);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2257
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2258 // FIXME: use __index__ property from patch object
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2259 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
2260
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2261 for (int i = 0; i < nf; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2262 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2263 if (clip_f(i))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2264 continue;
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 tess.begin_polygon (true);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2267 tess.begin_contour ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2268
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2269 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
2270 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2271 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
2272
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2273 tess.add_vertex (vv->coords.fortran_vec (), vv);
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 tess.end_contour ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2277 tess.end_polygon ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2278 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2279
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2280 if (fl_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2281 glDisable (GL_LIGHTING);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2282 }
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
2283 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2284 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2285 // FIXME: implement transparency
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2286 }
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
2287 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2288
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2289 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
2290 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2291 // 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
2292 if (props.get_edgealpha_double () == 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2293 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2294 if (ec_mode == 0)
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 glColor3dv (ecolor.data ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2297 if (el_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2298 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2299 float cb[4] = { 0, 0, 0, 1 };
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2300
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2301 for (int i = 0; i < 3; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2302 cb[i] = (as * ecolor(i));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2303 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2304
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2305 for (int i = 0; i < 3; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2306 cb[i] = ds * ecolor(i);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2307 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
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 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2310
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2311 if (el_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2312 glEnable (GL_LIGHTING);
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 set_linestyle (props.get_linestyle (), false);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2315 set_linewidth (props.get_linewidth ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2316
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2317
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2318 // 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
2319 // offset patch contour as well?
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2320 patch_tesselator tess (this, ec_mode, el_mode);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2321
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2322 for (int i = 0; i < nf; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2323 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2324 if (clip_f(i))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2325 {
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2326 // 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
2327 bool flag = false;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2328
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2329 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
2330 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2331 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
2332 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2333 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
2334 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
2335 if (! flag)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2336 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2337 flag = true;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2338 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
2339 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2340 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
2341 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2342 else if (flag)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2343 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2344 flag = false;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2345 glEnd ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2346 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2347 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2348
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2349 if (flag)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2350 glEnd ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2351 }
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2352 else
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2353 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2354 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
2355 tess.begin_contour ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2356
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2357 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
2358 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2359 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
2360 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
2361 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2362
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2363 tess.end_contour ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2364 tess.end_polygon ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2365 }
10315
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
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2368 set_linestyle ("-");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2369 set_linewidth (0.5);
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 if (el_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2372 glDisable (GL_LIGHTING);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2373 }
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
2374 else
10315
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 // FIXME: implement transparency
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2377 }
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
2378 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2379
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2380 if (! 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
2381 ! (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
2382 {
7838
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2383 bool do_edge = ! props.markeredgecolor_is ("none");
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2384 bool do_face = ! props.markerfacecolor_is ("none");
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2385
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2386 Matrix mecolor = props.get_markeredgecolor_rgb ();
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2387 Matrix mfcolor = props.get_markerfacecolor_rgb ();
12446
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
2388
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
2389 bool has_markerfacecolor = false;
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
2390
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
2391 if ((mecolor.numel () == 0 && ! props.markeredgecolor_is ("none"))
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
2392 || (mfcolor.numel () == 0 && ! props.markerfacecolor_is ("none")))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2393 {
12446
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
2394 Matrix mc = props.get_color_data ().matrix_value ();
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
2395
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
2396 if (mc.rows () == 1)
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
2397 {
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
2398 // Single color specifications, we can simplify a little bit
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
2399
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
2400 if (mfcolor.numel () == 0
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
2401 && ! props.markerfacecolor_is ("none"))
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
2402 mfcolor = mc;
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
2403
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
2404 if (mecolor.numel () == 0
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
2405 && ! props.markeredgecolor_is ("none"))
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
2406 mecolor = mc;
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
2407 }
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
2408 else
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
2409 {
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
2410 if (c.numel () == 0)
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
2411 c = props.get_color_data ().matrix_value ();
13141
e81ddf9cacd5 maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 12965
diff changeset
2412 has_markerfacecolor = ((c.numel () > 0)
12446
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
2413 && (c.rows () == f.rows ()));
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
2414 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2415 }
7838
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2416
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2417
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2418 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
2419 props.get_linewidth ());
7838
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2420
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2421 for (int i = 0; i < nf; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2422 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
2423 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2424 int idx = int (f(i,j) - 1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2425
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2426 if (clip(idx))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2427 continue;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2428
12446
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
2429 Matrix cc;
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
2430 if (c.numel () > 0)
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
2431 {
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
2432 cc.resize (1, 3);
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
2433 if (has_markerfacecolor)
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
2434 cc(0) = c(i,0), cc(1) = c(i,1), cc(2) = c(i,2);
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
2435 else
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
2436 cc(0) = c(idx,0), cc(1) = c(idx,1), cc(2) = c(idx,2);
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
2437 }
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
2438
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
2439 Matrix lc = (do_edge ? (mecolor.numel () == 0 ? cc : mecolor)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2440 : Matrix ());
12446
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
2441 Matrix fc = (do_face ? (mfcolor.numel () == 0 ? cc : mfcolor)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2442 : Matrix ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2443
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2444 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
2445 }
7838
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2446
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
2447 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
2448 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2449 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2450
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2451 void
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9687
diff changeset
2452 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
2453 {
35e8d6199455 Add hggroup support in OpenGL renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7851
diff changeset
2454 draw (props.get_children ());
35e8d6199455 Add hggroup support in OpenGL renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7851
diff changeset
2455 }
35e8d6199455 Add hggroup support in OpenGL renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7851
diff changeset
2456
35e8d6199455 Add hggroup support in OpenGL renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7851
diff changeset
2457 void
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9687
diff changeset
2458 opengl_renderer::draw_text (const text::properties& props)
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
2459 {
12965
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12684
diff changeset
2460 if (props.get_string ().is_empty ())
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
2461 return;
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
2462
13961
0fea4cf22f88 restore legend text with OpenGL + FLTK graphics (bug #34907)
John W. Eaton <jwe@octave.org>
parents: 13758
diff changeset
2463 Matrix pos = xform.scale (props.get_data_position ());
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
2464 const Matrix bbox = props.get_extent_matrix ();
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
2465
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
2466 // FIXME: handle margin and surrounding box
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
2467 bool blend = glIsEnabled (GL_BLEND);
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
2468
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
2469 glEnable (GL_BLEND);
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
2470 glEnable (GL_ALPHA_TEST);
13961
0fea4cf22f88 restore legend text with OpenGL + FLTK graphics (bug #34907)
John W. Eaton <jwe@octave.org>
parents: 13758
diff changeset
2471 glRasterPos3d (pos(0), pos(1), pos.numel () > 2 ? pos(2) : 0.0);
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
2472 glBitmap (0, 0, 0, 0, bbox(0), bbox(1), 0);
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
2473 glDrawPixels (bbox(2), bbox(3),
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
2474 GL_RGBA, GL_UNSIGNED_BYTE, props.get_pixels ().data ());
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
2475 glDisable (GL_ALPHA_TEST);
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
2476 if (! blend)
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
2477 glDisable (GL_BLEND);
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
2478
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
2479 }
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
2480
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
2481 void
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9687
diff changeset
2482 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
2483 {
9884
fed4aad2cdca handle indexed images in opengl renderer
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
2484 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
2485 dim_vector dv (cdata.dims ());
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9616
diff changeset
2486 int h = dv(0), w = dv(1);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2487
11093
d748acc75658 gl-render.cc: Treat images with scalar unique(x/ydata) like Matlab.
Ben Abbott <bpabbott@mac.com>
parents: 11026
diff changeset
2488 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
2489 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
2490
15069
7a3957ca99c3 Handle complex arguments in imagesc (bug #36866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14861
diff changeset
2491 // Someone wants us to draw an empty image? No way.
7a3957ca99c3 Handle complex arguments in imagesc (bug #36866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14861
diff changeset
2492 if (x.is_empty () || y.is_empty ())
7a3957ca99c3 Handle complex arguments in imagesc (bug #36866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14861
diff changeset
2493 return;
7a3957ca99c3 Handle complex arguments in imagesc (bug #36866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14861
diff changeset
2494
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2495 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
2496 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
2497
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2498 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
2499 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
2500
9681
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
2501 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
2502 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
2503
9687
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2504 // image pixel size in screen pixel units
9950
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
2505 float pix_dx, pix_dy;
9687
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2506 // image pixel size in normalized units
9950
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
2507 float nor_dx, nor_dy;
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
2508
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2509 if (w > 1)
9950
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
2510 {
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
2511 pix_dx = (p1(0) - p0(0))/(w-1);
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
2512 nor_dx = (x(1) - x(0))/(w-1);
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
2513 }
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
2514 else
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
2515 {
10076
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9950
diff changeset
2516 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
2517 pix_dx = p1w(0) - p0(0);
9950
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
2518 nor_dx = 1;
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
2519 }
10076
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9950
diff changeset
2520
9950
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
2521 if (h > 1)
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
2522 {
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
2523 pix_dy = (p1(1) - p0(1))/(h-1);
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
2524 nor_dy = (y(1) - y(0))/(h-1);
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
2525 }
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
2526 else
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
2527 {
10076
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9950
diff changeset
2528 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
2529 pix_dy = p1h(1) - p0(1);
9950
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
2530 nor_dy = 1;
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
2531 }
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
2532
9687
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2533
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2534 // 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
2535 // 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
2536 // ourselfes - only draw part of the image
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2537
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2538 int j0 = 0, j1 = w;
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2539 int i0 = 0, i1 = h;
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2540
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2541 float im_xmin = x(0) - nor_dx/2;
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2542 float im_xmax = x(1) + nor_dx/2;
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2543 float im_ymin = y(0) - nor_dy/2;
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2544 float im_ymax = y(1) + nor_dy/2;
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2545 if (props.is_clipping ()) // clip to axes
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2546 {
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2547 if (im_xmin < xmin)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2548 j0 += (xmin - im_xmin)/nor_dx + 1;
9687
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2549 if (im_xmax > xmax)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2550 j1 -= (im_xmax - xmax)/nor_dx ;
9687
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2551
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2552 if (im_ymin < ymin)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2553 i0 += (ymin - im_ymin)/nor_dy + 1;
9687
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2554 if (im_ymax > ymax)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2555 i1 -= (im_ymax - ymax)/nor_dy;
9687
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2556 }
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2557 else // clip to viewport
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2558 {
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2559 GLfloat vp[4];
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
2560 glGetFloatv (GL_VIEWPORT, vp);
9687
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2561 // 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
2562
9687
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2563 }
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2564
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2565 if (i0 >= i1 || j0 >= j1)
9687
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2566 return;
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2567
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2568 glPixelZoom (pix_dx, -pix_dy);
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2569 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
2570
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2571 // by default this is 4
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
2572 glPixelStorei (GL_UNPACK_ALIGNMENT,1);
9680
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9616
diff changeset
2573
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9616
diff changeset
2574 // Expect RGB data
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9616
diff changeset
2575 if (dv.length () == 3 && dv(2) == 3)
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9616
diff changeset
2576 {
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9616
diff changeset
2577 if (cdata.is_double_type ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2578 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2579 const NDArray xcdata = cdata.array_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2580
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2581 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
2582
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2583 for (int i = i0; i < i1; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2584 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2585 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
2586 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2587 a[idx] = xcdata(i,j,0);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2588 a[idx+1] = xcdata(i,j,1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2589 a[idx+2] = xcdata(i,j,2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2590 }
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
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2593 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
2594
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2595 }
9680
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9616
diff changeset
2596 else if (cdata.is_uint16_type ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2597 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2598 const uint16NDArray xcdata = cdata.uint16_array_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2599
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2600 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
2601
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2602 for (int i = i0; i < i1; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2603 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2604 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
2605 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2606 a[idx] = xcdata(i,j,0);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2607 a[idx+1] = xcdata(i,j,1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2608 a[idx+2] = xcdata(i,j,2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2609 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2610 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2611
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2612 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
2613
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2614 }
9680
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9616
diff changeset
2615 else if (cdata.is_uint8_type ())
10315
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 const uint8NDArray xcdata = cdata.uint8_array_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2618
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2619 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
2620
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2621 for (int i = i0; i < i1; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2622 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2623 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
2624 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2625 a[idx] = xcdata(i,j,0);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2626 a[idx+1] = xcdata(i,j,1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2627 a[idx+2] = xcdata(i,j,2);
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 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2630
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2631 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
2632 }
9680
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9616
diff changeset
2633 else
13219
cf5ebc0e47e4 fix warnings for unused but set variables and shadowed variables
John W. Eaton <jwe@octave.org>
parents: 13216
diff changeset
2634 warning ("opengl_texture::draw: invalid image data type (expected double, uint16, or uint8)");
9680
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9616
diff changeset
2635 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2636 else
13219
cf5ebc0e47e4 fix warnings for unused but set variables and shadowed variables
John W. Eaton <jwe@octave.org>
parents: 13216
diff changeset
2637 warning ("opengl_texture::draw: invalid image size (expected n*m*3 or n*m)");
cf5ebc0e47e4 fix warnings for unused but set variables and shadowed variables
John W. Eaton <jwe@octave.org>
parents: 13216
diff changeset
2638
9680
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9616
diff changeset
2639 glPixelZoom (1, 1);
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9616
diff changeset
2640 }
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9616
diff changeset
2641
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9616
diff changeset
2642 void
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2643 opengl_renderer::set_viewport (int w, int h)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2644 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2645 glViewport (0, 0, w, h);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2646 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2647
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2648 void
9950
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
2649 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
2650 GLenum type, const GLvoid *data)
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
2651 {
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
2652 glDrawPixels (width, height, format, type, data);
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
2653 }
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
2654
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
2655 void
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2656 opengl_renderer::set_color (const Matrix& c)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2657 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2658 glColor3dv (c.data ());
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
2659 #if HAVE_FREETYPE
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
2660 text_renderer.set_color (c);
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
2661 #endif
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
2662 }
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
2663
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
2664 void
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
2665 opengl_renderer::set_font (const base_properties& props)
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
2666 {
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
2667 #if HAVE_FREETYPE
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
2668 text_renderer.set_font (props.get ("fontname").string_value (),
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
2669 props.get ("fontweight").string_value (),
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
2670 props.get ("fontangle").string_value (),
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
2671 props.get ("fontsize").double_value ());
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
2672 #endif
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2673 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2674
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2675 void
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2676 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
2677 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2678 if (on)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2679 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2680 glPolygonOffset (offset, offset);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2681 glEnable (GL_POLYGON_OFFSET_FILL);
7906
b3becd212f3f Draw markers above lines
John W. Eaton <jwe@octave.org>
parents: 7904
diff changeset
2682 glEnable (GL_POLYGON_OFFSET_LINE);
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2683 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2684 else
7906
b3becd212f3f Draw markers above lines
John W. Eaton <jwe@octave.org>
parents: 7904
diff changeset
2685 {
b3becd212f3f Draw markers above lines
John W. Eaton <jwe@octave.org>
parents: 7904
diff changeset
2686 glDisable (GL_POLYGON_OFFSET_FILL);
b3becd212f3f Draw markers above lines
John W. Eaton <jwe@octave.org>
parents: 7904
diff changeset
2687 glDisable (GL_POLYGON_OFFSET_LINE);
b3becd212f3f Draw markers above lines
John W. Eaton <jwe@octave.org>
parents: 7904
diff changeset
2688 }
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2689 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2690
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2691 void
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2692 opengl_renderer::set_linewidth (float w)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2693 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2694 glLineWidth (w);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2695 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2696
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2697 void
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2698 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
2699 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2700 bool solid = false;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2701
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2702 if (s == "-")
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2703 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2704 glLineStipple (1, static_cast<unsigned short> (0xFFFF));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2705 solid = true;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2706 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2707 else if (s == ":")
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2708 glLineStipple (1, static_cast<unsigned short> (0x8888));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2709 else if (s == "--")
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2710 glLineStipple (1, static_cast<unsigned short> (0x0FFF));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2711 else if (s == "-.")
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2712 glLineStipple (1, static_cast<unsigned short> (0x020F));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2713 else
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2714 glLineStipple (1, static_cast<unsigned short> (0x0000));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2715
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2716 if (solid && ! use_stipple)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2717 glDisable (GL_LINE_STIPPLE);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2718 else
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2719 glEnable (GL_LINE_STIPPLE);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2720 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2721
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2722 void
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2723 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
2724 double z1, double z2)
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2725 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2726 double dx = (x2-x1);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2727 double dy = (y2-y1);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2728 double dz = (z2-z1);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2729
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2730 x1 -= 0.001*dx; x2 += 0.001*dx;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2731 y1 -= 0.001*dy; y2 += 0.001*dy;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2732 z1 -= 0.001*dz; z2 += 0.001*dz;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2733
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2734 ColumnVector p (4, 0.0);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2735
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2736 p(0) = -1; p(3) = x2;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2737 glClipPlane (GL_CLIP_PLANE0, p.data ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2738 p(0) = 1; p(3) = -x1;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2739 glClipPlane (GL_CLIP_PLANE1, p.data ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2740 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
2741 glClipPlane (GL_CLIP_PLANE2, p.data ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2742 p(1) = 1; p(3) = -y1;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2743 glClipPlane (GL_CLIP_PLANE3, p.data ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2744 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
2745 glClipPlane (GL_CLIP_PLANE4, p.data ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2746 p(2) = 1; p(3) = -z1;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2747 glClipPlane (GL_CLIP_PLANE5, p.data ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2748
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2749 xmin = x1; xmax = x2;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2750 ymin = y1; ymax = y2;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2751 zmin = z1; zmax = z2;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2752 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2753
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2754 void
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2755 opengl_renderer::set_clipping (bool enable)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2756 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2757 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
2758
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2759 if (enable != has_clipping)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2760 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2761 if (enable)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2762 for (int i = 0; i < 6; i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2763 glEnable (GL_CLIP_PLANE0+i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2764 else
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2765 for (int i = 0; i < 6; i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2766 glDisable (GL_CLIP_PLANE0+i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2767 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2768 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2769
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2770 void
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2771 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
2772 {
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
2773 #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
2774 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
2775 #else
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2776 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
2777 #endif
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2778
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2779 glGetIntegerv (GL_VIEWPORT, vw);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2780
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2781 glMatrixMode (GL_PROJECTION);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2782 glPushMatrix ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2783 glLoadIdentity ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2784 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
2785 glMatrixMode (GL_MODELVIEW);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2786 glPushMatrix ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2787
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2788 set_clipping (false);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2789 set_linewidth (width);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2790
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2791 marker_id = make_marker_list (m, size, false);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2792 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
2793 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2794
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2795 void
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2796 opengl_renderer::end_marker (void)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2797 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2798 glDeleteLists (marker_id, 1);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2799 glDeleteLists (filled_marker_id, 1);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2800
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2801 glMatrixMode (GL_MODELVIEW);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2802 glPopMatrix ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2803 glMatrixMode (GL_PROJECTION);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2804 glPopMatrix ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2805 set_linewidth (0.5f);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2806 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2807
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2808 void
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2809 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
2810 const Matrix& lc, const Matrix& fc)
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2811 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2812 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
2813
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2814 glLoadIdentity ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2815 glTranslated (tmp(0), tmp(1), -tmp(2));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2816
7907
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
2817 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
2818 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2819 glColor3dv (fc.data ());
7906
b3becd212f3f Draw markers above lines
John W. Eaton <jwe@octave.org>
parents: 7904
diff changeset
2820 set_polygon_offset (true, -1.0);
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2821 glCallList (filled_marker_id);
7906
b3becd212f3f Draw markers above lines
John W. Eaton <jwe@octave.org>
parents: 7904
diff changeset
2822 if (lc.numel () > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2823 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2824 glColor3dv (lc.data ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2825 glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2826 glEdgeFlag (GL_TRUE);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2827 set_polygon_offset (true, -2.0);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2828 glCallList (filled_marker_id);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2829 glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2830 }
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2831 set_polygon_offset (false);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2832 }
7907
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
2833 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
2834 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2835 glColor3dv (lc.data ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2836 glCallList (marker_id);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2837 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2838 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2839
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2840 unsigned int
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2841 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
2842 bool filled) const
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2843 {
7907
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
2844 char c = marker[0];
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
2845
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
2846 if (filled && (c == '+' || c == 'x' || c == '*' || c == '.'))
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
2847 return 0;
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
2848
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2849 unsigned int ID = glGenLists (1);
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
2850 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
2851
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2852 // constants for the * marker
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2853 const double sqrt2d4 = 0.35355339059327;
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2854 double tt = sz*sqrt2d4;
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2855
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2856 glNewList (ID, GL_COMPILE);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2857
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2858 switch (marker[0])
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2859 {
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2860 case '+':
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2861 glBegin (GL_LINES);
9681
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
2862 glVertex2f (-sz/2, 0);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
2863 glVertex2f (sz/2, 0);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
2864 glVertex2f (0, -sz/2);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
2865 glVertex2f (0, sz/2);
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2866 glEnd ();
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2867 break;
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2868 case 'x':
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
2869 glBegin (GL_LINES);
9681
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
2870 glVertex2f (-sz/2, -sz/2);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
2871 glVertex2f (sz/2, sz/2);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
2872 glVertex2f (-sz/2, sz/2);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
2873 glVertex2f (sz/2, -sz/2);
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2874 glEnd ();
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2875 break;
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2876 case '*':
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2877 glBegin (GL_LINES);
9681
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
2878 glVertex2f (-sz/2, 0);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
2879 glVertex2f (sz/2, 0);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
2880 glVertex2f (0, -sz/2);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
2881 glVertex2f (0, sz/2);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
2882 glVertex2f (-tt, -tt);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
2883 glVertex2f (+tt, +tt);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
2884 glVertex2f (-tt, +tt);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
2885 glVertex2f (+tt, -tt);
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2886 glEnd ();
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2887 break;
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2888 case '.':
10924
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
2889 {
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
2890 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
2891
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
2892 glBegin (GL_POLYGON);
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
2893 for (double ang = 0; ang < (2*M_PI); ang += ang_step)
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
2894 glVertex2d (sz*cos (ang)/3, sz*sin (ang)/3);
10924
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
2895 glEnd ();
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
2896 }
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2897 break;
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2898 case 's':
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2899 glBegin ((filled ? GL_POLYGON : GL_LINE_LOOP));
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2900 glVertex2d (-sz/2, -sz/2);
9681
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
2901 glVertex2d (-sz/2, sz/2);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
2902 glVertex2d (sz/2, sz/2);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
2903 glVertex2d (sz/2, -sz/2);
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14838
diff changeset
2904 glEnd ();
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2905 break;
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2906 case 'o':
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2907 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2908 double ang_step = M_PI / 5;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2909
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2910 glBegin ((filled ? GL_POLYGON : GL_LINE_LOOP));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2911 for (double ang = 0; ang < (2*M_PI); ang += ang_step)
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
2912 glVertex2d (sz*cos (ang)/2, sz*sin (ang)/2);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2913 glEnd ();
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2914 }
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2915 break;
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2916 case 'd':
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2917 glBegin ((filled ? GL_POLYGON : GL_LINE_LOOP));
9681
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
2918 glVertex2d (0, -sz/2);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
2919 glVertex2d (sz/2, 0);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
2920 glVertex2d (0, sz/2);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
2921 glVertex2d (-sz/2, 0);
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14838
diff changeset
2922 glEnd ();
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2923 break;
10835
4bbd6f75f173 gl-render.cc: Transpose markers '^' and 'v'.
Ben Abbott <bpabbott@mac.com>
parents: 10402
diff changeset
2924 case 'v':
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2925 glBegin ((filled ? GL_POLYGON : GL_LINE_LOOP));
9681
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
2926 glVertex2f (0, sz/2);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
2927 glVertex2f (sz/2, -sz/2);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
2928 glVertex2f (-sz/2, -sz/2);
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2929 glEnd ();
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2930 break;
10835
4bbd6f75f173 gl-render.cc: Transpose markers '^' and 'v'.
Ben Abbott <bpabbott@mac.com>
parents: 10402
diff changeset
2931 case '^':
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2932 glBegin ((filled ? GL_POLYGON : GL_LINE_LOOP));
9681
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
2933 glVertex2f (0, -sz/2);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
2934 glVertex2f (-sz/2, sz/2);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
2935 glVertex2f (sz/2, sz/2);
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2936 glEnd ();
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2937 break;
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2938 case '>':
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2939 glBegin ((filled ? GL_POLYGON : GL_LINE_LOOP));
9681
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
2940 glVertex2f (sz/2, 0);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
2941 glVertex2f (-sz/2, sz/2);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
2942 glVertex2f (-sz/2, -sz/2);
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2943 glEnd ();
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2944 break;
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2945 case '<':
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2946 glBegin ((filled ? GL_POLYGON : GL_LINE_LOOP));
9681
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
2947 glVertex2f (-sz/2, 0);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
2948 glVertex2f (sz/2, -sz/2);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
2949 glVertex2f (sz/2, sz/2);
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2950 glEnd ();
7906
b3becd212f3f Draw markers above lines
John W. Eaton <jwe@octave.org>
parents: 7904
diff changeset
2951 break;
10924
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
2952 case 'p':
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
2953 {
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
2954 double ang;
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
2955 double r;
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
2956 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
2957
10924
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
2958 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
2959 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
2960 {
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
2961 ang = (-0.5 + double(i+1)/5) * M_PI;
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
2962 r = 1.0 - (dr * fmod (double(i+1), 2.0));
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
2963 glVertex2d (sz*r*cos (ang)/2, sz*r*sin (ang)/2);
10924
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
2964 }
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
2965 glEnd ();
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
2966 }
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
2967 break;
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
2968 case 'h':
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
2969 {
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
2970 double ang;
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
2971 double r;
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
2972 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
2973
10924
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
2974 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
2975 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
2976 {
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
2977 ang = (0.5 + double(i+1)/6.0) * M_PI;
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
2978 r = 1.0 - (dr * fmod (double(i+1), 2.0));
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
2979 glVertex2d (sz*r*cos (ang)/2, sz*r*sin (ang)/2);
10924
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
2980 }
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
2981 glEnd ();
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
2982 }
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
2983 break;
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2984 default:
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2985 warning ("opengl_renderer: unsupported marker `%s'",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2986 marker.c_str ());
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
2987 break;
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2988 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2989
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2990 glEndList ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2991
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2992 return ID;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2993 }
7874
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7870
diff changeset
2994
9834
92d8f35ff217 compute bounding boxes for text in opengl graphics backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
2995 void
92d8f35ff217 compute bounding boxes for text in opengl graphics backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
2996 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
2997 uint8NDArray& pixels,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2998 Matrix& bbox,
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
2999 int halign, int valign, double rotation)
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3000 {
12333
f103b9c1ca05 use text_renderer object only when freetye is available
Kai Habel <kai.habel@gmx.de>
parents: 12327
diff changeset
3001 #if HAVE_FREETYPE
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
3002 text_renderer.text_to_pixels (txt, pixels, bbox,
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
3003 halign, valign, rotation);
12333
f103b9c1ca05 use text_renderer object only when freetye is available
Kai Habel <kai.habel@gmx.de>
parents: 12327
diff changeset
3004 #endif
9834
92d8f35ff217 compute bounding boxes for text in opengl graphics backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
3005 }
92d8f35ff217 compute bounding boxes for text in opengl graphics backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
3006
92d8f35ff217 compute bounding boxes for text in opengl graphics backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
3007 Matrix
92d8f35ff217 compute bounding boxes for text in opengl graphics backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
3008 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
3009 double x, double y, double z,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3010 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
3011 {
92d8f35ff217 compute bounding boxes for text in opengl graphics backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
3012 #if HAVE_FREETYPE
92d8f35ff217 compute bounding boxes for text in opengl graphics backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
3013 if (txt.empty ())
92d8f35ff217 compute bounding boxes for text in opengl graphics backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
3014 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
3015
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
3016 uint8NDArray pixels;
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3017 Matrix bbox;
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
3018 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
3019
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3020 bool blend = glIsEnabled (GL_BLEND);
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3021
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3022 glEnable (GL_BLEND);
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3023 glEnable (GL_ALPHA_TEST);
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3024 glRasterPos3d (x, y, z);
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
3025 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
3026 glDrawPixels (bbox(2), bbox(3),
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3027 GL_RGBA, GL_UNSIGNED_BYTE, pixels.data ());
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3028 glDisable (GL_ALPHA_TEST);
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3029 if (! blend)
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3030 glDisable (GL_BLEND);
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3031
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3032 return bbox;
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3033 #else
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9687
diff changeset
3034 ::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
3035 return Matrix (1, 4, 0.0);
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3036 #endif
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3037 }
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3038
7954
3ffc34caec65 configure fixes
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
3039 #endif