Mercurial > octave
annotate libinterp/corefcn/gl-render.cc @ 21198:1adcdc518d9e
provide wrapper for glFinish in opengl_renderer class
* gl-render.h, gl-render.cc (opengl_renderer::finish): New function.
* gl2ps-renderer.h, gl2ps-renderer.cc, __osmesa_print__.cc: Use it
instead of calling glFinish directly.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 04 Feb 2016 18:12:00 -0500 |
parents | bd96c2efd4fe |
children | fcac5dbbf9ed |
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 |
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19597
diff
changeset
|
3 Copyright (C) 2008-2015 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 | 27 #if defined (HAVE_OPENGL) |
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 |
21196
bd96c2efd4fe
move include statements for OpenGL headers to a single file
John W. Eaton <jwe@octave.org>
parents:
21115
diff
changeset
|
31 #ifdef HAVE_WINDOWS_H |
bd96c2efd4fe
move include statements for OpenGL headers to a single file
John W. Eaton <jwe@octave.org>
parents:
21115
diff
changeset
|
32 #define WIN32_LEAN_AND_MEAN |
bd96c2efd4fe
move include statements for OpenGL headers to a single file
John W. Eaton <jwe@octave.org>
parents:
21115
diff
changeset
|
33 #include <windows.h> |
bd96c2efd4fe
move include statements for OpenGL headers to a single file
John W. Eaton <jwe@octave.org>
parents:
21115
diff
changeset
|
34 #endif |
bd96c2efd4fe
move include statements for OpenGL headers to a single file
John W. Eaton <jwe@octave.org>
parents:
21115
diff
changeset
|
35 |
7825
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
36 #include <lo-mappers.h> |
8377
25bc2d31e1bf
improve OCTAVE_LOCAL_BUFFER
Jaroslav Hajek <highegg@gmail.com>
parents:
8263
diff
changeset
|
37 #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
|
38 #include "oct-refcount.h" |
21115
629643522cc0
include errwarn.h in all files that use gripe_disabled_feature
John W. Eaton <jwe@octave.org>
parents:
21109
diff
changeset
|
39 |
629643522cc0
include errwarn.h in all files that use gripe_disabled_feature
John W. Eaton <jwe@octave.org>
parents:
21109
diff
changeset
|
40 #include "errwarn.h" |
7825
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
41 #include "gl-render.h" |
21196
bd96c2efd4fe
move include statements for OpenGL headers to a single file
John W. Eaton <jwe@octave.org>
parents:
21115
diff
changeset
|
42 #include "oct-opengl.h" |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
8920
diff
changeset
|
43 #include "txt-eng.h" |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
8920
diff
changeset
|
44 #include "txt-eng-ft.h" |
7825
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
45 |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
46 #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
|
47 |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
48 // Use symbolic names for axes |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
49 enum |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
50 { |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
51 X_AXIS, |
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
52 Y_AXIS, |
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
53 Z_AXIS |
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
54 }; |
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
55 |
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
56 // Use symbolic names for color mode |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
57 enum |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
58 { |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
59 UNIFORM, |
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
60 FLAT, |
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
61 INTERP, |
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
62 TEXTURE |
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
63 }; |
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
64 |
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
65 // Use symbolic names for lighting |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
66 enum |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
67 { |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
68 NONE, |
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
69 //FLAT, // Already declared in anonymous enum for color mode |
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
70 GOURAUD = 2 |
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
71 }; |
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
72 |
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
|
73 // 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
|
74 // 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
|
75 // 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
|
76 #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
|
77 #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
|
78 #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
|
79 |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
80 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
|
81 opengl_texture |
7831
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
82 { |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
83 protected: |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
84 class texture_rep |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
85 { |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
86 public: |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11585
diff
changeset
|
87 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
|
88 : 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
|
89 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
|
90 { } |
7831
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
91 |
9681 | 92 texture_rep (GLuint id_arg, int w_arg, int h_arg, int tw_arg, int th_arg) |
17651
b0f529c3671d
gl-render.cc: Replace custom min function with std::min.
Rik <rik@octave.org>
parents:
17602
diff
changeset
|
93 : id (id_arg), w (w_arg), h (h_arg), tw (tw_arg), th (th_arg), |
b0f529c3671d
gl-render.cc: Replace custom min function with std::min.
Rik <rik@octave.org>
parents:
17602
diff
changeset
|
94 tx (double(w)/tw), ty (double(h)/th), valid (true), |
b0f529c3671d
gl-render.cc: Replace custom min function with std::min.
Rik <rik@octave.org>
parents:
17602
diff
changeset
|
95 count (1) { } |
7831
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
96 |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
97 ~texture_rep (void) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
98 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
99 if (valid) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
100 glDeleteTextures (1, &id); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
101 } |
7831
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 void bind (int mode) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
104 { if (valid) glBindTexture (mode, id); } |
7831
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 void tex_coord (double q, double r) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
107 { if (valid) glTexCoord2d (q*tx, r*ty); } |
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 GLuint id; |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
110 int w, h; |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
111 int tw, th; |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
112 double tx, ty; |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
113 bool valid; |
12125
a21a3875ca83
implement a common class for reference counts
Jaroslav Hajek <highegg@gmail.com>
parents:
12122
diff
changeset
|
114 octave_refcount<int> count; |
7831
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
115 }; |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
116 |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
117 texture_rep *rep; |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
118 |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
119 private: |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
120 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
|
121 |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
122 public: |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
123 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
|
124 |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
125 opengl_texture (const opengl_texture& tx) |
17651
b0f529c3671d
gl-render.cc: Replace custom min function with std::min.
Rik <rik@octave.org>
parents:
17602
diff
changeset
|
126 : rep (tx.rep) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
127 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
128 rep->count++; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
129 } |
7831
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
130 |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
131 ~opengl_texture (void) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
132 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
133 if (--rep->count == 0) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
134 delete rep; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
135 } |
7831
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
136 |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
137 opengl_texture& operator = (const opengl_texture& tx) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
138 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
139 if (--rep->count == 0) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
140 delete rep; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
141 |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
142 rep = tx.rep; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
143 rep->count++; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
144 |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
145 return *this; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
146 } |
7831
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
147 |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
148 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
|
149 |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
150 void bind (int mode = GL_TEXTURE_2D) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
151 { rep->bind (mode); } |
7831
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
152 |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
153 void tex_coord (double q, double r) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
154 { rep->tex_coord (q, r); } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11585
diff
changeset
|
155 |
7831
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
156 bool is_valid (void) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
157 { return rep->valid; } |
7831
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
158 }; |
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 static int |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
161 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
|
162 { |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
163 int m = 1; |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
164 |
15215
9020dddc925a
use std::numeric_limits for integer max and min values
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
165 while (m < n && m < std::numeric_limits<int>::max ()) |
7831
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
166 m <<= 1; |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
167 |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
168 return m; |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
169 } |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
170 |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
171 opengl_texture |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
172 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
|
173 { |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
174 opengl_texture retval; |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
175 |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
176 dim_vector dv (data.dims ()); |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
177 |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
178 // Expect RGB data |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
179 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
|
180 { |
17651
b0f529c3671d
gl-render.cc: Replace custom min function with std::min.
Rik <rik@octave.org>
parents:
17602
diff
changeset
|
181 // FIXME: dim_vectors hold octave_idx_type values. |
b0f529c3671d
gl-render.cc: Replace custom min function with std::min.
Rik <rik@octave.org>
parents:
17602
diff
changeset
|
182 // Should we check for dimensions larger than intmax? |
18100
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
183 int h, w, tw, th; |
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
184 h = dv(0), w = dv(1); |
7831
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
185 GLuint id; |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
186 bool ok = true; |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
187 |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
188 tw = next_power_of_2 (w); |
19898
2eed41ae3b64
Fix computation of next-power-of-2 for height in OpenGL texture creation.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19864
diff
changeset
|
189 th = next_power_of_2 (h); |
7831
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
190 |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
191 glGenTextures (1, &id); |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
192 glBindTexture (GL_TEXTURE_2D, id); |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
193 |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
194 if (data.is_double_type ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
195 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
196 const NDArray xdata = data.array_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
197 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
198 OCTAVE_LOCAL_BUFFER (float, a, (3*tw*th)); |
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 for (int i = 0; i < h; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
201 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
202 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
|
203 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
204 a[idx] = xdata(i,j,0); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
205 a[idx+1] = xdata(i,j,1); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
206 a[idx+2] = xdata(i,j,2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
207 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
208 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
209 |
17651
b0f529c3671d
gl-render.cc: Replace custom min function with std::min.
Rik <rik@octave.org>
parents:
17602
diff
changeset
|
210 glTexImage2D (GL_TEXTURE_2D, 0, 3, tw, th, 0, GL_RGB, GL_FLOAT, a); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
211 } |
7831
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
212 else if (data.is_uint8_type ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
213 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
214 const uint8NDArray xdata = data.uint8_array_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
215 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
216 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
|
217 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
218 for (int i = 0; i < h; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
219 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
220 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
|
221 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
222 a[idx] = xdata(i,j,0); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
223 a[idx+1] = xdata(i,j,1); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
224 a[idx+2] = xdata(i,j,2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
225 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
226 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
227 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
228 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
|
229 GL_RGB, GL_UNSIGNED_BYTE, a); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
230 } |
7831
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
231 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
232 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
233 ok = false; |
20711
7b608fadc663
Make error messages more specific about the variable and problem encountered.
Rik <rik@octave.org>
parents:
20623
diff
changeset
|
234 warning ("opengl_texture::create: invalid texture data type (double or uint8 required)"); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
235 } |
7831
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
236 |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
237 if (ok) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
238 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
239 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
|
240 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
|
241 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
242 if (glGetError () != GL_NO_ERROR) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
243 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
|
244 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
245 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
|
246 } |
7831
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
247 } |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
248 else |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
249 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
|
250 |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
251 return retval; |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
252 } |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
253 |
7833
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
254 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
|
255 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
|
256 { |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
257 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
|
258 #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
|
259 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
|
260 #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
|
261 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
|
262 #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
|
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 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
|
265 |
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
|
266 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
|
267 |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
268 virtual ~opengl_tesselator (void) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
269 { if (glu_tess) gluDeleteTess (glu_tess); } |
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
|
270 |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
271 void begin_polygon (bool filled = true) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
272 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
273 gluTessProperty (glu_tess, GLU_TESS_BOUNDARY_ONLY, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
274 (filled ? GL_FALSE : GL_TRUE)); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
275 fill = filled; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
276 gluTessBeginPolygon (glu_tess, this); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
277 } |
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
|
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 void end_polygon (void) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
280 { gluTessEndPolygon (glu_tess); } |
7833
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
281 |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
282 void begin_contour (void) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
283 { gluTessBeginContour (glu_tess); } |
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
|
284 |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
285 void end_contour (void) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
286 { gluTessEndContour (glu_tess); } |
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 |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
288 void add_vertex (double *loc, void *data) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
289 { gluTessVertex (glu_tess, loc, 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
|
290 |
8ff92634982d
Add initial 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 protected: |
7870 | 292 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
|
293 |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
294 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
|
295 |
17651
b0f529c3671d
gl-render.cc: Replace custom min function with std::min.
Rik <rik@octave.org>
parents:
17602
diff
changeset
|
296 virtual void vertex (void * /*data*/) { } |
b0f529c3671d
gl-render.cc: Replace custom min function with std::min.
Rik <rik@octave.org>
parents:
17602
diff
changeset
|
297 |
b0f529c3671d
gl-render.cc: Replace custom min function with std::min.
Rik <rik@octave.org>
parents:
17602
diff
changeset
|
298 virtual void combine (GLdouble [3] /*c*/, void * [4] /*data*/, |
b0f529c3671d
gl-render.cc: Replace custom min function with std::min.
Rik <rik@octave.org>
parents:
17602
diff
changeset
|
299 GLfloat [4] /*w*/, void ** /*out_data*/) { } |
7870 | 300 |
301 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
|
302 |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
303 virtual void error (GLenum err) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
304 { ::error ("OpenGL tesselation error (%d)", err); } |
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
|
305 |
8ff92634982d
Add initial 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 virtual void init (void) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
307 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
308 glu_tess = gluNewTess (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
309 |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
310 gluTessCallback (glu_tess, GLU_TESS_BEGIN_DATA, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
311 reinterpret_cast<fcn> (tess_begin)); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
312 gluTessCallback (glu_tess, GLU_TESS_END_DATA, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
313 reinterpret_cast<fcn> (tess_end)); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
314 gluTessCallback (glu_tess, GLU_TESS_VERTEX_DATA, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
315 reinterpret_cast<fcn> (tess_vertex)); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
316 gluTessCallback (glu_tess, GLU_TESS_COMBINE_DATA, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
317 reinterpret_cast<fcn> (tess_combine)); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
318 gluTessCallback (glu_tess, GLU_TESS_EDGE_FLAG_DATA, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
319 reinterpret_cast<fcn> (tess_edge_flag)); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
320 gluTessCallback (glu_tess, GLU_TESS_ERROR_DATA, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
321 reinterpret_cast<fcn> (tess_error)); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
322 } |
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
|
323 |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
324 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
|
325 |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
326 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
|
327 static void CALLBACK tess_begin (GLenum type, void *t) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
328 { 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
|
329 |
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
|
330 static void CALLBACK tess_end (void *t) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
331 { reinterpret_cast<opengl_tesselator *> (t)->end (); } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11585
diff
changeset
|
332 |
7833
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
333 static void CALLBACK tess_vertex (void *v, void *t) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
334 { 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
|
335 |
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
|
336 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
|
337 void **out, void *t) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
338 { 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
|
339 |
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
|
340 static void CALLBACK tess_edge_flag (GLboolean flag, void *t) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
341 { 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
|
342 |
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
|
343 static void CALLBACK tess_error (GLenum err, void *t) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
344 { reinterpret_cast<opengl_tesselator *> (t)->error (err); } |
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
|
345 |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
346 private: |
12122
f4689107dd8c
Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
11586
diff
changeset
|
347 |
f4689107dd8c
Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
11586
diff
changeset
|
348 // No copying! |
f4689107dd8c
Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
11586
diff
changeset
|
349 |
12174 | 350 opengl_tesselator (const opengl_tesselator&); |
351 | |
352 opengl_tesselator operator = (const opengl_tesselator&); | |
12122
f4689107dd8c
Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
11586
diff
changeset
|
353 |
7833
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
354 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
|
355 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
|
356 }; |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
357 |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
358 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
|
359 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
|
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 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
|
362 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
|
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 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
|
365 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
|
366 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
|
367 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
|
368 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
|
369 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
|
370 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
|
371 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
|
372 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
|
373 |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
374 // reference counter |
12125
a21a3875ca83
implement a common class for reference counts
Jaroslav Hajek <highegg@gmail.com>
parents:
12122
diff
changeset
|
375 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
|
376 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11585
diff
changeset
|
377 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
|
378 : 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
|
379 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
|
380 |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
381 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
|
382 double a, float as, float ds, float ss, float se) |
17651
b0f529c3671d
gl-render.cc: Replace custom min function with std::min.
Rik <rik@octave.org>
parents:
17602
diff
changeset
|
383 : coords (c), color (col), normal (n), alpha (a), |
b0f529c3671d
gl-render.cc: Replace custom min function with std::min.
Rik <rik@octave.org>
parents:
17602
diff
changeset
|
384 ambient (as), diffuse (ds), specular (ss), specular_exp (se), |
b0f529c3671d
gl-render.cc: Replace custom min function with std::min.
Rik <rik@octave.org>
parents:
17602
diff
changeset
|
385 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
|
386 }; |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
387 |
8ff92634982d
Add initial 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 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
|
389 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
|
390 |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
391 vertex_data_rep *nil_rep (void) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
392 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
393 static vertex_data_rep *nr = new vertex_data_rep (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
394 |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
395 return nr; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
396 } |
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
|
397 |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
398 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
|
399 vertex_data (void) : rep (nil_rep ()) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
400 { 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
|
401 |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
402 vertex_data (const vertex_data& v) : rep (v.rep) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
403 { 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
|
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 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
|
406 double a, float as, float ds, float ss, float se) |
17651
b0f529c3671d
gl-render.cc: Replace custom min function with std::min.
Rik <rik@octave.org>
parents:
17602
diff
changeset
|
407 : rep (new vertex_data_rep (c, col, n, a, as, ds, ss, se)) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
408 { } |
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
|
409 |
8ff92634982d
Add initial 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 vertex_data (vertex_data_rep *new_rep) |
17651
b0f529c3671d
gl-render.cc: Replace custom min function with std::min.
Rik <rik@octave.org>
parents:
17602
diff
changeset
|
411 : rep (new_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
|
412 |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
413 ~vertex_data (void) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
414 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
415 if (--rep->count == 0) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
416 delete rep; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
417 } |
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
|
418 |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
419 vertex_data& operator = (const vertex_data& v) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
420 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
421 if (--rep->count == 0) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
422 delete rep; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
423 |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
424 rep = v.rep; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
425 rep->count++; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
426 |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
427 return *this; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
428 } |
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 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
|
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 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
|
434 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
|
435 { |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
436 public: |
18768
75f8926deef1
Fix Z-order stacking of patches and axes grid lines (bug #40722).
Rik <rik@octave.org>
parents:
18720
diff
changeset
|
437 patch_tesselator (opengl_renderer *r, int cmode, int lmode, float idx = 0.0) |
17651
b0f529c3671d
gl-render.cc: Replace custom min function with std::min.
Rik <rik@octave.org>
parents:
17602
diff
changeset
|
438 : opengl_tesselator (), renderer (r), |
b0f529c3671d
gl-render.cc: Replace custom min function with std::min.
Rik <rik@octave.org>
parents:
17602
diff
changeset
|
439 color_mode (cmode), light_mode (lmode), index (idx), |
b0f529c3671d
gl-render.cc: Replace custom min function with std::min.
Rik <rik@octave.org>
parents:
17602
diff
changeset
|
440 first (true), tmp_vdata () |
12164
18e9a8da7d18
eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12126
diff
changeset
|
441 { } |
7833
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
442 |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
443 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
|
444 void begin (GLenum type) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
445 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
446 //printf ("patch_tesselator::begin (%d)\n", type); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
447 first = true; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
448 |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
449 if (color_mode == INTERP || light_mode == GOURAUD) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
450 glShadeModel (GL_SMOOTH); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
451 else |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
452 glShadeModel (GL_FLAT); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
453 |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
454 if (is_filled ()) |
18768
75f8926deef1
Fix Z-order stacking of patches and axes grid lines (bug #40722).
Rik <rik@octave.org>
parents:
18720
diff
changeset
|
455 renderer->set_polygon_offset (true, index); |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
456 |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
457 glBegin (type); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
458 } |
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
|
459 |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
460 void end (void) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
461 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
462 //printf ("patch_tesselator::end\n"); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
463 glEnd (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
464 renderer->set_polygon_offset (false); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
465 } |
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
|
466 |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
467 void vertex (void *data) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
468 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
469 vertex_data::vertex_data_rep *v |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
470 = reinterpret_cast<vertex_data::vertex_data_rep *> (data); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
471 //printf ("patch_tesselator::vertex (%g, %g, %g)\n", v->coords(0), v->coords(1), v->coords(2)); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
472 |
18768
75f8926deef1
Fix Z-order stacking of patches and axes grid lines (bug #40722).
Rik <rik@octave.org>
parents:
18720
diff
changeset
|
473 // NOTE: OpenGL can re-order vertices. For "flat" coloring of FaceColor |
75f8926deef1
Fix Z-order stacking of patches and axes grid lines (bug #40722).
Rik <rik@octave.org>
parents:
18720
diff
changeset
|
474 // the first vertex must be identified in the draw_patch routine. |
18296
c8d6ca222bcc
Make "edgecolor"="flat" for patch objects compatible with Matlab.
Rik <rik@octave.org>
parents:
18295
diff
changeset
|
475 |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
476 if (color_mode == INTERP || (color_mode == FLAT && ! is_filled ())) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
477 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
478 Matrix col = v->color; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
479 |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
480 if (col.numel () == 3) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
481 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
482 glColor3dv (col.data ()); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
483 if (light_mode > 0) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
484 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
485 float buf[4] = { 0, 0, 0, 1 }; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
486 |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
487 for (int k = 0; k < 3; k++) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
488 buf[k] = (v->ambient * col(k)); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
489 glMaterialfv (LIGHT_MODE, GL_AMBIENT, buf); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
490 |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
491 for (int k = 0; k < 3; k++) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
492 buf[k] = (v->diffuse * col(k)); |
18134
647d806868ee
Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents:
18100
diff
changeset
|
493 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, buf); |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
494 } |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
495 } |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
496 } |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
497 |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
498 if (light_mode > 0 && (first || light_mode == GOURAUD)) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
499 glNormal3dv (v->normal.data ()); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
500 |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
501 glVertex3dv (v->coords.data ()); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
502 |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
503 first = false; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
504 } |
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
|
505 |
18677
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
506 void combine (GLdouble xyz[3], void *data[4], GLfloat w[4], void **out_data) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
507 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
508 //printf ("patch_tesselator::combine\n"); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
509 |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
510 vertex_data::vertex_data_rep *v[4]; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
511 int vmax = 4; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
512 |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
513 for (int i = 0; i < 4; i++) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
514 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
515 v[i] = reinterpret_cast<vertex_data::vertex_data_rep *> (data[i]); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
516 |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
517 if (vmax == 4 && ! v[i]) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
518 vmax = i; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
519 } |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
520 |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
521 Matrix vv (1, 3, 0.0); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
522 Matrix cc; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
523 Matrix nn (1, 3, 0.0); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
524 double aa = 0.0; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
525 |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
526 vv(0) = xyz[0]; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
527 vv(1) = xyz[1]; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
528 vv(2) = xyz[2]; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
529 |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
530 if (v[0]->color.numel ()) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
531 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
532 cc.resize (1, 3, 0.0); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
533 for (int ic = 0; ic < 3; ic++) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
534 for (int iv = 0; iv < vmax; iv++) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
535 cc(ic) += (w[iv] * v[iv]->color (ic)); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
536 } |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
537 |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
538 if (v[0]->normal.numel () > 0) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
539 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
540 for (int in = 0; in < 3; in++) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
541 for (int iv = 0; iv < vmax; iv++) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
542 nn(in) += (w[iv] * v[iv]->normal (in)); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
543 } |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
544 |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
545 for (int iv = 0; iv < vmax; iv++) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
546 aa += (w[iv] * v[iv]->alpha); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
547 |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
548 vertex_data new_v (vv, cc, nn, aa, v[0]->ambient, v[0]->diffuse, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
549 v[0]->specular, v[0]->specular_exp); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
550 tmp_vdata.push_back (new_v); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
551 |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
552 *out_data = new_v.get_rep (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
553 } |
7833
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
554 |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
555 private: |
12122
f4689107dd8c
Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
11586
diff
changeset
|
556 |
f4689107dd8c
Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
11586
diff
changeset
|
557 // No copying! |
f4689107dd8c
Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
11586
diff
changeset
|
558 |
f4689107dd8c
Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
11586
diff
changeset
|
559 patch_tesselator (const patch_tesselator&); |
f4689107dd8c
Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
11586
diff
changeset
|
560 |
f4689107dd8c
Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
11586
diff
changeset
|
561 patch_tesselator& operator = (const patch_tesselator&); |
f4689107dd8c
Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
11586
diff
changeset
|
562 |
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
|
563 opengl_renderer *renderer; |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
564 int color_mode; |
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
565 int light_mode; |
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 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
|
567 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
|
568 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
|
569 }; |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
570 |
7825
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
571 void |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13219
diff
changeset
|
572 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
|
573 { |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
574 if (! go.valid_object ()) |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
575 return; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11585
diff
changeset
|
576 |
7825
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
577 const base_properties& props = go.get_properties (); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
578 |
14838
1abb7c083171
Make sure opengl_renderer::toolkit is defined.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
14138
diff
changeset
|
579 if (! toolkit) |
1abb7c083171
Make sure opengl_renderer::toolkit is defined.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
14138
diff
changeset
|
580 toolkit = props.get_toolkit (); |
1abb7c083171
Make sure opengl_renderer::toolkit is defined.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
14138
diff
changeset
|
581 |
7825
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
582 if (go.isa ("figure")) |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9687
diff
changeset
|
583 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
|
584 else if (go.isa ("axes")) |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9687
diff
changeset
|
585 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
|
586 else if (go.isa ("line")) |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9687
diff
changeset
|
587 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
|
588 else if (go.isa ("surface")) |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9687
diff
changeset
|
589 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
|
590 else if (go.isa ("patch")) |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9687
diff
changeset
|
591 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
|
592 else if (go.isa ("hggroup")) |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9687
diff
changeset
|
593 draw_hggroup (dynamic_cast<const hggroup::properties&> (props)); |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
8920
diff
changeset
|
594 else if (go.isa ("text")) |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9687
diff
changeset
|
595 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
|
596 else if (go.isa ("image")) |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9687
diff
changeset
|
597 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
|
598 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
|
599 || 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
|
600 || go.isa ("uipushtool") || go.isa ("uitoggletool")) |
20946 | 601 ; // SKIP |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13219
diff
changeset
|
602 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
|
603 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13219
diff
changeset
|
604 if (toplevel) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13219
diff
changeset
|
605 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
|
606 } |
7825
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
607 else |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13219
diff
changeset
|
608 { |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
609 warning ("opengl_renderer: cannot render object of type '%s'", |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13219
diff
changeset
|
610 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
|
611 } |
7825
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
612 } |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
613 |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
614 void |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9687
diff
changeset
|
615 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
|
616 { |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
617 // Initialize OpenGL context |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
618 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13219
diff
changeset
|
619 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
|
620 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13219
diff
changeset
|
621 // Draw children |
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 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
|
624 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13219
diff
changeset
|
625 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13219
diff
changeset
|
626 void |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13219
diff
changeset
|
627 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
|
628 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
|
629 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13219
diff
changeset
|
630 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
|
631 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
|
632 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
|
633 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
634 // Initialize OpenGL context |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13219
diff
changeset
|
635 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13219
diff
changeset
|
636 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
|
637 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
|
638 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13219
diff
changeset
|
639 // Draw children |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13219
diff
changeset
|
640 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13219
diff
changeset
|
641 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
|
642 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13219
diff
changeset
|
643 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13219
diff
changeset
|
644 void |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13219
diff
changeset
|
645 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
|
646 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13219
diff
changeset
|
647 // 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
|
648 |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
649 glEnable (GL_DEPTH_TEST); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
650 glDepthFunc (GL_LEQUAL); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
651 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
|
652 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
|
653 glEnable (GL_NORMALIZE); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
654 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13219
diff
changeset
|
655 if (enhanced) |
7907
c350329da645
Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents:
7906
diff
changeset
|
656 { |
c350329da645
Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents:
7906
diff
changeset
|
657 glEnable (GL_BLEND); |
18770
be8d7721ac16
Use OpenGL line smoothing when multisample is not available.
Rik <rik@octave.org>
parents:
18769
diff
changeset
|
658 glEnable (GL_MULTISAMPLE); |
be8d7721ac16
Use OpenGL line smoothing when multisample is not available.
Rik <rik@octave.org>
parents:
18769
diff
changeset
|
659 GLint iMultiSample, iNumSamples; |
be8d7721ac16
Use OpenGL line smoothing when multisample is not available.
Rik <rik@octave.org>
parents:
18769
diff
changeset
|
660 glGetIntegerv (GL_SAMPLE_BUFFERS, &iMultiSample); |
be8d7721ac16
Use OpenGL line smoothing when multisample is not available.
Rik <rik@octave.org>
parents:
18769
diff
changeset
|
661 glGetIntegerv (GL_SAMPLES, &iNumSamples); |
be8d7721ac16
Use OpenGL line smoothing when multisample is not available.
Rik <rik@octave.org>
parents:
18769
diff
changeset
|
662 if (iMultiSample != GL_TRUE || iNumSamples == 0) |
be8d7721ac16
Use OpenGL line smoothing when multisample is not available.
Rik <rik@octave.org>
parents:
18769
diff
changeset
|
663 { |
be8d7721ac16
Use OpenGL line smoothing when multisample is not available.
Rik <rik@octave.org>
parents:
18769
diff
changeset
|
664 // MultiSample not implemented. Use old-style anti-aliasing |
be8d7721ac16
Use OpenGL line smoothing when multisample is not available.
Rik <rik@octave.org>
parents:
18769
diff
changeset
|
665 glDisable (GL_MULTISAMPLE); |
be8d7721ac16
Use OpenGL line smoothing when multisample is not available.
Rik <rik@octave.org>
parents:
18769
diff
changeset
|
666 glEnable (GL_LINE_SMOOTH); |
be8d7721ac16
Use OpenGL line smoothing when multisample is not available.
Rik <rik@octave.org>
parents:
18769
diff
changeset
|
667 glHint (GL_LINE_SMOOTH_HINT, GL_NICEST); |
be8d7721ac16
Use OpenGL line smoothing when multisample is not available.
Rik <rik@octave.org>
parents:
18769
diff
changeset
|
668 } |
7907
c350329da645
Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents:
7906
diff
changeset
|
669 } |
c350329da645
Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents:
7906
diff
changeset
|
670 else |
c350329da645
Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents:
7906
diff
changeset
|
671 { |
c350329da645
Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents:
7906
diff
changeset
|
672 glDisable (GL_BLEND); |
c350329da645
Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents:
7906
diff
changeset
|
673 glDisable (GL_LINE_SMOOTH); |
c350329da645
Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents:
7906
diff
changeset
|
674 } |
c350329da645
Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents:
7906
diff
changeset
|
675 |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
676 // Clear background |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
677 |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20055
diff
changeset
|
678 if (c.numel () >= 3) |
7825
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
679 { |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
680 glClearColor (c(0), c(1), c(2), 1); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
681 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
|
682 } |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
683 } |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
684 |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
685 void |
12321
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
686 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
|
687 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
|
688 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
|
689 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
|
690 { |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
691 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
|
692 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
|
693 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
|
694 { |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
695 double val = ticks(i); |
18720
04adeda9b83d
Revert ea22cf3e370b and 60df2fd04293 plotting grid/ticks over axes lines.
Rik <rik@octave.org>
parents:
18705
diff
changeset
|
696 if (lim1 <= val && val <= lim2) |
12126
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
697 { |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
698 if (xyz == X_AXIS) |
12126
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
699 { |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
700 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
|
701 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
|
702 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
|
703 { |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
704 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
|
705 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
|
706 } |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
707 } |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
708 else if (xyz == Y_AXIS) |
12126
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
709 { |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
710 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
|
711 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
|
712 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
|
713 { |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
714 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
|
715 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
|
716 } |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
717 } |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
718 else if (xyz == Z_AXIS) |
12126
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
719 { |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
720 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
|
721 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
|
722 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
|
723 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
|
724 } |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
725 } |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
726 } |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
727 glEnd (); |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
728 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
|
729 } |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
730 |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
731 void |
12321
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
732 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
|
733 double lim1, double lim2, |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
734 double p1, double p1N, |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
735 double p2, double p2N, |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
736 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
|
737 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
|
738 { |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
739 glBegin (GL_LINES); |
12321
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
740 |
12126
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
741 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
|
742 { |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
743 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
|
744 |
18720
04adeda9b83d
Revert ea22cf3e370b and 60df2fd04293 plotting grid/ticks over axes lines.
Rik <rik@octave.org>
parents:
18705
diff
changeset
|
745 if (lim1 <= val && val <= lim2) |
12126
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
746 { |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
747 if (xyz == X_AXIS) |
12126
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 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
|
750 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
|
751 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
|
752 { |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
753 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
|
754 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
|
755 } |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
756 } |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
757 else if (xyz == Y_AXIS) |
12126
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 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
|
760 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
|
761 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
|
762 { |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
763 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
|
764 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
|
765 } |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
766 } |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
767 else if (xyz == Z_AXIS) |
12126
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
768 { |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
769 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
|
770 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
|
771 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
|
772 { |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
773 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
|
774 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
|
775 } |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
776 } |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
777 } |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
778 } |
12321
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
779 |
12126
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
780 glEnd (); |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
781 } |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
782 |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
783 void |
12321
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
784 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
|
785 const string_vector& ticklabels, |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
786 double lim1, double lim2, |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
787 double p1, double p2, |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
788 int xyz, int ha, int va, |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
789 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
|
790 { |
16855
359ac80ecb30
Trim ticklabel strings and repeat them as necessary to fill tick marks (bug #39344)
Rik <rik@octave.org>
parents:
15467
diff
changeset
|
791 int nticks = ticks.numel (); |
359ac80ecb30
Trim ticklabel strings and repeat them as necessary to fill tick marks (bug #39344)
Rik <rik@octave.org>
parents:
15467
diff
changeset
|
792 int nlabels = ticklabels.numel (); |
359ac80ecb30
Trim ticklabel strings and repeat them as necessary to fill tick marks (bug #39344)
Rik <rik@octave.org>
parents:
15467
diff
changeset
|
793 |
359ac80ecb30
Trim ticklabel strings and repeat them as necessary to fill tick marks (bug #39344)
Rik <rik@octave.org>
parents:
15467
diff
changeset
|
794 if (nlabels == 0) |
359ac80ecb30
Trim ticklabel strings and repeat them as necessary to fill tick marks (bug #39344)
Rik <rik@octave.org>
parents:
15467
diff
changeset
|
795 return; |
359ac80ecb30
Trim ticklabel strings and repeat them as necessary to fill tick marks (bug #39344)
Rik <rik@octave.org>
parents:
15467
diff
changeset
|
796 |
359ac80ecb30
Trim ticklabel strings and repeat them as necessary to fill tick marks (bug #39344)
Rik <rik@octave.org>
parents:
15467
diff
changeset
|
797 for (int i = 0; i < nticks; i++) |
12126
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
798 { |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
799 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
|
800 |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
801 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
|
802 { |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
803 Matrix b; |
16855
359ac80ecb30
Trim ticklabel strings and repeat them as necessary to fill tick marks (bug #39344)
Rik <rik@octave.org>
parents:
15467
diff
changeset
|
804 |
359ac80ecb30
Trim ticklabel strings and repeat them as necessary to fill tick marks (bug #39344)
Rik <rik@octave.org>
parents:
15467
diff
changeset
|
805 std::string label (ticklabels(i % nlabels)); |
359ac80ecb30
Trim ticklabel strings and repeat them as necessary to fill tick marks (bug #39344)
Rik <rik@octave.org>
parents:
15467
diff
changeset
|
806 label.erase (0, label.find_first_not_of (" ")); |
359ac80ecb30
Trim ticklabel strings and repeat them as necessary to fill tick marks (bug #39344)
Rik <rik@octave.org>
parents:
15467
diff
changeset
|
807 label = label.substr (0, label.find_last_not_of (" ")+1); |
359ac80ecb30
Trim ticklabel strings and repeat them as necessary to fill tick marks (bug #39344)
Rik <rik@octave.org>
parents:
15467
diff
changeset
|
808 |
18677
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
809 // FIXME: As tick text is transparent, shouldn't it be |
12126
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
810 // drawn after axes object, for correct rendering? |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
811 if (xyz == X_AXIS) |
12126
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
812 { |
16855
359ac80ecb30
Trim ticklabel strings and repeat them as necessary to fill tick marks (bug #39344)
Rik <rik@octave.org>
parents:
15467
diff
changeset
|
813 b = render_text (label, 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
|
814 } |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
815 else if (xyz == Y_AXIS) |
12126
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
816 { |
16855
359ac80ecb30
Trim ticklabel strings and repeat them as necessary to fill tick marks (bug #39344)
Rik <rik@octave.org>
parents:
15467
diff
changeset
|
817 b = render_text (label, 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
|
818 } |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
819 else if (xyz == Z_AXIS) |
12126
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
820 { |
16855
359ac80ecb30
Trim ticklabel strings and repeat them as necessary to fill tick marks (bug #39344)
Rik <rik@octave.org>
parents:
15467
diff
changeset
|
821 b = render_text (label, 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
|
822 } |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
823 |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
824 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
|
825 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
|
826 } |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
827 } |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
828 } |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
829 |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
12125
diff
changeset
|
830 void |
21198
1adcdc518d9e
provide wrapper for glFinish in opengl_renderer class
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
831 opengl_renderer::finish (void) |
1adcdc518d9e
provide wrapper for glFinish in opengl_renderer class
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
832 { |
1adcdc518d9e
provide wrapper for glFinish in opengl_renderer class
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
833 glFinish (); |
1adcdc518d9e
provide wrapper for glFinish in opengl_renderer class
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
834 } |
1adcdc518d9e
provide wrapper for glFinish in opengl_renderer class
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
835 |
1adcdc518d9e
provide wrapper for glFinish in opengl_renderer class
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
836 void |
12321
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
837 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
|
838 { |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
839 // setup OpenGL transformation |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
840 |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
841 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
|
842 |
7825
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
843 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
|
844 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
|
845 |
12321
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
846 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
|
847 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
|
848 |
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
|
849 #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
|
850 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
|
851 #else |
7825
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
852 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
|
853 #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
|
854 |
7825
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
855 glGetIntegerv (GL_VIEWPORT, vw); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
856 |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
857 glMatrixMode (GL_MODELVIEW); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
858 glLoadIdentity (); |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
859 glScaled (1, 1, -1); |
7825
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
860 glMultMatrixd (x_mat1.data ()); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
861 glMatrixMode (GL_PROJECTION); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
862 glLoadIdentity (); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
863 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
|
864 glMultMatrixd (x_mat2.data ()); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
865 glMatrixMode (GL_MODELVIEW); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
866 |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
867 glClear (GL_DEPTH_BUFFER_BIT); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
868 |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
869 // store axes transformation data |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
870 |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
871 xform = props.get_transform (); |
12321
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
872 } |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
873 |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
874 void |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12321
diff
changeset
|
875 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
|
876 { |
18677
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
877 Matrix axe_color = props.get_color_rgb (); |
20974
1edf15793cac
maint: Use is_empty rather than "numel () == 0" for clarity.
Rik <rik@octave.org>
parents:
20955
diff
changeset
|
878 if (axe_color.is_empty () || ! props.is_visible ()) |
18677
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
879 return; |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
880 |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12321
diff
changeset
|
881 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
|
882 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
|
883 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
|
884 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
|
885 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
|
886 double zPlaneN = props.get_zPlaneN (); |
20055
438485f6a479
Honor the axes stack order in gl2ps outputs (bug #44765)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20034
diff
changeset
|
887 bool is2d = props.get_is2D (); |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12321
diff
changeset
|
888 |
12321
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
889 // Axes planes |
18677
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
890 set_color (axe_color); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
891 set_polygon_offset (true, 2.5); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
892 |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
893 glBegin (GL_QUADS); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
894 |
20055
438485f6a479
Honor the axes stack order in gl2ps outputs (bug #44765)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20034
diff
changeset
|
895 if (! is2d) |
438485f6a479
Honor the axes stack order in gl2ps outputs (bug #44765)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20034
diff
changeset
|
896 { |
438485f6a479
Honor the axes stack order in gl2ps outputs (bug #44765)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20034
diff
changeset
|
897 // X plane |
438485f6a479
Honor the axes stack order in gl2ps outputs (bug #44765)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20034
diff
changeset
|
898 glVertex3d (xPlane, yPlaneN, zPlaneN); |
438485f6a479
Honor the axes stack order in gl2ps outputs (bug #44765)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20034
diff
changeset
|
899 glVertex3d (xPlane, yPlane, zPlaneN); |
438485f6a479
Honor the axes stack order in gl2ps outputs (bug #44765)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20034
diff
changeset
|
900 glVertex3d (xPlane, yPlane, zPlane); |
438485f6a479
Honor the axes stack order in gl2ps outputs (bug #44765)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20034
diff
changeset
|
901 glVertex3d (xPlane, yPlaneN, zPlane); |
438485f6a479
Honor the axes stack order in gl2ps outputs (bug #44765)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20034
diff
changeset
|
902 |
438485f6a479
Honor the axes stack order in gl2ps outputs (bug #44765)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20034
diff
changeset
|
903 // Y plane |
438485f6a479
Honor the axes stack order in gl2ps outputs (bug #44765)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20034
diff
changeset
|
904 glVertex3d (xPlaneN, yPlane, zPlaneN); |
438485f6a479
Honor the axes stack order in gl2ps outputs (bug #44765)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20034
diff
changeset
|
905 glVertex3d (xPlane, yPlane, zPlaneN); |
438485f6a479
Honor the axes stack order in gl2ps outputs (bug #44765)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20034
diff
changeset
|
906 glVertex3d (xPlane, yPlane, zPlane); |
438485f6a479
Honor the axes stack order in gl2ps outputs (bug #44765)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20034
diff
changeset
|
907 glVertex3d (xPlaneN, yPlane, zPlane); |
438485f6a479
Honor the axes stack order in gl2ps outputs (bug #44765)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20034
diff
changeset
|
908 } |
18677
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
909 |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
910 // Z plane |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
911 glVertex3d (xPlaneN, yPlaneN, zPlane); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
912 glVertex3d (xPlane, yPlaneN, zPlane); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
913 glVertex3d (xPlane, yPlane, zPlane); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
914 glVertex3d (xPlaneN, yPlane, zPlane); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
915 |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
916 glEnd (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
917 |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
918 set_polygon_offset (false); |
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 |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
921 void |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12321
diff
changeset
|
922 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
|
923 { |
18677
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
924 if (! props.is_visible ()) |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
925 return; |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
926 |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12321
diff
changeset
|
927 bool xySym = props.get_xySym (); |
18667
e42843ceff48
Fix axes bounding box not obeying 'layer' property.
Rik <rik@octave.org>
parents:
18658
diff
changeset
|
928 bool layer2Dtop = props.get_layer2Dtop (); |
e42843ceff48
Fix axes bounding box not obeying 'layer' property.
Rik <rik@octave.org>
parents:
18658
diff
changeset
|
929 bool is2d = props.get_is2D (); |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12321
diff
changeset
|
930 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
|
931 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
|
932 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
|
933 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
|
934 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
|
935 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
|
936 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
|
937 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
|
938 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
|
939 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
|
940 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
|
941 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
|
942 |
13216 | 943 bool plotyy = (props.has_property ("__plotyy_axes__")); |
12443
24b38afd6a45
fix plotyy bugs #31800, #32211
Konstantinos Poulios <logari81@googlemail.com>
parents:
12334
diff
changeset
|
944 |
12321
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
945 // Axes box |
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 set_linestyle ("-", true); |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
948 set_linewidth (props.get_linewidth ()); |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
949 |
18677
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
950 glBegin (GL_LINES); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
951 |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
952 if (layer2Dtop) |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
953 std::swap (zpTick, zpTickN); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
954 |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
955 // X box |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
956 set_color (props.get_xcolor_rgb ()); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
957 glVertex3d (xPlaneN, ypTick, zpTick); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
958 glVertex3d (xPlane, ypTick, zpTick); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
959 |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
960 if (props.is_box ()) |
12321
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
961 { |
18677
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
962 glVertex3d (xPlaneN, ypTickN, zpTick); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
963 glVertex3d (xPlane, ypTickN, zpTick); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
964 if (! is2d) |
12321
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
965 { |
18677
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
966 glVertex3d (xPlaneN, ypTickN, zpTickN); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
967 glVertex3d (xPlane, ypTickN, zpTickN); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
968 glVertex3d (xPlaneN, ypTick, zpTickN); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
969 glVertex3d (xPlane, ypTick, zpTickN); |
12321
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
970 } |
18677
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
971 } |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
972 |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
973 // Y box |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
974 set_color (props.get_ycolor_rgb ()); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
975 glVertex3d (xpTick, yPlaneN, zpTick); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
976 glVertex3d (xpTick, yPlane, zpTick); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
977 |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
978 if (props.is_box () && ! plotyy) |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
979 { |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
980 glVertex3d (xpTickN, yPlaneN, zpTick); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
981 glVertex3d (xpTickN, yPlane, zpTick); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
982 |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
983 if (! is2d) |
12321
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
984 { |
18677
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
985 glVertex3d (xpTickN, yPlaneN, zpTickN); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
986 glVertex3d (xpTickN, yPlane, zpTickN); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
987 glVertex3d (xpTick, yPlaneN, zpTickN); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
988 glVertex3d (xpTick, yPlane, zpTickN); |
12321
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
989 } |
18677
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
990 } |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
991 |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
992 // Z box |
20034
42c3a0829324
Skip z axes rendering when in 2D mode (bug #44752)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19898
diff
changeset
|
993 if (! is2d) |
18677
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
994 { |
20034
42c3a0829324
Skip z axes rendering when in 2D mode (bug #44752)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19898
diff
changeset
|
995 set_color (props.get_zcolor_rgb ()); |
12321
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
996 |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
997 if (xySym) |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
998 { |
20034
42c3a0829324
Skip z axes rendering when in 2D mode (bug #44752)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19898
diff
changeset
|
999 glVertex3d (xPlaneN, yPlane, zPlaneN); |
42c3a0829324
Skip z axes rendering when in 2D mode (bug #44752)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19898
diff
changeset
|
1000 glVertex3d (xPlaneN, yPlane, zPlane); |
42c3a0829324
Skip z axes rendering when in 2D mode (bug #44752)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19898
diff
changeset
|
1001 } |
42c3a0829324
Skip z axes rendering when in 2D mode (bug #44752)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19898
diff
changeset
|
1002 else |
42c3a0829324
Skip z axes rendering when in 2D mode (bug #44752)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19898
diff
changeset
|
1003 { |
18677
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1004 glVertex3d (xPlane, yPlaneN, zPlaneN); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1005 glVertex3d (xPlane, yPlaneN, zPlane); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1006 } |
20034
42c3a0829324
Skip z axes rendering when in 2D mode (bug #44752)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19898
diff
changeset
|
1007 |
42c3a0829324
Skip z axes rendering when in 2D mode (bug #44752)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19898
diff
changeset
|
1008 if (props.is_box ()) |
18677
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1009 { |
20034
42c3a0829324
Skip z axes rendering when in 2D mode (bug #44752)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19898
diff
changeset
|
1010 glVertex3d (xPlane, yPlane, zPlaneN); |
42c3a0829324
Skip z axes rendering when in 2D mode (bug #44752)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19898
diff
changeset
|
1011 glVertex3d (xPlane, yPlane, zPlane); |
42c3a0829324
Skip z axes rendering when in 2D mode (bug #44752)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19898
diff
changeset
|
1012 |
42c3a0829324
Skip z axes rendering when in 2D mode (bug #44752)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19898
diff
changeset
|
1013 if (xySym) |
42c3a0829324
Skip z axes rendering when in 2D mode (bug #44752)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19898
diff
changeset
|
1014 { |
42c3a0829324
Skip z axes rendering when in 2D mode (bug #44752)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19898
diff
changeset
|
1015 glVertex3d (xPlane, yPlaneN, zPlaneN); |
42c3a0829324
Skip z axes rendering when in 2D mode (bug #44752)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19898
diff
changeset
|
1016 glVertex3d (xPlane, yPlaneN, zPlane); |
42c3a0829324
Skip z axes rendering when in 2D mode (bug #44752)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19898
diff
changeset
|
1017 } |
42c3a0829324
Skip z axes rendering when in 2D mode (bug #44752)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19898
diff
changeset
|
1018 else |
42c3a0829324
Skip z axes rendering when in 2D mode (bug #44752)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19898
diff
changeset
|
1019 { |
42c3a0829324
Skip z axes rendering when in 2D mode (bug #44752)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19898
diff
changeset
|
1020 glVertex3d (xPlaneN, yPlane, zPlaneN); |
42c3a0829324
Skip z axes rendering when in 2D mode (bug #44752)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19898
diff
changeset
|
1021 glVertex3d (xPlaneN, yPlane, zPlane); |
42c3a0829324
Skip z axes rendering when in 2D mode (bug #44752)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19898
diff
changeset
|
1022 } |
42c3a0829324
Skip z axes rendering when in 2D mode (bug #44752)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19898
diff
changeset
|
1023 |
42c3a0829324
Skip z axes rendering when in 2D mode (bug #44752)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19898
diff
changeset
|
1024 glVertex3d (xPlaneN, yPlaneN, zPlaneN); |
42c3a0829324
Skip z axes rendering when in 2D mode (bug #44752)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19898
diff
changeset
|
1025 glVertex3d (xPlaneN, yPlaneN, zPlane); |
12321
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1026 } |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1027 } |
18677
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1028 |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1029 glEnd (); |
12321
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1030 } |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1031 |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1032 void |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12321
diff
changeset
|
1033 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
|
1034 { |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12321
diff
changeset
|
1035 int xstate = props.get_xstate (); |
12321
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1036 |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12321
diff
changeset
|
1037 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
|
1038 { |
18677
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1039 int zstate = props.get_zstate (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1040 bool x2Dtop = props.get_x2Dtop (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1041 bool layer2Dtop = props.get_layer2Dtop (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1042 bool xyzSym = props.get_xyzSym (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1043 bool nearhoriz = props.get_nearhoriz (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1044 double xticklen = props.get_xticklen (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1045 double xtickoffset = props.get_xtickoffset (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1046 double fy = props.get_fy (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1047 double fz = props.get_fz (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1048 double x_min = props.get_x_min (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1049 double x_max = props.get_x_max (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1050 double yPlane = props.get_yPlane (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1051 double yPlaneN = props.get_yPlaneN (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1052 double ypTick = props.get_ypTick (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1053 double ypTickN = props.get_ypTickN (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1054 double zPlane = props.get_zPlane (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1055 double zPlaneN = props.get_zPlaneN (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1056 double zpTick = props.get_zpTick (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1057 double zpTickN = props.get_zpTickN (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1058 |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1059 // X grid |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1060 |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12321
diff
changeset
|
1061 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
|
1062 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
|
1063 bool do_xgrid = (props.is_xgrid () && (gridstyle != "none")); |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1064 bool do_xminorgrid = (props.is_xminorgrid () |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1065 && (minorgridstyle != "none")); |
12321
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1066 bool do_xminortick = props.is_xminortick (); |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1067 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
|
1068 Matrix xmticks = xform.xscale (props.get_xmtick ().matrix_value ()); |
20990
fc9cca99b2de
Deprecate all_strings, replace with string_vector_value.
Rik <rik@octave.org>
parents:
20974
diff
changeset
|
1069 string_vector xticklabels = props.get_xticklabel ().string_vector_value (); |
18100
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
1070 int wmax = 0; |
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
1071 int hmax = 0; |
12321
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1072 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
|
1073 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
|
1074 |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1075 set_color (props.get_xcolor_rgb ()); |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1076 |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1077 // grid lines |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1078 if (do_xgrid) |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1079 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
|
1080 yPlane, yPlaneN, layer2Dtop ? zPlaneN : zPlane, |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1081 zPlaneN, 0, (zstate != AXE_DEPTH_DIR)); |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1082 |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1083 // tick marks |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1084 if (tick_along_z) |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1085 { |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1086 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
|
1087 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
|
1088 signum (zpTick-zpTickN)*fz*xticklen, |
12684
abfcb5d5641b
Disable mirrored axes ticks for plottyy in ftlk
Konstantinos Poulios <logari81@googlemail.com>
parents:
12446
diff
changeset
|
1089 0, mirror); |
12321
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1090 } |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1091 else |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1092 { |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1093 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
|
1094 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
|
1095 signum (ypTick-ypTickN)*fy*xticklen, |
12684
abfcb5d5641b
Disable mirrored axes ticks for plottyy in ftlk
Konstantinos Poulios <logari81@googlemail.com>
parents:
12446
diff
changeset
|
1096 0., 0, mirror); |
12321
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1097 } |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1098 |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1099 // tick texts |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1100 if (xticklabels.numel () > 0) |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1101 { |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1102 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
|
1103 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
|
1104 |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1105 if (tick_along_z) |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1106 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
|
1107 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
|
1108 0, halign, valign, wmax, hmax); |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1109 else |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1110 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
|
1111 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
|
1112 zpTick, 0, halign, valign, wmax, hmax); |
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 |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1115 // minor grid lines |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1116 if (do_xminorgrid) |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1117 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
|
1118 yPlane, yPlaneN, layer2Dtop ? zPlaneN : zPlane, |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1119 zPlaneN, 0, (zstate != AXE_DEPTH_DIR)); |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1120 |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1121 // minor tick marks |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1122 if (do_xminortick) |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1123 { |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1124 if (tick_along_z) |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1125 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
|
1126 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
|
1127 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
|
1128 0, mirror); |
12321
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1129 else |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1130 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
|
1131 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
|
1132 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
|
1133 0., 0, mirror); |
12321
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1134 } |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1135 |
12334
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12333
diff
changeset
|
1136 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
|
1137 } |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1138 else |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1139 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
|
1140 } |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1141 |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1142 void |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12321
diff
changeset
|
1143 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
|
1144 { |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12321
diff
changeset
|
1145 int ystate = props.get_ystate (); |
12321
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1146 |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12321
diff
changeset
|
1147 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
|
1148 { |
18677
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1149 int zstate = props.get_zstate (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1150 bool y2Dright = props.get_y2Dright (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1151 bool layer2Dtop = props.get_layer2Dtop (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1152 bool xyzSym = props.get_xyzSym (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1153 bool nearhoriz = props.get_nearhoriz (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1154 double yticklen = props.get_yticklen (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1155 double ytickoffset = props.get_ytickoffset (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1156 double fx = props.get_fx (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1157 double fz = props.get_fz (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1158 double xPlane = props.get_xPlane (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1159 double xPlaneN = props.get_xPlaneN (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1160 double xpTick = props.get_xpTick (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1161 double xpTickN = props.get_xpTickN (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1162 double y_min = props.get_y_min (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1163 double y_max = props.get_y_max (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1164 double zPlane = props.get_zPlane (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1165 double zPlaneN = props.get_zPlaneN (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1166 double zpTick = props.get_zpTick (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1167 double zpTickN = props.get_zpTickN (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1168 |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1169 // Y grid |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1170 |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12321
diff
changeset
|
1171 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
|
1172 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
|
1173 bool do_ygrid = (props.is_ygrid () && (gridstyle != "none")); |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1174 bool do_yminorgrid = (props.is_yminorgrid () |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1175 && (minorgridstyle != "none")); |
12321
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1176 bool do_yminortick = props.is_yminortick (); |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1177 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
|
1178 Matrix ymticks = xform.yscale (props.get_ymtick ().matrix_value ()); |
20990
fc9cca99b2de
Deprecate all_strings, replace with string_vector_value.
Rik <rik@octave.org>
parents:
20974
diff
changeset
|
1179 string_vector yticklabels = props.get_yticklabel ().string_vector_value (); |
18100
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
1180 int wmax = 0; |
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
1181 int hmax = 0; |
12321
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1182 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
|
1183 bool mirror = props.is_box () && ystate != AXE_ANY_DIR |
13216 | 1184 && (! props.has_property ("__plotyy_axes__")); |
12321
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1185 |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1186 set_color (props.get_ycolor_rgb ()); |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1187 |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1188 // grid lines |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1189 if (do_ygrid) |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1190 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
|
1191 xPlane, xPlaneN, layer2Dtop ? zPlaneN : zPlane, |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1192 zPlaneN, 1, (zstate != AXE_DEPTH_DIR)); |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1193 |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1194 // tick marks |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1195 if (tick_along_z) |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1196 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
|
1197 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
|
1198 signum (zpTick-zpTickN)*fz*yticklen, |
12684
abfcb5d5641b
Disable mirrored axes ticks for plottyy in ftlk
Konstantinos Poulios <logari81@googlemail.com>
parents:
12446
diff
changeset
|
1199 1, mirror); |
12321
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1200 else |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1201 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
|
1202 zpTick, zpTick, |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
1203 signum (xPlaneN-xPlane)*fx*yticklen, |
12684
abfcb5d5641b
Disable mirrored axes ticks for plottyy in ftlk
Konstantinos Poulios <logari81@googlemail.com>
parents:
12446
diff
changeset
|
1204 0., 0., 1, mirror); |
12321
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1205 |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1206 // tick texts |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1207 if (yticklabels.numel () > 0) |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1208 { |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1209 int halign = (ystate == AXE_HORZ_DIR |
20955
77f5591878bf
maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
1210 ? 1 : (! xyzSym || y2Dright ? 0 : 2)); |
12321
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1211 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
|
1212 |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1213 if (tick_along_z) |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1214 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
|
1215 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
|
1216 1, halign, valign, wmax, hmax); |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1217 else |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1218 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
|
1219 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
|
1220 zpTick, 1, halign, valign, wmax, hmax); |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1221 } |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1222 |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1223 // minor grid lines |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1224 if (do_yminorgrid) |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1225 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
|
1226 xPlane, xPlaneN, layer2Dtop ? zPlaneN : zPlane, |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1227 zPlaneN, 1, (zstate != AXE_DEPTH_DIR)); |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1228 |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1229 // minor tick marks |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1230 if (do_yminortick) |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1231 { |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1232 if (tick_along_z) |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1233 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
|
1234 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
|
1235 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
|
1236 1, mirror); |
12321
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1237 else |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1238 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
|
1239 zpTick, zpTick, |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
1240 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
|
1241 0., 0., 1, mirror); |
12321
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1242 } |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1243 |
12334
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12333
diff
changeset
|
1244 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
|
1245 } |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1246 else |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1247 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
|
1248 } |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1249 |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1250 void |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12321
diff
changeset
|
1251 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
|
1252 { |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12321
diff
changeset
|
1253 int zstate = props.get_zstate (); |
12321
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1254 |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12321
diff
changeset
|
1255 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
|
1256 { |
18677
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1257 bool xySym = props.get_xySym (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1258 bool zSign = props.get_zSign (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1259 double zticklen = props.get_zticklen (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1260 double ztickoffset = props.get_ztickoffset (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1261 double fx = props.get_fx (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1262 double fy = props.get_fy (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1263 double xPlane = props.get_xPlane (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1264 double xPlaneN = props.get_xPlaneN (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1265 double yPlane = props.get_yPlane (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1266 double yPlaneN = props.get_yPlaneN (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1267 double z_min = props.get_z_min (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1268 double z_max = props.get_z_max (); |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1269 |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1270 // Z Grid |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1271 |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12321
diff
changeset
|
1272 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
|
1273 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
|
1274 bool do_zgrid = (props.is_zgrid () && (gridstyle != "none")); |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1275 bool do_zminorgrid = (props.is_zminorgrid () |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1276 && (minorgridstyle != "none")); |
12321
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1277 bool do_zminortick = props.is_zminortick (); |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1278 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
|
1279 Matrix zmticks = xform.zscale (props.get_zmtick ().matrix_value ()); |
20990
fc9cca99b2de
Deprecate all_strings, replace with string_vector_value.
Rik <rik@octave.org>
parents:
20974
diff
changeset
|
1280 string_vector zticklabels = props.get_zticklabel ().string_vector_value (); |
18100
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
1281 int wmax = 0; |
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
1282 int hmax = 0; |
12684
abfcb5d5641b
Disable mirrored axes ticks for plottyy in ftlk
Konstantinos Poulios <logari81@googlemail.com>
parents:
12446
diff
changeset
|
1283 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
|
1284 |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1285 set_color (props.get_zcolor_rgb ()); |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1286 |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1287 // grid lines |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1288 if (do_zgrid) |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1289 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
|
1290 xPlane, xPlaneN, yPlane, yPlaneN, 2, true); |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1291 |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1292 // tick marks |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1293 if (xySym) |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1294 { |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1295 if (xisinf (fy)) |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1296 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
|
1297 yPlane, yPlane, |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
1298 signum (xPlaneN-xPlane)*fx*zticklen, |
12684
abfcb5d5641b
Disable mirrored axes ticks for plottyy in ftlk
Konstantinos Poulios <logari81@googlemail.com>
parents:
12446
diff
changeset
|
1299 0., 0., 2, mirror); |
12321
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1300 else |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1301 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
|
1302 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
|
1303 signum (yPlane-yPlaneN)*fy*zticklen, |
12321
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1304 0., 2, false); |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1305 } |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1306 else |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1307 { |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1308 if (xisinf (fx)) |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1309 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
|
1310 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
|
1311 signum (yPlaneN-yPlane)*fy*zticklen, |
12684
abfcb5d5641b
Disable mirrored axes ticks for plottyy in ftlk
Konstantinos Poulios <logari81@googlemail.com>
parents:
12446
diff
changeset
|
1312 0., 2, mirror); |
12321
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 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
|
1315 yPlaneN, yPlane, |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
1316 signum (xPlane-xPlaneN)*fx*zticklen, |
12321
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1317 0., 0., 2, false); |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1318 } |
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 // FIXME: tick texts |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1321 if (zticklabels.numel () > 0) |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1322 { |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1323 int halign = 2; |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1324 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
|
1325 |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1326 if (xySym) |
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 if (xisinf (fy)) |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1329 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
|
1330 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
|
1331 yPlane, 2, halign, valign, wmax, hmax); |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1332 else |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1333 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
|
1334 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
|
1335 2, halign, valign, wmax, hmax); |
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 else |
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 if (xisinf (fx)) |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1340 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
|
1341 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
|
1342 2, halign, valign, wmax, hmax); |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1343 else |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1344 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
|
1345 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
|
1346 yPlaneN, 2, halign, valign, wmax, hmax); |
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 // minor grid lines |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1351 if (do_zminorgrid) |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1352 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
|
1353 xPlane, xPlaneN, yPlane, yPlaneN, 2, true); |
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 // minor tick marks |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1356 if (do_zminortick) |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1357 { |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1358 if (xySym) |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1359 { |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1360 if (xisinf (fy)) |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1361 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
|
1362 yPlane, yPlane, |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
1363 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
|
1364 0., 0., 2, mirror); |
12321
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1365 else |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1366 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
|
1367 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
|
1368 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
|
1369 0., 2, false); |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1370 } |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1371 else |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1372 { |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1373 if (xisinf (fx)) |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1374 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
|
1375 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
|
1376 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
|
1377 0., 2, mirror); |
12321
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1378 else |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1379 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
|
1380 yPlaneN, yPlaneN, |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
1381 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
|
1382 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
|
1383 } |
12321
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1384 } |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1385 |
12334
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12333
diff
changeset
|
1386 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
|
1387 } |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1388 else |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1389 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
|
1390 } |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1391 |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1392 void |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1393 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
|
1394 { |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1395 // Children |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1396 |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1397 Matrix children = props.get_all_children (); |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1398 std::list<graphics_object> obj_list; |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1399 std::list<graphics_object>::iterator it; |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1400 |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1401 // 1st pass: draw light objects |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1402 |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1403 // Start with the last element of the array of child objects to |
18677
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1404 // display them in the order they were added to the array. |
12321
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1405 |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1406 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
|
1407 { |
18677
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1408 graphics_object go = gh_manager::get_object (children(i)); |
12321
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1409 |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1410 if (go.get_properties ().is_visible ()) |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1411 { |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1412 if (go.isa ("light")) |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1413 draw (go); |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1414 else |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1415 obj_list.push_back (go); |
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 } |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1418 |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1419 // 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
|
1420 |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1421 it = obj_list.begin (); |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1422 while (it != obj_list.end ()) |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1423 { |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1424 graphics_object go = (*it); |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1425 |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1426 // 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
|
1427 // to "data" |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1428 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
|
1429 { |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1430 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
|
1431 draw (go); |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1432 |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1433 it = obj_list.erase (it); |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1434 } |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1435 else |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1436 it++; |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1437 } |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1438 |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1439 // 3rd pass: draw remaining objects |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1440 |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1441 glDisable (GL_DEPTH_TEST); |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1442 |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1443 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
|
1444 { |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1445 graphics_object go = (*it); |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1446 |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1447 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
|
1448 draw (go); |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1449 } |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1450 |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1451 glEnable (GL_DEPTH_TEST); |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1452 |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1453 set_clipping (false); |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1454 |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1455 // FIXME: finalize rendering (transparency processing) |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1456 // FIXME: draw zoom box, if needed |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1457 } |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1458 |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1459 void |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1460 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
|
1461 { |
17726
d449f4668b72
Print warning and abort plot if data range > max float (bug #40246)
Rik <rik@octave.org>
parents:
17651
diff
changeset
|
1462 static double floatmax = std::numeric_limits<float>::max (); |
d449f4668b72
Print warning and abort plot if data range > max float (bug #40246)
Rik <rik@octave.org>
parents:
17651
diff
changeset
|
1463 |
12334
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12333
diff
changeset
|
1464 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
|
1465 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
|
1466 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
|
1467 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
|
1468 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
|
1469 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
|
1470 |
17732
dcc88366f94b
Print warning and abort FLTK plot if data values < -maxfloat (bug #40246)
Rik <rik@octave.org>
parents:
17728
diff
changeset
|
1471 if (x_max > floatmax || y_max > floatmax || z_max > floatmax |
dcc88366f94b
Print warning and abort FLTK plot if data values < -maxfloat (bug #40246)
Rik <rik@octave.org>
parents:
17728
diff
changeset
|
1472 || x_min < -floatmax || y_min < -floatmax || z_min < -floatmax) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1473 { |
18682
8c537222f1e5
gl-render.cc: Use class prefix, opengl_renderer or opengl_texture, when printing warning.
Rik <rik@octave.org>
parents:
18677
diff
changeset
|
1474 warning ("opengl_renderer: data values greater than float capacity. (1) Scale data, or (2) Use gnuplot"); |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1475 return; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1476 } |
17726
d449f4668b72
Print warning and abort plot if data range > max float (bug #40246)
Rik <rik@octave.org>
parents:
17651
diff
changeset
|
1477 |
12321
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1478 setup_opengl_transformation (props); |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1479 |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19047
diff
changeset
|
1480 // Disable line smoothing for axes |
18770
be8d7721ac16
Use OpenGL line smoothing when multisample is not available.
Rik <rik@octave.org>
parents:
18769
diff
changeset
|
1481 GLboolean antialias; |
be8d7721ac16
Use OpenGL line smoothing when multisample is not available.
Rik <rik@octave.org>
parents:
18769
diff
changeset
|
1482 glGetBooleanv (GL_LINE_SMOOTH, &antialias); |
be8d7721ac16
Use OpenGL line smoothing when multisample is not available.
Rik <rik@octave.org>
parents:
18769
diff
changeset
|
1483 if (antialias == GL_TRUE) |
be8d7721ac16
Use OpenGL line smoothing when multisample is not available.
Rik <rik@octave.org>
parents:
18769
diff
changeset
|
1484 glDisable (GL_LINE_SMOOTH); |
be8d7721ac16
Use OpenGL line smoothing when multisample is not available.
Rik <rik@octave.org>
parents:
18769
diff
changeset
|
1485 |
12321
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1486 // draw axes object |
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1487 |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12321
diff
changeset
|
1488 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
|
1489 draw_axes_boxes (props); |
7825
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1490 |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
8920
diff
changeset
|
1491 set_font (props); |
20285
6db2ea5556a4
Make use of the axes "ticklabelinterpreter" property (bug #45438)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20232
diff
changeset
|
1492 set_interpreter (props.get_ticklabelinterpreter ()); |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
8920
diff
changeset
|
1493 |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12321
diff
changeset
|
1494 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
|
1495 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
|
1496 draw_axes_z_grid (props); |
7825
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1497 |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1498 set_linestyle ("-"); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1499 |
12334
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12333
diff
changeset
|
1500 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
|
1501 |
18770
be8d7721ac16
Use OpenGL line smoothing when multisample is not available.
Rik <rik@octave.org>
parents:
18769
diff
changeset
|
1502 // Re-enable line smoothing for children |
be8d7721ac16
Use OpenGL line smoothing when multisample is not available.
Rik <rik@octave.org>
parents:
18769
diff
changeset
|
1503 if (antialias == GL_TRUE) |
be8d7721ac16
Use OpenGL line smoothing when multisample is not available.
Rik <rik@octave.org>
parents:
18769
diff
changeset
|
1504 glEnable (GL_LINE_SMOOTH); |
be8d7721ac16
Use OpenGL line smoothing when multisample is not available.
Rik <rik@octave.org>
parents:
18769
diff
changeset
|
1505 |
12321
6ba28900706b
opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents:
12174
diff
changeset
|
1506 draw_axes_children (props); |
7825
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1507 } |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1508 |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1509 void |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9687
diff
changeset
|
1510 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
|
1511 { |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1512 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
|
1513 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
|
1514 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
|
1515 |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1516 bool has_z = (z.numel () > 0); |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1517 int n = static_cast<int> (std::min (std::min (x.numel (), y.numel ()), |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1518 (has_z ? z.numel () |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1519 : std::numeric_limits<int>::max ()))); |
7825
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1520 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
|
1521 |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1522 std::vector<octave_uint8> clip (n); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1523 |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1524 if (has_z) |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1525 for (int i = 0; i < n; i++) |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1526 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
|
1527 else |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1528 { |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1529 double z_mid = (zmin+zmax)/2; |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1530 |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1531 for (int i = 0; i < n; i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1532 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
|
1533 } |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1534 |
20738
f90295782d60
Accept color value of "none" for line objects (bug #44224).
Rik <rik@octave.org>
parents:
20711
diff
changeset
|
1535 if (! props.linestyle_is ("none") && ! props.color_is ("none")) |
7825
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1536 { |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1537 set_color (props.get_color_rgb ()); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1538 set_linestyle (props.get_linestyle (), false); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1539 set_linewidth (props.get_linewidth ()); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1540 |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1541 if (has_z) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1542 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1543 bool flag = false; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1544 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1545 for (int i = 1; i < n; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1546 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1547 if ((clip[i-1] & clip[i]) == clip_ok) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1548 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1549 if (! flag) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1550 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1551 flag = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1552 glBegin (GL_LINE_STRIP); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1553 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
|
1554 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1555 glVertex3d (x(i), y(i), z(i)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1556 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1557 else if (flag) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1558 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1559 flag = false; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1560 glEnd (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1561 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1562 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1563 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1564 if (flag) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1565 glEnd (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1566 } |
7825
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1567 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1568 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1569 bool flag = false; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1570 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1571 for (int i = 1; i < n; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1572 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1573 if ((clip[i-1] & clip[i]) == clip_ok) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1574 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1575 if (! flag) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1576 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1577 flag = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1578 glBegin (GL_LINE_STRIP); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1579 glVertex2d (x(i-1), y(i-1)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1580 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1581 glVertex2d (x(i), y(i)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1582 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1583 else if (flag) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1584 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1585 flag = false; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1586 glEnd (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1587 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1588 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1589 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1590 if (flag) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1591 glEnd (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1592 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11585
diff
changeset
|
1593 |
7825
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1594 set_linewidth (0.5); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1595 set_linestyle ("-"); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1596 } |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1597 |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1598 set_clipping (false); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1599 |
19864
17d647821d61
maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
1600 if (! props.marker_is ("none") |
17d647821d61
maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
1601 && ! (props.markeredgecolor_is ("none") |
17d647821d61
maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
1602 && props.markerfacecolor_is ("none"))) |
7825
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1603 { |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1604 Matrix lc, fc; |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1605 |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1606 if (props.markeredgecolor_is ("auto")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1607 lc = props.get_color_rgb (); |
7825
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1608 else if (! props.markeredgecolor_is ("none")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1609 lc = props.get_markeredgecolor_rgb (); |
7825
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1610 |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1611 if (props.markerfacecolor_is ("auto")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1612 fc = props.get_color_rgb (); |
7825
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1613 else if (! props.markerfacecolor_is ("none")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1614 fc = props.get_markerfacecolor_rgb (); |
7825
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1615 |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1616 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
|
1617 props.get_linewidth ()); |
7825
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1618 |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1619 for (int i = 0; i < n; i++) |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1620 { |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1621 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
|
1622 draw_marker (x(i), y(i), |
18658
75ec138ba53b
Fix Z-order stacking of line markers and other graphic objects (bug #40054).
Rik <rik@octave.org>
parents:
18296
diff
changeset
|
1623 has_z ? z(i) : 0.0, |
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
|
1624 lc, fc); |
7825
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1625 } |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1626 |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1627 end_marker (); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1628 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11585
diff
changeset
|
1629 |
7825
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1630 set_clipping (props.is_clipping ()); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1631 } |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1632 |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1633 void |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9687
diff
changeset
|
1634 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
|
1635 { |
9681 | 1636 const Matrix x = xform.xscale (props.get_xdata ().matrix_value ()); |
1637 const Matrix y = xform.yscale (props.get_ydata ().matrix_value ()); | |
1638 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
|
1639 |
18100
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
1640 int zr = z.rows (); |
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
1641 int zc = z.columns (); |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
1642 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
1643 NDArray c; |
9681 | 1644 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
|
1645 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
1646 // FIXME: handle transparency |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
1647 Matrix a; |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
1648 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
1649 if (props.facelighting_is ("phong") || props.edgelighting_is ("phong")) |
18682
8c537222f1e5
gl-render.cc: Use class prefix, opengl_renderer or opengl_texture, when printing warning.
Rik <rik@octave.org>
parents:
18677
diff
changeset
|
1650 warning ("opengl_renderer: phong light model not supported"); |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
1651 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
1652 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
|
1653 (props.facecolor_is ("flat") ? 1 : |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1654 (props.facecolor_is ("interp") ? 2 : |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1655 (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
|
1656 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
|
1657 (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
|
1658 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
|
1659 (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
|
1660 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
|
1661 (props.edgecolor_is ("flat") ? 1 : |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1662 (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
|
1663 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
|
1664 (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
|
1665 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
|
1666 (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
|
1667 |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
1668 Matrix fcolor = (fc_mode == TEXTURE ? Matrix (1, 3, 1.0) |
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
1669 : props.get_facecolor_rgb ()); |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
1670 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
|
1671 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
1672 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
|
1673 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
|
1674 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
|
1675 float se = props.get_specularexponent (); |
8674
0d263850d582
Fix calculation of diffuse reflectance. Calculate surface normals here now.
Kai Habel
parents:
8377
diff
changeset
|
1676 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
|
1677 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
|
1678 |
7831
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
1679 opengl_texture tex; |
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
1680 |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
1681 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
|
1682 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
|
1683 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
|
1684 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
1685 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
|
1686 |
17558
e48a22b94727
Don't plot NaN values in cdata (bug #40114).
Rik <rik@octave.org>
parents:
17269
diff
changeset
|
1687 if ((fc_mode > 0 && fc_mode < 3) || ec_mode > 0) |
e48a22b94727
Don't plot NaN values in cdata (bug #40114).
Rik <rik@octave.org>
parents:
17269
diff
changeset
|
1688 c = props.get_color_data ().array_value (); |
e48a22b94727
Don't plot NaN values in cdata (bug #40114).
Rik <rik@octave.org>
parents:
17269
diff
changeset
|
1689 |
7831
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
1690 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
|
1691 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
1692 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
|
1693 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
1694 if (x_mat) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1695 i1 = i; |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
1696 |
7831
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
1697 for (int j = 0; j < zc; j++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1698 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1699 if (y_mat) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1700 j1 = j; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1701 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1702 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
|
1703 } |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
1704 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
1705 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
1706 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
|
1707 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
1708 // FIXME: implement alphadata conversion |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
1709 //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
|
1710 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
1711 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
1712 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
|
1713 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
1714 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
|
1715 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
1716 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
|
1717 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
|
1718 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
1719 |
18677
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1720 // FIXME: good candidate for caching, |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
1721 // transferring pixel data to OpenGL is time consuming. |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
1722 if (fc_mode == TEXTURE) |
7831
c7925666f0bf
Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
1723 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
|
1724 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
1725 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
|
1726 { |
7846
d7737a4268b7
Fix typos in property names (edgealpha/facealpha).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7838
diff
changeset
|
1727 if (props.get_facealpha_double () == 1) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1728 { |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
1729 if (fc_mode == UNIFORM || fc_mode == TEXTURE) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1730 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1731 glColor3dv (fcolor.data ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1732 if (fl_mode > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1733 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1734 for (int i = 0; i < 3; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1735 cb[i] = as * fcolor(i); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1736 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb); |
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 for (int i = 0; i < 3; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1739 cb[i] = ds * fcolor(i); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1740 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1741 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1742 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1743 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1744 if (fl_mode > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1745 glEnable (GL_LIGHTING); |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
1746 glShadeModel ((fc_mode == INTERP || fl_mode == GOURAUD) ? GL_SMOOTH |
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
1747 : GL_FLAT); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1748 set_polygon_offset (true, 1); |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
1749 if (fc_mode == TEXTURE) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1750 glEnable (GL_TEXTURE_2D); |
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 i = 1; i < zc; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1753 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1754 if (y_mat) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1755 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1756 i1 = i-1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1757 i2 = i; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1758 } |
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 for (int j = 1; j < zr; j++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1761 { |
17589
c3aadd228c37
Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents:
17558
diff
changeset
|
1762 |
c3aadd228c37
Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents:
17558
diff
changeset
|
1763 if (clip(j-1, i-1) || clip(j, i-1) |
c3aadd228c37
Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents:
17558
diff
changeset
|
1764 || clip(j-1, i) || clip(j, i)) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1765 continue; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1766 |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
1767 if (fc_mode == FLAT) |
17589
c3aadd228c37
Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents:
17558
diff
changeset
|
1768 { |
c3aadd228c37
Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents:
17558
diff
changeset
|
1769 // "flat" only needs color at lower-left vertex |
c3aadd228c37
Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents:
17558
diff
changeset
|
1770 if (! xfinite (c(j-1,i-1))) |
c3aadd228c37
Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents:
17558
diff
changeset
|
1771 continue; |
c3aadd228c37
Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents:
17558
diff
changeset
|
1772 } |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
1773 else if (fc_mode == INTERP) |
17589
c3aadd228c37
Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents:
17558
diff
changeset
|
1774 { |
c3aadd228c37
Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents:
17558
diff
changeset
|
1775 // "interp" needs valid color at all 4 vertices |
c3aadd228c37
Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents:
17558
diff
changeset
|
1776 if (! (xfinite (c(j-1, i-1)) && xfinite (c(j, i-1)) |
c3aadd228c37
Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents:
17558
diff
changeset
|
1777 && xfinite (c(j-1, i)) && xfinite (c(j, i)))) |
c3aadd228c37
Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents:
17558
diff
changeset
|
1778 continue; |
c3aadd228c37
Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents:
17558
diff
changeset
|
1779 } |
c3aadd228c37
Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents:
17558
diff
changeset
|
1780 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1781 if (x_mat) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1782 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1783 j1 = j-1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1784 j2 = j; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1785 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1786 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1787 glBegin (GL_QUADS); |
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 // Vertex 1 |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
1790 if (fc_mode == TEXTURE) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1791 tex.tex_coord (double (i-1) / (zc-1), |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1792 double (j-1) / (zr-1)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1793 else if (fc_mode > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1794 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1795 // 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
|
1796 for (int k = 0; k < 3; k++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1797 cb[k] = c(j-1, i-1, k); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1798 glColor3fv (cb); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1799 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1800 if (fl_mode > 0) |
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 for (int k = 0; k < 3; k++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1803 cb[k] *= as; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1804 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11585
diff
changeset
|
1805 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1806 for (int k = 0; k < 3; k++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1807 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
|
1808 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1809 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1810 } |
8674
0d263850d582
Fix calculation of diffuse reflectance. Calculate surface normals here now.
Kai Habel
parents:
8377
diff
changeset
|
1811 if (fl_mode > 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1812 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1813 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
|
1814 + 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
|
1815 + n(j-1,i-1,2) * n(j-1,i-1,2)); |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1816 glNormal3d (n(j-1,i-1,0)/d, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1817 n(j-1,i-1,1)/d, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1818 n(j-1,i-1,2)/d); |
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 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
|
1821 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1822 // Vertex 2 |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
1823 if (fc_mode == TEXTURE) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1824 tex.tex_coord (double (i) / (zc-1), double (j-1) / (zr-1)); |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
1825 else if (fc_mode == INTERP) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1826 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1827 for (int k = 0; k < 3; k++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1828 cb[k] = c(j-1, i, k); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1829 glColor3fv (cb); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1830 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1831 if (fl_mode > 0) |
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 for (int k = 0; k < 3; k++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1834 cb[k] *= as; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1835 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11585
diff
changeset
|
1836 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1837 for (int k = 0; k < 3; k++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1838 cb[k] = ds * c(j-1, i, k); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1839 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1840 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1841 } |
8674
0d263850d582
Fix calculation of diffuse reflectance. Calculate surface normals here now.
Kai Habel
parents:
8377
diff
changeset
|
1842 |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
1843 if (fl_mode == GOURAUD) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1844 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1845 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
|
1846 + 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
|
1847 + 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
|
1848 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
|
1849 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1850 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1851 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
|
1852 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1853 // Vertex 3 |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
1854 if (fc_mode == TEXTURE) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1855 tex.tex_coord (double (i) / (zc-1), double (j) / (zr-1)); |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
1856 else if (fc_mode == INTERP) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1857 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1858 for (int k = 0; k < 3; k++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1859 cb[k] = c(j, i, k); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1860 glColor3fv (cb); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1861 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1862 if (fl_mode > 0) |
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 for (int k = 0; k < 3; k++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1865 cb[k] *= as; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1866 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11585
diff
changeset
|
1867 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1868 for (int k = 0; k < 3; k++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1869 cb[k] = ds * c(j, i, k); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1870 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1871 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1872 } |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
1873 if (fl_mode == GOURAUD) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1874 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1875 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
|
1876 + n(j,i,1) * n(j,i,1) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1877 + n(j,i,2) * n(j,i,2)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1878 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
|
1879 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1880 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
|
1881 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1882 // Vertex 4 |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
1883 if (fc_mode == TEXTURE) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1884 tex.tex_coord (double (i-1) / (zc-1), double (j) / (zr-1)); |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
1885 else if (fc_mode == INTERP) |
10315
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 for (int k = 0; k < 3; k++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1888 cb[k] = c(j, i-1, k); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1889 glColor3fv (cb); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1890 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1891 if (fl_mode > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1892 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1893 for (int k = 0; k < 3; k++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1894 cb[k] *= as; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1895 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11585
diff
changeset
|
1896 |
10315
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] = ds * c(j, i-1, k); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1899 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, 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 } |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
1902 if (fl_mode == GOURAUD) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1903 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1904 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
|
1905 + 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
|
1906 + 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
|
1907 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
|
1908 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1909 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
|
1910 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1911 glEnd (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1912 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1913 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1914 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1915 set_polygon_offset (false); |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
1916 if (fc_mode == TEXTURE) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1917 glDisable (GL_TEXTURE_2D); |
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 if (fl_mode > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1920 glDisable (GL_LIGHTING); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1921 } |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
1922 else |
10315
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 // FIXME: implement transparency |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1925 } |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
1926 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
1927 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
1928 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
|
1929 { |
7846
d7737a4268b7
Fix typos in property names (edgealpha/facealpha).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7838
diff
changeset
|
1930 if (props.get_edgealpha_double () == 1) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1931 { |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
1932 if (ec_mode == UNIFORM) |
10315
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 glColor3dv (ecolor.data ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1935 if (fl_mode > 0) |
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 for (int i = 0; i < 3; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1938 cb[i] = as * ecolor(i); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1939 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1940 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1941 for (int i = 0; i < 3; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1942 cb[i] = ds * ecolor(i); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1943 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb); |
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 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1946 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1947 if (el_mode > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1948 glEnable (GL_LIGHTING); |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
1949 glShadeModel ((ec_mode == INTERP || el_mode == GOURAUD) ? GL_SMOOTH |
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
1950 : GL_FLAT); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1951 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1952 set_linestyle (props.get_linestyle (), false); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1953 set_linewidth (props.get_linewidth ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1954 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1955 // Mesh along Y-axis |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1956 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1957 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
|
1958 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1959 for (int i = 0; i < zc; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1960 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1961 if (y_mat) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1962 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1963 i1 = i-1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1964 i2 = i; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1965 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1966 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1967 for (int j = 1; j < zr; j++) |
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 (clip(j-1,i) || clip(j,i)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1970 continue; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1971 |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
1972 if (ec_mode == FLAT) |
17589
c3aadd228c37
Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents:
17558
diff
changeset
|
1973 { |
c3aadd228c37
Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents:
17558
diff
changeset
|
1974 // "flat" only needs color at lower-left vertex |
c3aadd228c37
Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents:
17558
diff
changeset
|
1975 if (! xfinite (c(j-1,i))) |
c3aadd228c37
Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents:
17558
diff
changeset
|
1976 continue; |
c3aadd228c37
Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents:
17558
diff
changeset
|
1977 } |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
1978 else if (ec_mode == INTERP) |
17589
c3aadd228c37
Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents:
17558
diff
changeset
|
1979 { |
c3aadd228c37
Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents:
17558
diff
changeset
|
1980 // "interp" needs valid color at both vertices |
c3aadd228c37
Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents:
17558
diff
changeset
|
1981 if (! (xfinite (c(j-1, i)) && xfinite (c(j, i)))) |
c3aadd228c37
Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents:
17558
diff
changeset
|
1982 continue; |
c3aadd228c37
Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents:
17558
diff
changeset
|
1983 } |
c3aadd228c37
Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents:
17558
diff
changeset
|
1984 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1985 if (x_mat) |
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 j1 = j-1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1988 j2 = j; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1989 } |
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 glBegin (GL_LINES); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1992 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1993 // Vertex 1 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1994 if (ec_mode > 0) |
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 for (int k = 0; k < 3; k++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1997 cb[k] = c(j-1, i, k); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1998 glColor3fv (cb); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
1999 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2000 if (fl_mode > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2001 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2002 for (int k = 0; k < 3; k++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2003 cb[k] *= as; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2004 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2005 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2006 for (int k = 0; k < 3; k++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2007 cb[k] = ds * c(j-1, i, k); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2008 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb); |
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 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2011 if (el_mode > 0) |
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 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
|
2014 + 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
|
2015 + 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
|
2016 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
|
2017 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2018 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
|
2019 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2020 // Vertex 2 |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
2021 if (ec_mode == INTERP) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2022 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2023 for (int k = 0; k < 3; k++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2024 cb[k] = c(j, i, k); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2025 glColor3fv (cb); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2026 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2027 if (fl_mode > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2028 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2029 for (int k = 0; k < 3; k++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2030 cb[k] *= as; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2031 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2032 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2033 for (int k = 0; k < 3; k++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2034 cb[k] = ds * c(j, i, k); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2035 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2036 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2037 } |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
2038 if (el_mode == GOURAUD) |
8674
0d263850d582
Fix calculation of diffuse reflectance. Calculate surface normals here now.
Kai Habel
parents:
8377
diff
changeset
|
2039 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2040 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
|
2041 + n(j,i,1) * n(j,i,1) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2042 + n(j,i,2) * n(j,i,2)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2043 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
|
2044 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2045 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
|
2046 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2047 glEnd (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2048 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2049 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2050 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2051 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2052 // Mesh along X-axis |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2053 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2054 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
|
2055 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2056 for (int j = 0; j < zr; j++) |
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 (x_mat) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2059 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2060 j1 = j-1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2061 j2 = 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 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2064 for (int i = 1; i < zc; i++) |
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 (clip(j,i-1) || clip(j,i)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2067 continue; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2068 |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
2069 if (ec_mode == FLAT) |
17589
c3aadd228c37
Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents:
17558
diff
changeset
|
2070 { |
c3aadd228c37
Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents:
17558
diff
changeset
|
2071 // "flat" only needs color at lower-left vertex |
c3aadd228c37
Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents:
17558
diff
changeset
|
2072 if (! xfinite (c(j,i-1))) |
c3aadd228c37
Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents:
17558
diff
changeset
|
2073 continue; |
c3aadd228c37
Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents:
17558
diff
changeset
|
2074 } |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
2075 else if (ec_mode == INTERP) |
17589
c3aadd228c37
Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents:
17558
diff
changeset
|
2076 { |
c3aadd228c37
Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents:
17558
diff
changeset
|
2077 // "interp" needs valid color at both vertices |
c3aadd228c37
Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents:
17558
diff
changeset
|
2078 if (! (xfinite (c(j, i-1)) && xfinite (c(j, i)))) |
c3aadd228c37
Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents:
17558
diff
changeset
|
2079 continue; |
c3aadd228c37
Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents:
17558
diff
changeset
|
2080 } |
c3aadd228c37
Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents:
17558
diff
changeset
|
2081 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2082 if (y_mat) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2083 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2084 i1 = i-1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2085 i2 = i; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2086 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2087 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2088 glBegin (GL_LINES); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2089 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2090 // Vertex 1 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2091 if (ec_mode > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2092 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2093 for (int k = 0; k < 3; k++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2094 cb[k] = c(j, i-1, k); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2095 glColor3fv (cb); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2096 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2097 if (fl_mode > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2098 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2099 for (int k = 0; k < 3; k++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2100 cb[k] *= as; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2101 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2102 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2103 for (int k = 0; k < 3; k++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2104 cb[k] = ds * c(j, i-1, k); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2105 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2106 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2107 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2108 if (el_mode > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2109 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2110 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
|
2111 + 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
|
2112 + 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
|
2113 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
|
2114 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2115 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
|
2116 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2117 // Vertex 2 |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
2118 if (ec_mode == INTERP) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2119 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2120 for (int k = 0; k < 3; k++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2121 cb[k] = c(j, i, k); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2122 glColor3fv (cb); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2123 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2124 if (fl_mode > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2125 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2126 for (int k = 0; k < 3; k++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2127 cb[k] *= as; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2128 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2129 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2130 for (int k = 0; k < 3; k++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2131 cb[k] = ds * c(j, i, k); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2132 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2133 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2134 } |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
2135 if (el_mode == GOURAUD) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2136 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2137 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
|
2138 + n(j,i,1) * n(j,i,1) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2139 + n(j,i,2) * n(j,i,2)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2140 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
|
2141 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2142 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
|
2143 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2144 glEnd (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2145 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2146 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2147 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2148 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2149 set_linestyle ("-"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2150 set_linewidth (0.5); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2151 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2152 if (el_mode > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2153 glDisable (GL_LIGHTING); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2154 } |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
2155 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2156 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2157 // FIXME: implement transparency |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2158 } |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
2159 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
2160 |
19864
17d647821d61
maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
2161 if (! props.marker_is ("none") |
17d647821d61
maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
2162 && ! (props.markeredgecolor_is ("none") |
17d647821d61
maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
2163 && 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
|
2164 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
2165 // 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
|
2166 // 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
|
2167 // 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
|
2168 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
2169 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
|
2170 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
|
2171 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
2172 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
|
2173 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
|
2174 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
|
2175 |
20974
1edf15793cac
maint: Use is_empty rather than "numel () == 0" for clarity.
Rik <rik@octave.org>
parents:
20955
diff
changeset
|
2176 if (mecolor.is_empty () && props.markeredgecolor_is ("auto")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2177 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2178 mecolor = props.get_edgecolor_rgb (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2179 do_edge = ! props.edgecolor_is ("none"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2180 } |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
2181 |
20974
1edf15793cac
maint: Use is_empty rather than "numel () == 0" for clarity.
Rik <rik@octave.org>
parents:
20955
diff
changeset
|
2182 if (mfcolor.is_empty () && props.markerfacecolor_is ("auto")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2183 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2184 mfcolor = props.get_facecolor_rgb (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2185 do_face = ! props.facecolor_is ("none"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2186 } |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
2187 |
20974
1edf15793cac
maint: Use is_empty rather than "numel () == 0" for clarity.
Rik <rik@octave.org>
parents:
20955
diff
changeset
|
2188 if ((mecolor.is_empty () || mfcolor.is_empty ()) && c.is_empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2189 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
|
2190 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
2191 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
|
2192 props.get_linewidth ()); |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
2193 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
2194 for (int i = 0; i < zc; i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2195 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2196 if (y_mat) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2197 i1 = i; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11585
diff
changeset
|
2198 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2199 for (int j = 0; j < zr; j++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2200 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2201 if (clip(j,i)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2202 continue; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2203 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2204 if (x_mat) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2205 j1 = j; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2206 |
20974
1edf15793cac
maint: Use is_empty rather than "numel () == 0" for clarity.
Rik <rik@octave.org>
parents:
20955
diff
changeset
|
2207 if ((do_edge && mecolor.is_empty ()) |
1edf15793cac
maint: Use is_empty rather than "numel () == 0" for clarity.
Rik <rik@octave.org>
parents:
20955
diff
changeset
|
2208 || (do_face && mfcolor.is_empty ())) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2209 { |
17589
c3aadd228c37
Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents:
17558
diff
changeset
|
2210 if (! xfinite (c(j,i))) |
c3aadd228c37
Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents:
17558
diff
changeset
|
2211 continue; // Skip NaNs in color data |
c3aadd228c37
Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents:
17558
diff
changeset
|
2212 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2213 for (int k = 0; k < 3; k++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2214 cc(k) = c(j,i,k); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2215 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2216 |
20974
1edf15793cac
maint: Use is_empty rather than "numel () == 0" for clarity.
Rik <rik@octave.org>
parents:
20955
diff
changeset
|
2217 Matrix lc = (do_edge ? (mecolor.is_empty () ? cc : mecolor) |
17589
c3aadd228c37
Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents:
17558
diff
changeset
|
2218 : Matrix ()); |
20974
1edf15793cac
maint: Use is_empty rather than "numel () == 0" for clarity.
Rik <rik@octave.org>
parents:
20955
diff
changeset
|
2219 Matrix fc = (do_face ? (mfcolor.is_empty () ? cc : mfcolor) |
17589
c3aadd228c37
Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents:
17558
diff
changeset
|
2220 : Matrix ()); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2221 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2222 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
|
2223 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2224 } |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
2225 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
2226 end_marker (); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
2227 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
2228 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
2229 |
18677
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
2230 // FIXME: global optimization (rendering, data structures...), |
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
2231 // there is probably a smarter/faster/less-memory-consuming way to do this. |
7833
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
2232 void |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9687
diff
changeset
|
2233 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
|
2234 { |
18901
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18817
diff
changeset
|
2235 // Do not render if the patch has incoherent data |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18817
diff
changeset
|
2236 std::string msg; |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18817
diff
changeset
|
2237 if (props.has_bad_data (msg)) |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18817
diff
changeset
|
2238 { |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18817
diff
changeset
|
2239 warning ("opengl_renderer: %s. Not rendering.", msg.c_str ()); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18817
diff
changeset
|
2240 return; |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18817
diff
changeset
|
2241 } |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18817
diff
changeset
|
2242 |
9681 | 2243 const Matrix f = props.get_faces ().matrix_value (); |
2244 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
|
2245 Matrix c; |
9681 | 2246 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
|
2247 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
|
2248 |
7870 | 2249 int nv = v.rows (); |
2250 int nf = f.rows (); | |
2251 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
|
2252 |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
2253 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
|
2254 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
|
2255 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
|
2256 |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
2257 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
|
2258 || 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
|
2259 (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
|
2260 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
|
2261 (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
|
2262 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
|
2263 (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
|
2264 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
|
2265 || 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
|
2266 (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
|
2267 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
|
2268 (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
|
2269 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
|
2270 (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
|
2271 |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
2272 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
|
2273 Matrix ecolor = props.get_edgecolor_rgb (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11585
diff
changeset
|
2274 |
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
|
2275 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
|
2276 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
|
2277 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
|
2278 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
|
2279 |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
2280 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
|
2281 |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
2282 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
|
2283 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
|
2284 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
|
2285 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
|
2286 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
|
2287 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
|
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 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
|
2290 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
|
2291 |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
2292 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
|
2293 { |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
2294 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
|
2295 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
|
2296 |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
2297 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
|
2298 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
|
2299 |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
2300 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
|
2301 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
|
2302 } |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
2303 |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
2304 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
|
2305 { |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
2306 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
|
2307 |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
2308 if (c.rows () == 1) |
10315
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 // 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
|
2311 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2312 if (fc_mode > 0) |
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 fcolor = c; |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
2315 fc_mode = UNIFORM; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2316 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2317 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2318 if (ec_mode > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2319 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2320 ecolor = c; |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
2321 ec_mode = UNIFORM; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2322 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2323 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2324 c = Matrix (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2325 } |
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
|
2326 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2327 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
|
2328 } |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
2329 |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
2330 if (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
|
2331 { |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
2332 // 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
|
2333 //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
|
2334 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
|
2335 } |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
2336 |
7924 | 2337 octave_idx_type fr = f.rows (); |
7914
e998e81224b5
Various compilation fixes for MSVC.
John W. Eaton <jwe@octave.org>
parents:
7907
diff
changeset
|
2338 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
|
2339 |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
2340 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
|
2341 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
|
2342 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2343 int idx = int (f(i,j) - 1); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2344 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2345 Matrix vv (1, 3, 0.0); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2346 Matrix cc; |
18702
8969bd721448
Fix Z-depth issues of patches and lines in 2-D plots (bug #40722).
Rik <rik@octave.org>
parents:
18683
diff
changeset
|
2347 Matrix nn (1, 3, 0.0); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2348 double aa = 1.0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2349 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2350 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
|
2351 if (has_z) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2352 vv(2) = v(idx,2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2353 // FIXME: uncomment when patch object has normal computation |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2354 //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
|
2355 if (c.numel () > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2356 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2357 cc.resize (1, 3); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2358 if (has_facecolor) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2359 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
|
2360 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2361 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
|
2362 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2363 if (a.numel () > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2364 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2365 if (has_facealpha) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2366 aa = a(i); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2367 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2368 aa = a(idx); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2369 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2370 |
18677
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
2371 vdata[i+j*fr] = 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
|
2372 } |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
2373 |
8ff92634982d
Add initial 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 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
|
2375 { |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
2376 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
|
2377 |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
2378 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
|
2379 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
|
2380 } |
8ff92634982d
Add initial 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 |
8ff92634982d
Add initial 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 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
|
2383 { |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
2384 // 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
|
2385 if (props.get_facealpha_double () == 1) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2386 { |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
2387 if (fc_mode == UNIFORM) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2388 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2389 glColor3dv (fcolor.data ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2390 if (fl_mode > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2391 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2392 float cb[4] = { 0, 0, 0, 1 }; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2393 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2394 for (int i = 0; i < 3; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2395 cb[i] = (as * fcolor(i)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2396 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2397 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2398 for (int i = 0; i < 3; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2399 cb[i] = ds * fcolor(i); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2400 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2401 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2402 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2403 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2404 if (fl_mode > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2405 glEnable (GL_LIGHTING); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2406 |
18768
75f8926deef1
Fix Z-order stacking of patches and axes grid lines (bug #40722).
Rik <rik@octave.org>
parents:
18720
diff
changeset
|
2407 // NOTE: Push filled part of patch backwards to avoid Z-fighting with |
75f8926deef1
Fix Z-order stacking of patches and axes grid lines (bug #40722).
Rik <rik@octave.org>
parents:
18720
diff
changeset
|
2408 // tesselator outline. A value of 1.0 seems to work fine. Value |
75f8926deef1
Fix Z-order stacking of patches and axes grid lines (bug #40722).
Rik <rik@octave.org>
parents:
18720
diff
changeset
|
2409 // can't be too large or the patch will be pushed below the axes |
75f8926deef1
Fix Z-order stacking of patches and axes grid lines (bug #40722).
Rik <rik@octave.org>
parents:
18720
diff
changeset
|
2410 // planes at +2.5. |
75f8926deef1
Fix Z-order stacking of patches and axes grid lines (bug #40722).
Rik <rik@octave.org>
parents:
18720
diff
changeset
|
2411 patch_tesselator tess (this, fc_mode, fl_mode, 1.0); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2412 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2413 for (int i = 0; i < nf; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2414 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2415 if (clip_f(i)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2416 continue; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2417 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2418 tess.begin_polygon (true); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2419 tess.begin_contour (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2420 |
18295
2ed9498e4a74
Change diagonal of FaceColor interpolation for patch objects to match Matlab.
Rik <rik@octave.org>
parents:
18134
diff
changeset
|
2421 // Add vertices in reverse order for Matlab compatibility |
2ed9498e4a74
Change diagonal of FaceColor interpolation for patch objects to match Matlab.
Rik <rik@octave.org>
parents:
18134
diff
changeset
|
2422 for (int j = count_f(i)-1; j > 0; j--) |
2ed9498e4a74
Change diagonal of FaceColor interpolation for patch objects to match Matlab.
Rik <rik@octave.org>
parents:
18134
diff
changeset
|
2423 { |
2ed9498e4a74
Change diagonal of FaceColor interpolation for patch objects to match Matlab.
Rik <rik@octave.org>
parents:
18134
diff
changeset
|
2424 vertex_data::vertex_data_rep *vv = vdata[i+j*fr].get_rep (); |
2ed9498e4a74
Change diagonal of FaceColor interpolation for patch objects to match Matlab.
Rik <rik@octave.org>
parents:
18134
diff
changeset
|
2425 |
2ed9498e4a74
Change diagonal of FaceColor interpolation for patch objects to match Matlab.
Rik <rik@octave.org>
parents:
18134
diff
changeset
|
2426 tess.add_vertex (vv->coords.fortran_vec (), vv); |
2ed9498e4a74
Change diagonal of FaceColor interpolation for patch objects to match Matlab.
Rik <rik@octave.org>
parents:
18134
diff
changeset
|
2427 } |
2ed9498e4a74
Change diagonal of FaceColor interpolation for patch objects to match Matlab.
Rik <rik@octave.org>
parents:
18134
diff
changeset
|
2428 |
18134
647d806868ee
Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents:
18100
diff
changeset
|
2429 if (count_f(i) > 0) |
647d806868ee
Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents:
18100
diff
changeset
|
2430 { |
647d806868ee
Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents:
18100
diff
changeset
|
2431 vertex_data::vertex_data_rep *vv = vdata[i].get_rep (); |
647d806868ee
Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents:
18100
diff
changeset
|
2432 |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
2433 if (fc_mode == FLAT) |
18134
647d806868ee
Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents:
18100
diff
changeset
|
2434 { |
647d806868ee
Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents:
18100
diff
changeset
|
2435 // For "flat" shading, use color of 1st vertex. |
647d806868ee
Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents:
18100
diff
changeset
|
2436 Matrix col = vv->color; |
647d806868ee
Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents:
18100
diff
changeset
|
2437 |
647d806868ee
Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents:
18100
diff
changeset
|
2438 if (col.numel () == 3) |
647d806868ee
Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents:
18100
diff
changeset
|
2439 { |
647d806868ee
Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents:
18100
diff
changeset
|
2440 glColor3dv (col.data ()); |
647d806868ee
Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents:
18100
diff
changeset
|
2441 if (fl_mode > 0) |
647d806868ee
Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents:
18100
diff
changeset
|
2442 { |
647d806868ee
Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents:
18100
diff
changeset
|
2443 float cb[4] = { 0, 0, 0, 1 }; |
647d806868ee
Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents:
18100
diff
changeset
|
2444 |
647d806868ee
Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents:
18100
diff
changeset
|
2445 for (int k = 0; k < 3; k++) |
647d806868ee
Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents:
18100
diff
changeset
|
2446 cb[k] = (vv->ambient * col(k)); |
647d806868ee
Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents:
18100
diff
changeset
|
2447 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb); |
647d806868ee
Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents:
18100
diff
changeset
|
2448 |
647d806868ee
Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents:
18100
diff
changeset
|
2449 for (int k = 0; k < 3; k++) |
647d806868ee
Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents:
18100
diff
changeset
|
2450 cb[k] = (vv->diffuse * col(k)); |
647d806868ee
Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents:
18100
diff
changeset
|
2451 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb); |
647d806868ee
Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents:
18100
diff
changeset
|
2452 } |
647d806868ee
Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents:
18100
diff
changeset
|
2453 } |
647d806868ee
Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents:
18100
diff
changeset
|
2454 } |
647d806868ee
Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents:
18100
diff
changeset
|
2455 |
647d806868ee
Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents:
18100
diff
changeset
|
2456 tess.add_vertex (vv->coords.fortran_vec (), vv); |
647d806868ee
Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents:
18100
diff
changeset
|
2457 } |
647d806868ee
Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents:
18100
diff
changeset
|
2458 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2459 tess.end_contour (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2460 tess.end_polygon (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2461 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2462 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2463 if (fl_mode > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2464 glDisable (GL_LIGHTING); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2465 } |
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
|
2466 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2467 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2468 // FIXME: implement transparency |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2469 } |
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
|
2470 } |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
2471 |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
2472 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
|
2473 { |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
2474 // 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
|
2475 if (props.get_edgealpha_double () == 1) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2476 { |
18771
79f69742971a
gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents:
18770
diff
changeset
|
2477 if (ec_mode == UNIFORM) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2478 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2479 glColor3dv (ecolor.data ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2480 if (el_mode > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2481 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2482 float cb[4] = { 0, 0, 0, 1 }; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2483 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2484 for (int i = 0; i < 3; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2485 cb[i] = (as * ecolor(i)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2486 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2487 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2488 for (int i = 0; i < 3; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2489 cb[i] = ds * ecolor(i); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2490 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2491 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2492 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2493 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2494 if (el_mode > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2495 glEnable (GL_LIGHTING); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2496 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2497 set_linestyle (props.get_linestyle (), false); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2498 set_linewidth (props.get_linewidth ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2499 |
18768
75f8926deef1
Fix Z-order stacking of patches and axes grid lines (bug #40722).
Rik <rik@octave.org>
parents:
18720
diff
changeset
|
2500 // NOTE: patch contour cannot be offset. Offset must occur with the |
75f8926deef1
Fix Z-order stacking of patches and axes grid lines (bug #40722).
Rik <rik@octave.org>
parents:
18720
diff
changeset
|
2501 // filled portion of the patch above. The tesselator uses |
75f8926deef1
Fix Z-order stacking of patches and axes grid lines (bug #40722).
Rik <rik@octave.org>
parents:
18720
diff
changeset
|
2502 // GLU_TESS_BOUNDARY_ONLY to get the outline of the patch and OpenGL |
75f8926deef1
Fix Z-order stacking of patches and axes grid lines (bug #40722).
Rik <rik@octave.org>
parents:
18720
diff
changeset
|
2503 // automatically sets the glType to GL_LINE_LOOP. This primitive is |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19047
diff
changeset
|
2504 // not supported by glPolygonOffset which is used to do Z offsets. |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2505 patch_tesselator tess (this, ec_mode, el_mode); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2506 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2507 for (int i = 0; i < nf; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2508 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2509 if (clip_f(i)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2510 { |
18817
096b1a159d1f
Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents:
18771
diff
changeset
|
2511 // This is an unclosed contour. Draw it as a line. |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2512 bool flag = false; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2513 |
18817
096b1a159d1f
Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents:
18771
diff
changeset
|
2514 glShadeModel ((ec_mode == INTERP || el_mode == GOURAUD) |
096b1a159d1f
Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents:
18771
diff
changeset
|
2515 ? GL_SMOOTH : GL_FLAT); |
096b1a159d1f
Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents:
18771
diff
changeset
|
2516 |
096b1a159d1f
Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents:
18771
diff
changeset
|
2517 // Add vertices in reverse order for Matlab compatibility |
096b1a159d1f
Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents:
18771
diff
changeset
|
2518 for (int j = count_f(i)-1; j >= 0; j--) |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2519 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2520 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
|
2521 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2522 vertex_data::vertex_data_rep *vv |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2523 = vdata[i+j*fr].get_rep (); |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2524 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
|
2525 if (! flag) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2526 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2527 flag = true; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2528 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
|
2529 } |
18817
096b1a159d1f
Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents:
18771
diff
changeset
|
2530 if (ec_mode != UNIFORM) |
096b1a159d1f
Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents:
18771
diff
changeset
|
2531 { |
096b1a159d1f
Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents:
18771
diff
changeset
|
2532 Matrix col = vv->color; |
096b1a159d1f
Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents:
18771
diff
changeset
|
2533 |
096b1a159d1f
Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents:
18771
diff
changeset
|
2534 if (col.numel () == 3) |
096b1a159d1f
Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents:
18771
diff
changeset
|
2535 glColor3dv (col.data ()); |
096b1a159d1f
Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents:
18771
diff
changeset
|
2536 } |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2537 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
|
2538 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2539 else if (flag) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2540 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2541 flag = false; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2542 glEnd (); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2543 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2544 } |
18817
096b1a159d1f
Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents:
18771
diff
changeset
|
2545 // Do loop body with vertex N to "close" GL_LINE_STRIP |
096b1a159d1f
Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents:
18771
diff
changeset
|
2546 // from vertex 0 to vertex N. |
096b1a159d1f
Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents:
18771
diff
changeset
|
2547 int j = count_f(i)-1; |
096b1a159d1f
Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents:
18771
diff
changeset
|
2548 if (flag && ! clip(int (f(i,j) - 1))) |
096b1a159d1f
Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents:
18771
diff
changeset
|
2549 { |
096b1a159d1f
Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents:
18771
diff
changeset
|
2550 vertex_data::vertex_data_rep *vv |
096b1a159d1f
Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents:
18771
diff
changeset
|
2551 = vdata[i+j*fr].get_rep (); |
096b1a159d1f
Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents:
18771
diff
changeset
|
2552 const Matrix m = vv->coords; |
096b1a159d1f
Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents:
18771
diff
changeset
|
2553 if (ec_mode != UNIFORM) |
096b1a159d1f
Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents:
18771
diff
changeset
|
2554 { |
096b1a159d1f
Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents:
18771
diff
changeset
|
2555 Matrix col = vv->color; |
096b1a159d1f
Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents:
18771
diff
changeset
|
2556 |
096b1a159d1f
Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents:
18771
diff
changeset
|
2557 if (col.numel () == 3) |
096b1a159d1f
Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents:
18771
diff
changeset
|
2558 glColor3dv (col.data ()); |
096b1a159d1f
Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents:
18771
diff
changeset
|
2559 } |
096b1a159d1f
Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents:
18771
diff
changeset
|
2560 glVertex3d (m(0), m(1), m(2)); |
096b1a159d1f
Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents:
18771
diff
changeset
|
2561 } |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2562 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2563 if (flag) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2564 glEnd (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2565 } |
18817
096b1a159d1f
Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents:
18771
diff
changeset
|
2566 else // Normal edge contour drawn with tesselator |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2567 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2568 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
|
2569 tess.begin_contour (); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2570 |
18296
c8d6ca222bcc
Make "edgecolor"="flat" for patch objects compatible with Matlab.
Rik <rik@octave.org>
parents:
18295
diff
changeset
|
2571 for (int j = count_f(i)-1; j >= 0; j--) |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2572 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2573 vertex_data::vertex_data_rep *vv |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2574 = vdata[i+j*fr].get_rep (); |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2575 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
|
2576 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2577 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2578 tess.end_contour (); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2579 tess.end_polygon (); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2580 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2581 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2582 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2583 set_linestyle ("-"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2584 set_linewidth (0.5); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2585 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2586 if (el_mode > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2587 glDisable (GL_LIGHTING); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2588 } |
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
|
2589 else |
10315
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 // FIXME: implement transparency |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2592 } |
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
|
2593 } |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
2594 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2595 if (! props.marker_is ("none") |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2596 && ! (props.markeredgecolor_is ("none") |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2597 && props.markerfacecolor_is ("none"))) |
7833
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
2598 { |
7838
0a2ba0053fbd
Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7837
diff
changeset
|
2599 bool do_edge = ! props.markeredgecolor_is ("none"); |
0a2ba0053fbd
Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7837
diff
changeset
|
2600 bool do_face = ! props.markerfacecolor_is ("none"); |
0a2ba0053fbd
Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7837
diff
changeset
|
2601 |
0a2ba0053fbd
Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7837
diff
changeset
|
2602 Matrix mecolor = props.get_markeredgecolor_rgb (); |
0a2ba0053fbd
Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7837
diff
changeset
|
2603 Matrix mfcolor = props.get_markerfacecolor_rgb (); |
12446
f899f451fe76
Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents:
12443
diff
changeset
|
2604 |
f899f451fe76
Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents:
12443
diff
changeset
|
2605 bool has_markerfacecolor = false; |
f899f451fe76
Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents:
12443
diff
changeset
|
2606 |
20974
1edf15793cac
maint: Use is_empty rather than "numel () == 0" for clarity.
Rik <rik@octave.org>
parents:
20955
diff
changeset
|
2607 if ((mecolor.is_empty () && ! props.markeredgecolor_is ("none")) |
1edf15793cac
maint: Use is_empty rather than "numel () == 0" for clarity.
Rik <rik@octave.org>
parents:
20955
diff
changeset
|
2608 || (mfcolor.is_empty () && ! props.markerfacecolor_is ("none"))) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2609 { |
12446
f899f451fe76
Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents:
12443
diff
changeset
|
2610 Matrix mc = props.get_color_data ().matrix_value (); |
f899f451fe76
Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents:
12443
diff
changeset
|
2611 |
f899f451fe76
Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents:
12443
diff
changeset
|
2612 if (mc.rows () == 1) |
f899f451fe76
Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents:
12443
diff
changeset
|
2613 { |
f899f451fe76
Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents:
12443
diff
changeset
|
2614 // Single color specifications, we can simplify a little bit |
20974
1edf15793cac
maint: Use is_empty rather than "numel () == 0" for clarity.
Rik <rik@octave.org>
parents:
20955
diff
changeset
|
2615 if (mfcolor.is_empty () && ! props.markerfacecolor_is ("none")) |
12446
f899f451fe76
Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents:
12443
diff
changeset
|
2616 mfcolor = mc; |
f899f451fe76
Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents:
12443
diff
changeset
|
2617 |
20974
1edf15793cac
maint: Use is_empty rather than "numel () == 0" for clarity.
Rik <rik@octave.org>
parents:
20955
diff
changeset
|
2618 if (mecolor.is_empty () && ! props.markeredgecolor_is ("none")) |
12446
f899f451fe76
Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents:
12443
diff
changeset
|
2619 mecolor = mc; |
f899f451fe76
Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents:
12443
diff
changeset
|
2620 } |
f899f451fe76
Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents:
12443
diff
changeset
|
2621 else |
f899f451fe76
Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents:
12443
diff
changeset
|
2622 { |
20974
1edf15793cac
maint: Use is_empty rather than "numel () == 0" for clarity.
Rik <rik@octave.org>
parents:
20955
diff
changeset
|
2623 if (c.is_empty ()) |
12446
f899f451fe76
Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents:
12443
diff
changeset
|
2624 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
|
2625 has_markerfacecolor = ((c.numel () > 0) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2626 && (c.rows () == f.rows ())); |
12446
f899f451fe76
Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents:
12443
diff
changeset
|
2627 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2628 } |
7838
0a2ba0053fbd
Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7837
diff
changeset
|
2629 |
0a2ba0053fbd
Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7837
diff
changeset
|
2630 |
0a2ba0053fbd
Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7837
diff
changeset
|
2631 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
|
2632 props.get_linewidth ()); |
7838
0a2ba0053fbd
Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7837
diff
changeset
|
2633 |
0a2ba0053fbd
Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7837
diff
changeset
|
2634 for (int i = 0; i < nf; i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2635 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
|
2636 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2637 int idx = int (f(i,j) - 1); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2638 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2639 if (clip(idx)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2640 continue; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2641 |
12446
f899f451fe76
Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents:
12443
diff
changeset
|
2642 Matrix cc; |
f899f451fe76
Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents:
12443
diff
changeset
|
2643 if (c.numel () > 0) |
f899f451fe76
Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents:
12443
diff
changeset
|
2644 { |
f899f451fe76
Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents:
12443
diff
changeset
|
2645 cc.resize (1, 3); |
f899f451fe76
Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents:
12443
diff
changeset
|
2646 if (has_markerfacecolor) |
f899f451fe76
Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents:
12443
diff
changeset
|
2647 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
|
2648 else |
f899f451fe76
Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents:
12443
diff
changeset
|
2649 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
|
2650 } |
f899f451fe76
Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents:
12443
diff
changeset
|
2651 |
20974
1edf15793cac
maint: Use is_empty rather than "numel () == 0" for clarity.
Rik <rik@octave.org>
parents:
20955
diff
changeset
|
2652 Matrix lc = (do_edge ? (mecolor.is_empty () ? cc : mecolor) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2653 : Matrix ()); |
20974
1edf15793cac
maint: Use is_empty rather than "numel () == 0" for clarity.
Rik <rik@octave.org>
parents:
20955
diff
changeset
|
2654 Matrix fc = (do_face ? (mfcolor.is_empty () ? cc : mfcolor) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2655 : Matrix ()); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2656 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2657 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
|
2658 } |
7838
0a2ba0053fbd
Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7837
diff
changeset
|
2659 |
0a2ba0053fbd
Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7837
diff
changeset
|
2660 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
|
2661 } |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
2662 } |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7831
diff
changeset
|
2663 |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7825
diff
changeset
|
2664 void |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9687
diff
changeset
|
2665 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
|
2666 { |
35e8d6199455
Add hggroup support in OpenGL renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7851
diff
changeset
|
2667 draw (props.get_children ()); |
35e8d6199455
Add hggroup support in OpenGL renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7851
diff
changeset
|
2668 } |
35e8d6199455
Add hggroup support in OpenGL renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7851
diff
changeset
|
2669 |
35e8d6199455
Add hggroup support in OpenGL renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7851
diff
changeset
|
2670 void |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9687
diff
changeset
|
2671 opengl_renderer::draw_text (const text::properties& props) |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
8920
diff
changeset
|
2672 { |
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
|
2673 if (props.get_string ().is_empty ()) |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
8920
diff
changeset
|
2674 return; |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
8920
diff
changeset
|
2675 |
19047
1288a2f27769
Handle non "points" fontunits properties (bug # 40158)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18906
diff
changeset
|
2676 set_font (props); |
1288a2f27769
Handle non "points" fontunits properties (bug # 40158)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18906
diff
changeset
|
2677 |
13961
0fea4cf22f88
restore legend text with OpenGL + FLTK graphics (bug #34907)
John W. Eaton <jwe@octave.org>
parents:
13758
diff
changeset
|
2678 Matrix pos = xform.scale (props.get_data_position ()); |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11385
diff
changeset
|
2679 const Matrix bbox = props.get_extent_matrix (); |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
8920
diff
changeset
|
2680 |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
8920
diff
changeset
|
2681 // FIXME: handle margin and surrounding box |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11385
diff
changeset
|
2682 bool blend = glIsEnabled (GL_BLEND); |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11385
diff
changeset
|
2683 |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11385
diff
changeset
|
2684 glEnable (GL_BLEND); |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11385
diff
changeset
|
2685 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
|
2686 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
|
2687 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
|
2688 glDrawPixels (bbox(2), bbox(3), |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11385
diff
changeset
|
2689 GL_RGBA, GL_UNSIGNED_BYTE, props.get_pixels ().data ()); |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11385
diff
changeset
|
2690 glDisable (GL_ALPHA_TEST); |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11385
diff
changeset
|
2691 if (! blend) |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11385
diff
changeset
|
2692 glDisable (GL_BLEND); |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11385
diff
changeset
|
2693 |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
8920
diff
changeset
|
2694 } |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
8920
diff
changeset
|
2695 |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
8920
diff
changeset
|
2696 void |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9687
diff
changeset
|
2697 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
|
2698 { |
9884
fed4aad2cdca
handle indexed images in opengl renderer
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9834
diff
changeset
|
2699 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
|
2700 dim_vector dv (cdata.dims ()); |
18100
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
2701 int h = dv(0); |
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
2702 int w = dv(1); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11585
diff
changeset
|
2703 |
11093
d748acc75658
gl-render.cc: Treat images with scalar unique(x/ydata) like Matlab.
Ben Abbott <bpabbott@mac.com>
parents:
11026
diff
changeset
|
2704 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
|
2705 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
|
2706 |
15069
7a3957ca99c3
Handle complex arguments in imagesc (bug #36866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14861
diff
changeset
|
2707 // 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
|
2708 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
|
2709 return; |
7a3957ca99c3
Handle complex arguments in imagesc (bug #36866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14861
diff
changeset
|
2710 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11585
diff
changeset
|
2711 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
|
2712 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
|
2713 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11585
diff
changeset
|
2714 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
|
2715 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
|
2716 |
9681 | 2717 const ColumnVector p0 = xform.transform (x(0), y(0), 0); |
2718 const ColumnVector p1 = xform.transform (x(1), y(1), 0); | |
2719 | |
17727
36d646ead233
Fix segfault when x or y data values are large (bug #39925).
Rik <rik@octave.org>
parents:
17726
diff
changeset
|
2720 if (xisnan (p0(0)) || xisnan (p0(1)) || xisnan (p1(0)) || xisnan (p1(1))) |
36d646ead233
Fix segfault when x or y data values are large (bug #39925).
Rik <rik@octave.org>
parents:
17726
diff
changeset
|
2721 { |
18682
8c537222f1e5
gl-render.cc: Use class prefix, opengl_renderer or opengl_texture, when printing warning.
Rik <rik@octave.org>
parents:
18677
diff
changeset
|
2722 warning ("opengl_renderer: image X,Y data too large to draw"); |
17727
36d646ead233
Fix segfault when x or y data values are large (bug #39925).
Rik <rik@octave.org>
parents:
17726
diff
changeset
|
2723 return; |
36d646ead233
Fix segfault when x or y data values are large (bug #39925).
Rik <rik@octave.org>
parents:
17726
diff
changeset
|
2724 } |
36d646ead233
Fix segfault when x or y data values are large (bug #39925).
Rik <rik@octave.org>
parents:
17726
diff
changeset
|
2725 |
9687
86aa08bbc887
image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9682
diff
changeset
|
2726 // image pixel size in screen pixel units |
9950
7dedfd70dd9f
image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9884
diff
changeset
|
2727 float pix_dx, pix_dy; |
9687
86aa08bbc887
image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9682
diff
changeset
|
2728 // image pixel size in normalized units |
9950
7dedfd70dd9f
image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9884
diff
changeset
|
2729 float nor_dx, nor_dy; |
7dedfd70dd9f
image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9884
diff
changeset
|
2730 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11585
diff
changeset
|
2731 if (w > 1) |
9950
7dedfd70dd9f
image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9884
diff
changeset
|
2732 { |
7dedfd70dd9f
image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9884
diff
changeset
|
2733 pix_dx = (p1(0) - p0(0))/(w-1); |
7dedfd70dd9f
image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9884
diff
changeset
|
2734 nor_dx = (x(1) - x(0))/(w-1); |
7dedfd70dd9f
image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9884
diff
changeset
|
2735 } |
7dedfd70dd9f
image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9884
diff
changeset
|
2736 else |
7dedfd70dd9f
image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9884
diff
changeset
|
2737 { |
10076 | 2738 const ColumnVector p1w = xform.transform (x(1) + 1, y(1), 0); |
2739 pix_dx = p1w(0) - p0(0); | |
9950
7dedfd70dd9f
image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9884
diff
changeset
|
2740 nor_dx = 1; |
7dedfd70dd9f
image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9884
diff
changeset
|
2741 } |
10076 | 2742 |
9950
7dedfd70dd9f
image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9884
diff
changeset
|
2743 if (h > 1) |
7dedfd70dd9f
image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9884
diff
changeset
|
2744 { |
7dedfd70dd9f
image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9884
diff
changeset
|
2745 pix_dy = (p1(1) - p0(1))/(h-1); |
7dedfd70dd9f
image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9884
diff
changeset
|
2746 nor_dy = (y(1) - y(0))/(h-1); |
7dedfd70dd9f
image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9884
diff
changeset
|
2747 } |
7dedfd70dd9f
image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9884
diff
changeset
|
2748 else |
7dedfd70dd9f
image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9884
diff
changeset
|
2749 { |
10076 | 2750 const ColumnVector p1h = xform.transform (x(1), y(1) + 1, 0); |
2751 pix_dy = p1h(1) - p0(1); | |
9950
7dedfd70dd9f
image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9884
diff
changeset
|
2752 nor_dy = 1; |
7dedfd70dd9f
image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9884
diff
changeset
|
2753 } |
7dedfd70dd9f
image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9884
diff
changeset
|
2754 |
18682
8c537222f1e5
gl-render.cc: Use class prefix, opengl_renderer or opengl_texture, when printing warning.
Rik <rik@octave.org>
parents:
18677
diff
changeset
|
2755 // OpenGL won't draw any of the image if it's origin is outside the |
8c537222f1e5
gl-render.cc: Use class prefix, opengl_renderer or opengl_texture, when printing warning.
Rik <rik@octave.org>
parents:
18677
diff
changeset
|
2756 // viewport/clipping plane so we must do the clipping ourselves. |
9687
86aa08bbc887
image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9682
diff
changeset
|
2757 |
18100
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
2758 int j0, j1, i0, i1; |
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
2759 j0 = 0, j1 = w; |
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
2760 i0 = 0, i1 = h; |
9687
86aa08bbc887
image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9682
diff
changeset
|
2761 |
86aa08bbc887
image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9682
diff
changeset
|
2762 float im_xmin = x(0) - nor_dx/2; |
86aa08bbc887
image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9682
diff
changeset
|
2763 float im_xmax = x(1) + nor_dx/2; |
86aa08bbc887
image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9682
diff
changeset
|
2764 float im_ymin = y(0) - nor_dy/2; |
86aa08bbc887
image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9682
diff
changeset
|
2765 float im_ymax = y(1) + nor_dy/2; |
86aa08bbc887
image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9682
diff
changeset
|
2766 if (props.is_clipping ()) // clip to axes |
86aa08bbc887
image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9682
diff
changeset
|
2767 { |
86aa08bbc887
image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9682
diff
changeset
|
2768 if (im_xmin < xmin) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2769 j0 += (xmin - im_xmin)/nor_dx + 1; |
9687
86aa08bbc887
image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9682
diff
changeset
|
2770 if (im_xmax > xmax) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2771 j1 -= (im_xmax - xmax)/nor_dx ; |
9687
86aa08bbc887
image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9682
diff
changeset
|
2772 |
86aa08bbc887
image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9682
diff
changeset
|
2773 if (im_ymin < ymin) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2774 i0 += (ymin - im_ymin)/nor_dy + 1; |
9687
86aa08bbc887
image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9682
diff
changeset
|
2775 if (im_ymax > ymax) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2776 i1 -= (im_ymax - ymax)/nor_dy; |
9687
86aa08bbc887
image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9682
diff
changeset
|
2777 } |
86aa08bbc887
image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9682
diff
changeset
|
2778 else // clip to viewport |
86aa08bbc887
image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9682
diff
changeset
|
2779 { |
86aa08bbc887
image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9682
diff
changeset
|
2780 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
|
2781 glGetFloatv (GL_VIEWPORT, vp); |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2782 // 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
|
2783 |
9687
86aa08bbc887
image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9682
diff
changeset
|
2784 } |
86aa08bbc887
image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9682
diff
changeset
|
2785 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11585
diff
changeset
|
2786 if (i0 >= i1 || j0 >= j1) |
9687
86aa08bbc887
image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9682
diff
changeset
|
2787 return; |
86aa08bbc887
image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9682
diff
changeset
|
2788 |
86aa08bbc887
image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9682
diff
changeset
|
2789 glPixelZoom (pix_dx, -pix_dy); |
86aa08bbc887
image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9682
diff
changeset
|
2790 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
|
2791 |
86aa08bbc887
image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9682
diff
changeset
|
2792 // by default this is 4 |
18683
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18682
diff
changeset
|
2793 glPixelStorei (GL_UNPACK_ALIGNMENT, 1); |
9680
73153525df9a
initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9616
diff
changeset
|
2794 |
73153525df9a
initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9616
diff
changeset
|
2795 // Expect RGB data |
73153525df9a
initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9616
diff
changeset
|
2796 if (dv.length () == 3 && dv(2) == 3) |
73153525df9a
initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9616
diff
changeset
|
2797 { |
73153525df9a
initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9616
diff
changeset
|
2798 if (cdata.is_double_type ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2799 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2800 const NDArray xcdata = cdata.array_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2801 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2802 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
|
2803 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2804 for (int i = i0; i < i1; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2805 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2806 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
|
2807 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2808 a[idx] = xcdata(i,j,0); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2809 a[idx+1] = xcdata(i,j,1); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2810 a[idx+2] = xcdata(i,j,2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2811 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2812 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2813 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2814 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
|
2815 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2816 } |
18683
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18682
diff
changeset
|
2817 else if (cdata.is_single_type ()) |
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18682
diff
changeset
|
2818 { |
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18682
diff
changeset
|
2819 const FloatNDArray xcdata = cdata.float_array_value (); |
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18682
diff
changeset
|
2820 |
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18682
diff
changeset
|
2821 OCTAVE_LOCAL_BUFFER (GLfloat, a, 3*(j1-j0)*(i1-i0)); |
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18682
diff
changeset
|
2822 |
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18682
diff
changeset
|
2823 for (int i = i0; i < i1; i++) |
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18682
diff
changeset
|
2824 { |
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18682
diff
changeset
|
2825 for (int j = j0, idx = (i-i0)*(j1-j0)*3; j < j1; j++, idx += 3) |
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18682
diff
changeset
|
2826 { |
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18682
diff
changeset
|
2827 a[idx] = xcdata(i,j,0); |
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18682
diff
changeset
|
2828 a[idx+1] = xcdata(i,j,1); |
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18682
diff
changeset
|
2829 a[idx+2] = xcdata(i,j,2); |
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18682
diff
changeset
|
2830 } |
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18682
diff
changeset
|
2831 } |
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18682
diff
changeset
|
2832 |
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18682
diff
changeset
|
2833 draw_pixels (j1-j0, i1-i0, GL_RGB, GL_FLOAT, a); |
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18682
diff
changeset
|
2834 |
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18682
diff
changeset
|
2835 } |
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18682
diff
changeset
|
2836 else if (cdata.is_uint8_type ()) |
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18682
diff
changeset
|
2837 { |
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18682
diff
changeset
|
2838 const uint8NDArray xcdata = cdata.uint8_array_value (); |
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18682
diff
changeset
|
2839 |
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18682
diff
changeset
|
2840 OCTAVE_LOCAL_BUFFER (GLubyte, a, 3*(j1-j0)*(i1-i0)); |
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18682
diff
changeset
|
2841 |
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18682
diff
changeset
|
2842 for (int i = i0; i < i1; i++) |
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18682
diff
changeset
|
2843 { |
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18682
diff
changeset
|
2844 for (int j = j0, idx = (i-i0)*(j1-j0)*3; j < j1; j++, idx += 3) |
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18682
diff
changeset
|
2845 { |
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18682
diff
changeset
|
2846 a[idx] = xcdata(i,j,0); |
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18682
diff
changeset
|
2847 a[idx+1] = xcdata(i,j,1); |
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18682
diff
changeset
|
2848 a[idx+2] = xcdata(i,j,2); |
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18682
diff
changeset
|
2849 } |
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18682
diff
changeset
|
2850 } |
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18682
diff
changeset
|
2851 |
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18682
diff
changeset
|
2852 draw_pixels (j1-j0, i1-i0, GL_RGB, GL_UNSIGNED_BYTE, a); |
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18682
diff
changeset
|
2853 |
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18682
diff
changeset
|
2854 } |
9680
73153525df9a
initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9616
diff
changeset
|
2855 else if (cdata.is_uint16_type ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2856 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2857 const uint16NDArray xcdata = cdata.uint16_array_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2858 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2859 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
|
2860 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2861 for (int i = i0; i < i1; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2862 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2863 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
|
2864 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2865 a[idx] = xcdata(i,j,0); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2866 a[idx+1] = xcdata(i,j,1); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2867 a[idx+2] = xcdata(i,j,2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2868 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2869 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2870 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2871 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
|
2872 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
2873 } |
9680
73153525df9a
initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9616
diff
changeset
|
2874 else |
18683
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18682
diff
changeset
|
2875 warning ("opengl_renderer: invalid image data type (expected double, single, uint8, or uint16)"); |
9680
73153525df9a
initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9616
diff
changeset
|
2876 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11585
diff
changeset
|
2877 else |
18682
8c537222f1e5
gl-render.cc: Use class prefix, opengl_renderer or opengl_texture, when printing warning.
Rik <rik@octave.org>
parents:
18677
diff
changeset
|
2878 warning ("opengl_renderer: invalid image size (expected MxNx3 or MxN)"); |
13219
cf5ebc0e47e4
fix warnings for unused but set variables and shadowed variables
John W. Eaton <jwe@octave.org>
parents:
13216
diff
changeset
|
2879 |
9680
73153525df9a
initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9616
diff
changeset
|
2880 glPixelZoom (1, 1); |
73153525df9a
initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9616
diff
changeset
|
2881 } |
73153525df9a
initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9616
diff
changeset
|
2882 |
73153525df9a
initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9616
diff
changeset
|
2883 void |
7825
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2884 opengl_renderer::set_viewport (int w, int h) |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2885 { |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2886 glViewport (0, 0, w, h); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2887 } |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2888 |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2889 void |
9950
7dedfd70dd9f
image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9884
diff
changeset
|
2890 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
|
2891 GLenum type, const GLvoid *data) |
7dedfd70dd9f
image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9884
diff
changeset
|
2892 { |
7dedfd70dd9f
image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9884
diff
changeset
|
2893 glDrawPixels (width, height, format, type, data); |
7dedfd70dd9f
image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9884
diff
changeset
|
2894 } |
7dedfd70dd9f
image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9884
diff
changeset
|
2895 |
7dedfd70dd9f
image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9884
diff
changeset
|
2896 void |
7825
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2897 opengl_renderer::set_color (const Matrix& c) |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2898 { |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2899 glColor3dv (c.data ()); |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
8920
diff
changeset
|
2900 #if HAVE_FREETYPE |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
8920
diff
changeset
|
2901 text_renderer.set_color (c); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
8920
diff
changeset
|
2902 #endif |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
8920
diff
changeset
|
2903 } |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
8920
diff
changeset
|
2904 |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
8920
diff
changeset
|
2905 void |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
8920
diff
changeset
|
2906 opengl_renderer::set_font (const base_properties& props) |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
8920
diff
changeset
|
2907 { |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
8920
diff
changeset
|
2908 #if HAVE_FREETYPE |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11385
diff
changeset
|
2909 text_renderer.set_font (props.get ("fontname").string_value (), |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11385
diff
changeset
|
2910 props.get ("fontweight").string_value (), |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11385
diff
changeset
|
2911 props.get ("fontangle").string_value (), |
19047
1288a2f27769
Handle non "points" fontunits properties (bug # 40158)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18906
diff
changeset
|
2912 props.get ("fontsize_points").double_value ()); |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
8920
diff
changeset
|
2913 #endif |
7825
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2914 } |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2915 |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2916 void |
18768
75f8926deef1
Fix Z-order stacking of patches and axes grid lines (bug #40722).
Rik <rik@octave.org>
parents:
18720
diff
changeset
|
2917 opengl_renderer::set_polygon_offset (bool on, float offset) |
7825
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2918 { |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2919 if (on) |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2920 { |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2921 glEnable (GL_POLYGON_OFFSET_FILL); |
7906 | 2922 glEnable (GL_POLYGON_OFFSET_LINE); |
18768
75f8926deef1
Fix Z-order stacking of patches and axes grid lines (bug #40722).
Rik <rik@octave.org>
parents:
18720
diff
changeset
|
2923 glPolygonOffset (offset, offset); |
7825
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2924 } |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2925 else |
7906 | 2926 { |
2927 glDisable (GL_POLYGON_OFFSET_FILL); | |
2928 glDisable (GL_POLYGON_OFFSET_LINE); | |
2929 } | |
7825
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2930 } |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2931 |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2932 void |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2933 opengl_renderer::set_linewidth (float w) |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2934 { |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2935 glLineWidth (w); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2936 } |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2937 |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2938 void |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2939 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
|
2940 { |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2941 bool solid = false; |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2942 |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2943 if (s == "-") |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2944 { |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2945 glLineStipple (1, static_cast<unsigned short> (0xFFFF)); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2946 solid = true; |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2947 } |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2948 else if (s == ":") |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2949 glLineStipple (1, static_cast<unsigned short> (0x8888)); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2950 else if (s == "--") |
18906
c0fb31c46e87
Change OpenGL dashed line style to 50% mark / 50% space.
Rik <rik@octave.org>
parents:
18901
diff
changeset
|
2951 glLineStipple (1, static_cast<unsigned short> (0xF0F0)); |
7825
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2952 else if (s == "-.") |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2953 glLineStipple (1, static_cast<unsigned short> (0x020F)); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2954 else |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2955 glLineStipple (1, static_cast<unsigned short> (0x0000)); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2956 |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2957 if (solid && ! use_stipple) |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2958 glDisable (GL_LINE_STIPPLE); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2959 else |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2960 glEnable (GL_LINE_STIPPLE); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2961 } |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2962 |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2963 void |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2964 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
|
2965 double z1, double z2) |
7825
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2966 { |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2967 double dx = (x2-x1); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2968 double dy = (y2-y1); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2969 double dz = (z2-z1); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2970 |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2971 x1 -= 0.001*dx; x2 += 0.001*dx; |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2972 y1 -= 0.001*dy; y2 += 0.001*dy; |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2973 z1 -= 0.001*dz; z2 += 0.001*dz; |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2974 |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2975 ColumnVector p (4, 0.0); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2976 |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2977 p(0) = -1; p(3) = x2; |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2978 glClipPlane (GL_CLIP_PLANE0, p.data ()); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2979 p(0) = 1; p(3) = -x1; |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2980 glClipPlane (GL_CLIP_PLANE1, p.data ()); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2981 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
|
2982 glClipPlane (GL_CLIP_PLANE2, p.data ()); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2983 p(1) = 1; p(3) = -y1; |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2984 glClipPlane (GL_CLIP_PLANE3, p.data ()); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2985 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
|
2986 glClipPlane (GL_CLIP_PLANE4, p.data ()); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2987 p(2) = 1; p(3) = -z1; |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2988 glClipPlane (GL_CLIP_PLANE5, p.data ()); |
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 xmin = x1; xmax = x2; |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2991 ymin = y1; ymax = y2; |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2992 zmin = z1; zmax = z2; |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2993 } |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2994 |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2995 void |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2996 opengl_renderer::set_clipping (bool enable) |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2997 { |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2998 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
|
2999 |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3000 if (enable != has_clipping) |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3001 { |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3002 if (enable) |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3003 for (int i = 0; i < 6; i++) |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3004 glEnable (GL_CLIP_PLANE0+i); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3005 else |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3006 for (int i = 0; i < 6; i++) |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3007 glDisable (GL_CLIP_PLANE0+i); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3008 } |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3009 } |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3010 |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3011 void |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3012 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
|
3013 { |
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
|
3014 #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
|
3015 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
|
3016 #else |
7825
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3017 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
|
3018 #endif |
7825
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3019 |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3020 glGetIntegerv (GL_VIEWPORT, vw); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3021 |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3022 glMatrixMode (GL_PROJECTION); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3023 glPushMatrix (); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3024 glLoadIdentity (); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3025 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
|
3026 glMatrixMode (GL_MODELVIEW); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3027 glPushMatrix (); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3028 |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3029 set_clipping (false); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3030 set_linewidth (width); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3031 |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3032 marker_id = make_marker_list (m, size, false); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3033 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
|
3034 } |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3035 |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3036 void |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3037 opengl_renderer::end_marker (void) |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3038 { |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3039 glDeleteLists (marker_id, 1); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3040 glDeleteLists (filled_marker_id, 1); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3041 |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3042 glMatrixMode (GL_MODELVIEW); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3043 glPopMatrix (); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3044 glMatrixMode (GL_PROJECTION); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3045 glPopMatrix (); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3046 set_linewidth (0.5f); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3047 } |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3048 |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3049 void |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3050 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
|
3051 const Matrix& lc, const Matrix& fc) |
7825
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3052 { |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3053 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
|
3054 |
7825
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3055 glLoadIdentity (); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3056 glTranslated (tmp(0), tmp(1), -tmp(2)); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3057 |
7907
c350329da645
Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents:
7906
diff
changeset
|
3058 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
|
3059 { |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3060 glColor3dv (fc.data ()); |
7906 | 3061 set_polygon_offset (true, -1.0); |
7825
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3062 glCallList (filled_marker_id); |
7906 | 3063 if (lc.numel () > 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
3064 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
3065 glColor3dv (lc.data ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
3066 glPolygonMode (GL_FRONT_AND_BACK, GL_LINE); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
3067 glEdgeFlag (GL_TRUE); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
3068 set_polygon_offset (true, -2.0); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
3069 glCallList (filled_marker_id); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
3070 glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
3071 } |
7825
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3072 set_polygon_offset (false); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3073 } |
7907
c350329da645
Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents:
7906
diff
changeset
|
3074 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
|
3075 { |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3076 glColor3dv (lc.data ()); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3077 glCallList (marker_id); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3078 } |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3079 } |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3080 |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3081 unsigned int |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3082 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
|
3083 bool filled) const |
7825
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3084 { |
7907
c350329da645
Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents:
7906
diff
changeset
|
3085 char c = marker[0]; |
c350329da645
Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents:
7906
diff
changeset
|
3086 |
c350329da645
Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents:
7906
diff
changeset
|
3087 if (filled && (c == '+' || c == 'x' || c == '*' || c == '.')) |
c350329da645
Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents:
7906
diff
changeset
|
3088 return 0; |
c350329da645
Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents:
7906
diff
changeset
|
3089 |
7825
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3090 unsigned int ID = glGenLists (1); |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11570
diff
changeset
|
3091 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
|
3092 |
7851
002b1d8460d2
added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7846
diff
changeset
|
3093 // constants for the * marker |
002b1d8460d2
added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7846
diff
changeset
|
3094 const double sqrt2d4 = 0.35355339059327; |
002b1d8460d2
added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7846
diff
changeset
|
3095 double tt = sz*sqrt2d4; |
002b1d8460d2
added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7846
diff
changeset
|
3096 |
7825
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3097 glNewList (ID, GL_COMPILE); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3098 |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3099 switch (marker[0]) |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3100 { |
7851
002b1d8460d2
added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7846
diff
changeset
|
3101 case '+': |
002b1d8460d2
added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7846
diff
changeset
|
3102 glBegin (GL_LINES); |
18769
ff39ddf84a19
* gl-render.cc (opengl_renderer::make_marker_list): Replace glVertex2f with
Rik <rik@octave.org>
parents:
18768
diff
changeset
|
3103 glVertex2d (-sz/2, 0); |
ff39ddf84a19
* gl-render.cc (opengl_renderer::make_marker_list): Replace glVertex2f with
Rik <rik@octave.org>
parents:
18768
diff
changeset
|
3104 glVertex2d (sz/2, 0); |
ff39ddf84a19
* gl-render.cc (opengl_renderer::make_marker_list): Replace glVertex2f with
Rik <rik@octave.org>
parents:
18768
diff
changeset
|
3105 glVertex2d (0, -sz/2); |
ff39ddf84a19
* gl-render.cc (opengl_renderer::make_marker_list): Replace glVertex2f with
Rik <rik@octave.org>
parents:
18768
diff
changeset
|
3106 glVertex2d (0, sz/2); |
7851
002b1d8460d2
added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7846
diff
changeset
|
3107 glEnd (); |
002b1d8460d2
added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7846
diff
changeset
|
3108 break; |
002b1d8460d2
added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7846
diff
changeset
|
3109 case 'x': |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
3110 glBegin (GL_LINES); |
18769
ff39ddf84a19
* gl-render.cc (opengl_renderer::make_marker_list): Replace glVertex2f with
Rik <rik@octave.org>
parents:
18768
diff
changeset
|
3111 glVertex2d (-sz/2, -sz/2); |
ff39ddf84a19
* gl-render.cc (opengl_renderer::make_marker_list): Replace glVertex2f with
Rik <rik@octave.org>
parents:
18768
diff
changeset
|
3112 glVertex2d (sz/2, sz/2); |
ff39ddf84a19
* gl-render.cc (opengl_renderer::make_marker_list): Replace glVertex2f with
Rik <rik@octave.org>
parents:
18768
diff
changeset
|
3113 glVertex2d (-sz/2, sz/2); |
ff39ddf84a19
* gl-render.cc (opengl_renderer::make_marker_list): Replace glVertex2f with
Rik <rik@octave.org>
parents:
18768
diff
changeset
|
3114 glVertex2d (sz/2, -sz/2); |
7851
002b1d8460d2
added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7846
diff
changeset
|
3115 glEnd (); |
002b1d8460d2
added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7846
diff
changeset
|
3116 break; |
002b1d8460d2
added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7846
diff
changeset
|
3117 case '*': |
002b1d8460d2
added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7846
diff
changeset
|
3118 glBegin (GL_LINES); |
18769
ff39ddf84a19
* gl-render.cc (opengl_renderer::make_marker_list): Replace glVertex2f with
Rik <rik@octave.org>
parents:
18768
diff
changeset
|
3119 glVertex2d (-sz/2, 0); |
ff39ddf84a19
* gl-render.cc (opengl_renderer::make_marker_list): Replace glVertex2f with
Rik <rik@octave.org>
parents:
18768
diff
changeset
|
3120 glVertex2d (sz/2, 0); |
ff39ddf84a19
* gl-render.cc (opengl_renderer::make_marker_list): Replace glVertex2f with
Rik <rik@octave.org>
parents:
18768
diff
changeset
|
3121 glVertex2d (0, -sz/2); |
ff39ddf84a19
* gl-render.cc (opengl_renderer::make_marker_list): Replace glVertex2f with
Rik <rik@octave.org>
parents:
18768
diff
changeset
|
3122 glVertex2d (0, sz/2); |
ff39ddf84a19
* gl-render.cc (opengl_renderer::make_marker_list): Replace glVertex2f with
Rik <rik@octave.org>
parents:
18768
diff
changeset
|
3123 glVertex2d (-tt, -tt); |
ff39ddf84a19
* gl-render.cc (opengl_renderer::make_marker_list): Replace glVertex2f with
Rik <rik@octave.org>
parents:
18768
diff
changeset
|
3124 glVertex2d (+tt, +tt); |
ff39ddf84a19
* gl-render.cc (opengl_renderer::make_marker_list): Replace glVertex2f with
Rik <rik@octave.org>
parents:
18768
diff
changeset
|
3125 glVertex2d (-tt, +tt); |
ff39ddf84a19
* gl-render.cc (opengl_renderer::make_marker_list): Replace glVertex2f with
Rik <rik@octave.org>
parents:
18768
diff
changeset
|
3126 glVertex2d (+tt, -tt); |
7851
002b1d8460d2
added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7846
diff
changeset
|
3127 glEnd (); |
002b1d8460d2
added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7846
diff
changeset
|
3128 break; |
002b1d8460d2
added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7846
diff
changeset
|
3129 case '.': |
10924
f56255a2b890
gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents:
10835
diff
changeset
|
3130 { |
f56255a2b890
gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents:
10835
diff
changeset
|
3131 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
|
3132 |
f56255a2b890
gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents:
10835
diff
changeset
|
3133 glBegin (GL_POLYGON); |
f56255a2b890
gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents:
10835
diff
changeset
|
3134 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
|
3135 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
|
3136 glEnd (); |
f56255a2b890
gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents:
10835
diff
changeset
|
3137 } |
7851
002b1d8460d2
added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7846
diff
changeset
|
3138 break; |
002b1d8460d2
added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7846
diff
changeset
|
3139 case 's': |
002b1d8460d2
added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7846
diff
changeset
|
3140 glBegin ((filled ? GL_POLYGON : GL_LINE_LOOP)); |
002b1d8460d2
added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7846
diff
changeset
|
3141 glVertex2d (-sz/2, -sz/2); |
9681 | 3142 glVertex2d (-sz/2, sz/2); |
3143 glVertex2d (sz/2, sz/2); | |
3144 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
|
3145 glEnd (); |
7851
002b1d8460d2
added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7846
diff
changeset
|
3146 break; |
002b1d8460d2
added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7846
diff
changeset
|
3147 case 'o': |
002b1d8460d2
added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7846
diff
changeset
|
3148 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
3149 double ang_step = M_PI / 5; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
3150 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
3151 glBegin ((filled ? GL_POLYGON : GL_LINE_LOOP)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
3152 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
|
3153 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
|
3154 glEnd (); |
7851
002b1d8460d2
added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7846
diff
changeset
|
3155 } |
002b1d8460d2
added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7846
diff
changeset
|
3156 break; |
002b1d8460d2
added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7846
diff
changeset
|
3157 case 'd': |
002b1d8460d2
added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7846
diff
changeset
|
3158 glBegin ((filled ? GL_POLYGON : GL_LINE_LOOP)); |
9681 | 3159 glVertex2d (0, -sz/2); |
3160 glVertex2d (sz/2, 0); | |
3161 glVertex2d (0, sz/2); | |
3162 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
|
3163 glEnd (); |
7851
002b1d8460d2
added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7846
diff
changeset
|
3164 break; |
10835
4bbd6f75f173
gl-render.cc: Transpose markers '^' and 'v'.
Ben Abbott <bpabbott@mac.com>
parents:
10402
diff
changeset
|
3165 case 'v': |
7851
002b1d8460d2
added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7846
diff
changeset
|
3166 glBegin ((filled ? GL_POLYGON : GL_LINE_LOOP)); |
18769
ff39ddf84a19
* gl-render.cc (opengl_renderer::make_marker_list): Replace glVertex2f with
Rik <rik@octave.org>
parents:
18768
diff
changeset
|
3167 glVertex2d (0, sz/2); |
ff39ddf84a19
* gl-render.cc (opengl_renderer::make_marker_list): Replace glVertex2f with
Rik <rik@octave.org>
parents:
18768
diff
changeset
|
3168 glVertex2d (sz/2, -sz/2); |
ff39ddf84a19
* gl-render.cc (opengl_renderer::make_marker_list): Replace glVertex2f with
Rik <rik@octave.org>
parents:
18768
diff
changeset
|
3169 glVertex2d (-sz/2, -sz/2); |
7851
002b1d8460d2
added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7846
diff
changeset
|
3170 glEnd (); |
002b1d8460d2
added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7846
diff
changeset
|
3171 break; |
10835
4bbd6f75f173
gl-render.cc: Transpose markers '^' and 'v'.
Ben Abbott <bpabbott@mac.com>
parents:
10402
diff
changeset
|
3172 case '^': |
7851
002b1d8460d2
added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7846
diff
changeset
|
3173 glBegin ((filled ? GL_POLYGON : GL_LINE_LOOP)); |
18769
ff39ddf84a19
* gl-render.cc (opengl_renderer::make_marker_list): Replace glVertex2f with
Rik <rik@octave.org>
parents:
18768
diff
changeset
|
3174 glVertex2d (0, -sz/2); |
ff39ddf84a19
* gl-render.cc (opengl_renderer::make_marker_list): Replace glVertex2f with
Rik <rik@octave.org>
parents:
18768
diff
changeset
|
3175 glVertex2d (-sz/2, sz/2); |
ff39ddf84a19
* gl-render.cc (opengl_renderer::make_marker_list): Replace glVertex2f with
Rik <rik@octave.org>
parents:
18768
diff
changeset
|
3176 glVertex2d (sz/2, sz/2); |
7851
002b1d8460d2
added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7846
diff
changeset
|
3177 glEnd (); |
002b1d8460d2
added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7846
diff
changeset
|
3178 break; |
002b1d8460d2
added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7846
diff
changeset
|
3179 case '>': |
002b1d8460d2
added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7846
diff
changeset
|
3180 glBegin ((filled ? GL_POLYGON : GL_LINE_LOOP)); |
18769
ff39ddf84a19
* gl-render.cc (opengl_renderer::make_marker_list): Replace glVertex2f with
Rik <rik@octave.org>
parents:
18768
diff
changeset
|
3181 glVertex2d (sz/2, 0); |
ff39ddf84a19
* gl-render.cc (opengl_renderer::make_marker_list): Replace glVertex2f with
Rik <rik@octave.org>
parents:
18768
diff
changeset
|
3182 glVertex2d (-sz/2, sz/2); |
ff39ddf84a19
* gl-render.cc (opengl_renderer::make_marker_list): Replace glVertex2f with
Rik <rik@octave.org>
parents:
18768
diff
changeset
|
3183 glVertex2d (-sz/2, -sz/2); |
7851
002b1d8460d2
added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7846
diff
changeset
|
3184 glEnd (); |
002b1d8460d2
added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7846
diff
changeset
|
3185 break; |
002b1d8460d2
added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7846
diff
changeset
|
3186 case '<': |
002b1d8460d2
added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7846
diff
changeset
|
3187 glBegin ((filled ? GL_POLYGON : GL_LINE_LOOP)); |
18769
ff39ddf84a19
* gl-render.cc (opengl_renderer::make_marker_list): Replace glVertex2f with
Rik <rik@octave.org>
parents:
18768
diff
changeset
|
3188 glVertex2d (-sz/2, 0); |
ff39ddf84a19
* gl-render.cc (opengl_renderer::make_marker_list): Replace glVertex2f with
Rik <rik@octave.org>
parents:
18768
diff
changeset
|
3189 glVertex2d (sz/2, -sz/2); |
ff39ddf84a19
* gl-render.cc (opengl_renderer::make_marker_list): Replace glVertex2f with
Rik <rik@octave.org>
parents:
18768
diff
changeset
|
3190 glVertex2d (sz/2, sz/2); |
7851
002b1d8460d2
added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7846
diff
changeset
|
3191 glEnd (); |
7906 | 3192 break; |
10924
f56255a2b890
gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents:
10835
diff
changeset
|
3193 case 'p': |
f56255a2b890
gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents:
10835
diff
changeset
|
3194 { |
f56255a2b890
gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents:
10835
diff
changeset
|
3195 double ang; |
f56255a2b890
gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents:
10835
diff
changeset
|
3196 double r; |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
3197 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
|
3198 |
10924
f56255a2b890
gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents:
10835
diff
changeset
|
3199 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
|
3200 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
|
3201 { |
f56255a2b890
gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents:
10835
diff
changeset
|
3202 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
|
3203 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
|
3204 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
|
3205 } |
f56255a2b890
gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents:
10835
diff
changeset
|
3206 glEnd (); |
f56255a2b890
gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents:
10835
diff
changeset
|
3207 } |
f56255a2b890
gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents:
10835
diff
changeset
|
3208 break; |
f56255a2b890
gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents:
10835
diff
changeset
|
3209 case 'h': |
f56255a2b890
gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents:
10835
diff
changeset
|
3210 { |
f56255a2b890
gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents:
10835
diff
changeset
|
3211 double ang; |
f56255a2b890
gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents:
10835
diff
changeset
|
3212 double r; |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
3213 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
|
3214 |
10924
f56255a2b890
gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents:
10835
diff
changeset
|
3215 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
|
3216 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
|
3217 { |
f56255a2b890
gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents:
10835
diff
changeset
|
3218 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
|
3219 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
|
3220 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
|
3221 } |
f56255a2b890
gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents:
10835
diff
changeset
|
3222 glEnd (); |
f56255a2b890
gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents:
10835
diff
changeset
|
3223 } |
f56255a2b890
gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents:
10835
diff
changeset
|
3224 break; |
7851
002b1d8460d2
added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7846
diff
changeset
|
3225 default: |
18677
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18667
diff
changeset
|
3226 warning ("opengl_renderer: unsupported marker '%s'", marker.c_str ()); |
7851
002b1d8460d2
added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7846
diff
changeset
|
3227 break; |
7825
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3228 } |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3229 |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3230 glEndList (); |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3231 |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3232 return ID; |
13871b7de124
Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3233 } |
7874
e3a502930e2a
eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents:
7870
diff
changeset
|
3234 |
9834
92d8f35ff217
compute bounding boxes for text in opengl graphics backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9798
diff
changeset
|
3235 void |
92d8f35ff217
compute bounding boxes for text in opengl graphics backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9798
diff
changeset
|
3236 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
|
3237 uint8NDArray& pixels, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
3238 Matrix& bbox, |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11385
diff
changeset
|
3239 int halign, int valign, double rotation) |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
8920
diff
changeset
|
3240 { |
12333
f103b9c1ca05
use text_renderer object only when freetye is available
Kai Habel <kai.habel@gmx.de>
parents:
12327
diff
changeset
|
3241 #if HAVE_FREETYPE |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11385
diff
changeset
|
3242 text_renderer.text_to_pixels (txt, pixels, bbox, |
20285
6db2ea5556a4
Make use of the axes "ticklabelinterpreter" property (bug #45438)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20232
diff
changeset
|
3243 halign, valign, rotation, interpreter); |
12333
f103b9c1ca05
use text_renderer object only when freetye is available
Kai Habel <kai.habel@gmx.de>
parents:
12327
diff
changeset
|
3244 #endif |
9834
92d8f35ff217
compute bounding boxes for text in opengl graphics backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9798
diff
changeset
|
3245 } |
92d8f35ff217
compute bounding boxes for text in opengl graphics backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9798
diff
changeset
|
3246 |
20623
2be59ab36110
Add method in gl_render to get a list of parsed ft_string (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20285
diff
changeset
|
3247 void |
2be59ab36110
Add method in gl_render to get a list of parsed ft_string (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20285
diff
changeset
|
3248 opengl_renderer::text_to_strlist (const std::string& txt, |
2be59ab36110
Add method in gl_render to get a list of parsed ft_string (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20285
diff
changeset
|
3249 std::list<ft_render::ft_string>& lst, |
2be59ab36110
Add method in gl_render to get a list of parsed ft_string (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20285
diff
changeset
|
3250 Matrix& bbox, |
2be59ab36110
Add method in gl_render to get a list of parsed ft_string (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20285
diff
changeset
|
3251 int halign, int valign, double rotation) |
2be59ab36110
Add method in gl_render to get a list of parsed ft_string (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20285
diff
changeset
|
3252 { |
2be59ab36110
Add method in gl_render to get a list of parsed ft_string (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20285
diff
changeset
|
3253 #if HAVE_FREETYPE |
2be59ab36110
Add method in gl_render to get a list of parsed ft_string (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20285
diff
changeset
|
3254 text_renderer.text_to_strlist (txt, lst, bbox, |
2be59ab36110
Add method in gl_render to get a list of parsed ft_string (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20285
diff
changeset
|
3255 halign, valign, rotation, interpreter); |
2be59ab36110
Add method in gl_render to get a list of parsed ft_string (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20285
diff
changeset
|
3256 #endif |
2be59ab36110
Add method in gl_render to get a list of parsed ft_string (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20285
diff
changeset
|
3257 } |
2be59ab36110
Add method in gl_render to get a list of parsed ft_string (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20285
diff
changeset
|
3258 |
9834
92d8f35ff217
compute bounding boxes for text in opengl graphics backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9798
diff
changeset
|
3259 Matrix |
92d8f35ff217
compute bounding boxes for text in opengl graphics backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9798
diff
changeset
|
3260 opengl_renderer::render_text (const std::string& txt, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
3261 double x, double y, double z, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
3262 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
|
3263 { |
92d8f35ff217
compute bounding boxes for text in opengl graphics backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9798
diff
changeset
|
3264 #if HAVE_FREETYPE |
92d8f35ff217
compute bounding boxes for text in opengl graphics backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9798
diff
changeset
|
3265 if (txt.empty ()) |
92d8f35ff217
compute bounding boxes for text in opengl graphics backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9798
diff
changeset
|
3266 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
|
3267 |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11385
diff
changeset
|
3268 uint8NDArray pixels; |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
8920
diff
changeset
|
3269 Matrix bbox; |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11385
diff
changeset
|
3270 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
|
3271 |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
8920
diff
changeset
|
3272 bool blend = glIsEnabled (GL_BLEND); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
8920
diff
changeset
|
3273 |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
8920
diff
changeset
|
3274 glEnable (GL_BLEND); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
8920
diff
changeset
|
3275 glEnable (GL_ALPHA_TEST); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
8920
diff
changeset
|
3276 glRasterPos3d (x, y, z); |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11385
diff
changeset
|
3277 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
|
3278 glDrawPixels (bbox(2), bbox(3), |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10202
diff
changeset
|
3279 GL_RGBA, GL_UNSIGNED_BYTE, pixels.data ()); |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
8920
diff
changeset
|
3280 glDisable (GL_ALPHA_TEST); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
8920
diff
changeset
|
3281 if (! blend) |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
8920
diff
changeset
|
3282 glDisable (GL_BLEND); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
8920
diff
changeset
|
3283 |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
8920
diff
changeset
|
3284 return bbox; |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
8920
diff
changeset
|
3285 #else |
21109
bd1752782e56
Use err_disabled_feature, warn_disabled_feature throughout code base.
Rik <rik@octave.org>
parents:
20990
diff
changeset
|
3286 warn_disabled_feature ("opengl_renderer::render_text", |
bd1752782e56
Use err_disabled_feature, warn_disabled_feature throughout code base.
Rik <rik@octave.org>
parents:
20990
diff
changeset
|
3287 "rendering text (FreeType)"); |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
8920
diff
changeset
|
3288 return Matrix (1, 4, 0.0); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
8920
diff
changeset
|
3289 #endif |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
8920
diff
changeset
|
3290 } |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
8920
diff
changeset
|
3291 |
7954 | 3292 #endif |