annotate libinterp/corefcn/gl-render.cc @ 21789:6afdf40be534

Implement graphics object "light" (patch #8943). * graphics.in.h (light): New class. * graphics.in.h (patch, surface): Make default value of facelighting property compatible with Matlab. * graphics.cc: Add function default_light_position. Export function __go_light__. * gl-render.h (opengl_renderer): Declare opengl_renderer::draw_light. New private properties "view_vector", "num_lights" and "current_light". Delete private property "has_light". * gl-render.cc (opengl_renderer::draw_light): New function. (opengl_renderer::draw): Handle drawing for light property. Support for up to GL_MAX_LIGHTS light sources (at least 8, limited by OpenGL). Set view_vector before drawing anything. Set OpenGL ambient light color before drawing other axes objects. Respect setting of "specularcolorreflectance" on patches and surfaces. Set normals of OpenGL faces in patch objects if possible. Support lighting modes "reverselit" and "unlit". Only enable OpenGL lighting if normals are defined for patch. * scripts/plot/draw/light.m: New function. * scripts/plot/draw/module.mk: Update. * __unimplemented__.m: Remove "light" from list. * __gnuplot_draw_axes__.m: Do not throw an error if light object is present. * doc/interpreter/genpropdoc.m, doc/interpreter/module.mk, doc/interpreter/plot.txi: Document light and related properties. * NEWS: Mention new feature.
author mmuetzel <markus.muetzel@gmx.de>
date Mon, 30 May 2016 13:17:13 +0200
parents 2aef506f3fec
children f625afd1ef55
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1 /*
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2
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
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21691
diff changeset
23 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21209
diff changeset
24 # include "config.h"
7825
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
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
27 #include <iostream>
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
28
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21691
diff changeset
29 #if defined (HAVE_WINDOWS_H)
21200
fcac5dbbf9ed maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents: 21198
diff changeset
30 # define WIN32_LEAN_AND_MEAN
fcac5dbbf9ed maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents: 21198
diff changeset
31 # include <windows.h>
21196
bd96c2efd4fe move include statements for OpenGL headers to a single file
John W. Eaton <jwe@octave.org>
parents: 21115
diff changeset
32 #endif
bd96c2efd4fe move include statements for OpenGL headers to a single file
John W. Eaton <jwe@octave.org>
parents: 21115
diff changeset
33
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
34 #include <lo-mappers.h>
8377
25bc2d31e1bf improve OCTAVE_LOCAL_BUFFER
Jaroslav Hajek <highegg@gmail.com>
parents: 8263
diff changeset
35 #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
36 #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
37
629643522cc0 include errwarn.h in all files that use gripe_disabled_feature
John W. Eaton <jwe@octave.org>
parents: 21109
diff changeset
38 #include "errwarn.h"
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
39 #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
40 #include "oct-opengl.h"
21209
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
41 #include "text-renderer.h"
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
42
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
43 #if defined (HAVE_OPENGL)
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
44
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
45 #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
46
18771
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
47 // Use symbolic names for axes
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
48 enum
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
49 {
18771
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
50 X_AXIS,
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
51 Y_AXIS,
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
52 Z_AXIS
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
53 };
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 // 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
56 enum
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
57 {
18771
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
58 UNIFORM,
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
59 FLAT,
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
60 INTERP,
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
61 TEXTURE
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
62 };
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 // Use symbolic names for lighting
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
65 enum
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
66 {
18771
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
67 NONE,
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
68 //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
69 GOURAUD = 2
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
70 };
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
71
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
72 // Win32 API requires the CALLBACK attributes for
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21724
diff changeset
73 // GLU callback functions. Define it to empty on
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
74 // other platforms.
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21691
diff changeset
75 #if ! defined (CALLBACK)
21200
fcac5dbbf9ed maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents: 21198
diff changeset
76 # define CALLBACK
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
77 #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
78
8ff92634982d Add initial 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 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
80 opengl_texture
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
81 {
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
82 protected:
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
83 class texture_rep
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
84 {
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
85 public:
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
86 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
87 : 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
88 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
89 { }
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
90
9681
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
91 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
92 : 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
93 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
94 count (1) { }
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
95
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
96 ~texture_rep (void)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
97 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
98 if (valid)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
99 glDeleteTextures (1, &id);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
100 }
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
101
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
102 void bind (int mode) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
103 { 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
104
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
105 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
106 { 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
107
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
108 GLuint id;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
109 int w, h;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
110 int tw, th;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
111 double tx, ty;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
112 bool valid;
12125
a21a3875ca83 implement a common class for reference counts
Jaroslav Hajek <highegg@gmail.com>
parents: 12122
diff changeset
113 octave_refcount<int> count;
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
114 };
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
115
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
116 texture_rep *rep;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
117
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
118 private:
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
119 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
120
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
121 public:
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
122 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
123
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
124 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
125 : rep (tx.rep)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
126 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
127 rep->count++;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
128 }
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
129
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
130 ~opengl_texture (void)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
131 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
132 if (--rep->count == 0)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
133 delete rep;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
134 }
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
135
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
136 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
137 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
138 if (--rep->count == 0)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
139 delete rep;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
140
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
141 rep = tx.rep;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
142 rep->count++;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
143
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
144 return *this;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
145 }
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
146
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
147 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
148
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
149 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
150 { rep->bind (mode); }
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
151
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
152 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
153 { rep->tex_coord (q, r); }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
154
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
155 bool is_valid (void) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
156 { return rep->valid; }
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
157 };
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 static int
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
160 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
161 {
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
162 int m = 1;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
163
15215
9020dddc925a use std::numeric_limits for integer max and min values
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
164 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
165 m <<= 1;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
166
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
167 return m;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
168 }
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
169
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
170 opengl_texture
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
171 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
172 {
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
173 opengl_texture retval;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
174
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
175 dim_vector dv (data.dims ());
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
176
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
177 // Expect RGB data
21660
53728df3e4c9 maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents: 21602
diff changeset
178 if (dv.ndims () == 3 && dv(2) == 3)
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
179 {
17651
b0f529c3671d gl-render.cc: Replace custom min function with std::min.
Rik <rik@octave.org>
parents: 17602
diff changeset
180 // 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
181 // 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
182 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
183 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
184 GLuint id;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
185 bool ok = true;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
186
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
187 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
188 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
189
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
190 glGenTextures (1, &id);
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
191 glBindTexture (GL_TEXTURE_2D, id);
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
192
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
193 if (data.is_double_type ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
194 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
195 const NDArray xdata = data.array_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
196
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
197 OCTAVE_LOCAL_BUFFER (float, a, (3*tw*th));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
198
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
199 for (int i = 0; i < h; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
200 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
201 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
202 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
203 a[idx] = xdata(i,j,0);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
204 a[idx+1] = xdata(i,j,1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
205 a[idx+2] = xdata(i,j,2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
206 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
207 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
208
17651
b0f529c3671d gl-render.cc: Replace custom min function with std::min.
Rik <rik@octave.org>
parents: 17602
diff changeset
209 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
210 }
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
211 else if (data.is_uint8_type ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
212 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
213 const uint8NDArray xdata = data.uint8_array_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
214
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
215 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
216
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
217 for (int i = 0; i < h; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
218 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
219 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
220 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
221 a[idx] = xdata(i,j,0);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
222 a[idx+1] = xdata(i,j,1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
223 a[idx+2] = xdata(i,j,2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
224 }
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 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
228 GL_RGB, GL_UNSIGNED_BYTE, a);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
229 }
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
230 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
231 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
232 ok = false;
20711
7b608fadc663 Make error messages more specific about the variable and problem encountered.
Rik <rik@octave.org>
parents: 20623
diff changeset
233 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
234 }
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
235
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
236 if (ok)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
237 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
238 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
239 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
240
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
241 if (glGetError () != GL_NO_ERROR)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
242 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
243 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
244 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
245 }
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
246 }
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
247 else
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
248 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
249
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
250 return retval;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
251 }
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
252
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
253 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
254 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
255 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
256 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
257 #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
258 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
259 #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
260 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
261 #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
262
8ff92634982d Add initial 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 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
264
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
265 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
266
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
267 virtual ~opengl_tesselator (void)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
268 { 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
269
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
270 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
271 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
272 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
273 (filled ? GL_FALSE : GL_TRUE));
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
274 fill = filled;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
275 gluTessBeginPolygon (glu_tess, this);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
276 }
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
277
8ff92634982d Add initial 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 void end_polygon (void) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
279 { 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
280
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
281 void begin_contour (void) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
282 { 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
283
8ff92634982d Add initial 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 void end_contour (void) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
285 { 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
286
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
287 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
288 { 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
289
8ff92634982d Add initial 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 protected:
7870
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
291 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
292
8ff92634982d Add initial 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 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
294
17651
b0f529c3671d gl-render.cc: Replace custom min function with std::min.
Rik <rik@octave.org>
parents: 17602
diff changeset
295 virtual void vertex (void * /*data*/) { }
b0f529c3671d gl-render.cc: Replace custom min function with std::min.
Rik <rik@octave.org>
parents: 17602
diff changeset
296
b0f529c3671d gl-render.cc: Replace custom min function with std::min.
Rik <rik@octave.org>
parents: 17602
diff changeset
297 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
298 GLfloat [4] /*w*/, void ** /*out_data*/) { }
7870
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
299
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
300 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
301
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
302 virtual void error (GLenum err)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
303 { ::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
304
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
305 virtual void init (void)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
306 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
307 glu_tess = gluNewTess ();
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
308
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
309 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
310 reinterpret_cast<fcn> (tess_begin));
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
311 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
312 reinterpret_cast<fcn> (tess_end));
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
313 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
314 reinterpret_cast<fcn> (tess_vertex));
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
315 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
316 reinterpret_cast<fcn> (tess_combine));
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
317 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
318 reinterpret_cast<fcn> (tess_edge_flag));
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
319 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
320 reinterpret_cast<fcn> (tess_error));
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
321 }
7833
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
322
8ff92634982d Add initial 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 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
324
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
325 private:
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
326 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
327 { 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
328
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
329 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
330 { reinterpret_cast<opengl_tesselator *> (t)->end (); }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
331
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
332 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
333 { 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
334
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
335 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
336 void **out, void *t)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
337 { 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
338
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
339 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
340 { 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
341
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
342 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
343 { 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
344
8ff92634982d Add initial 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 private:
12122
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11586
diff changeset
346
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11586
diff changeset
347 // No copying!
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11586
diff changeset
348
12174
db1f49eaba6b whitespace fixes
John W. Eaton <jwe@octave.org>
parents: 12164
diff changeset
349 opengl_tesselator (const opengl_tesselator&);
db1f49eaba6b whitespace fixes
John W. Eaton <jwe@octave.org>
parents: 12164
diff changeset
350
db1f49eaba6b whitespace fixes
John W. Eaton <jwe@octave.org>
parents: 12164
diff changeset
351 opengl_tesselator operator = (const opengl_tesselator&);
12122
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11586
diff changeset
352
7833
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
353 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
354 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
355 };
8ff92634982d Add initial 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 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
358 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
359 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
360 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
361 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
362 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
363 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
364 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
365 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
366 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
367 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
368 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
369 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
370 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
371 float specular_exp;
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
372 float specular_color_refl;
7833
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
373
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
374 // 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 (),
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
379 ambient (), diffuse (), specular (), specular_exp (),
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
380 specular_color_refl (), 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
381
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
382 vertex_data_rep (const Matrix& c, const Matrix& col, const Matrix& n,
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
383 double a, float as, float ds, float ss, float se,
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
384 float scr)
17651
b0f529c3671d gl-render.cc: Replace custom min function with std::min.
Rik <rik@octave.org>
parents: 17602
diff changeset
385 : 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
386 ambient (as), diffuse (ds), specular (ss), specular_exp (se),
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
387 specular_color_refl (scr), 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
388 };
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
389
8ff92634982d Add initial 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 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
391 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
392
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
393 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
394 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
395 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
396
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
397 return nr;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
398 }
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
399
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
400 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
401 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
402 { 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
403
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
404 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
405 { 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
406
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
407 vertex_data (const Matrix& c, const Matrix& col, const Matrix& n,
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
408 double a, float as, float ds, float ss, float se,
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
409 float scr)
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
410 : rep (new vertex_data_rep (c, col, n, a, as, ds, ss, se, scr))
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
411 { }
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 (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
414 : 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
415
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
416 ~vertex_data (void)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
417 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
418 if (--rep->count == 0)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
419 delete rep;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
420 }
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
421
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
422 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
423 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
424 if (--rep->count == 0)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
425 delete rep;
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 rep = v.rep;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
428 rep->count++;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
429
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
430 return *this;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
431 }
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
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 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
434 };
8ff92634982d Add initial 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 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
437 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
438 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
439 public:
18768
75f8926deef1 Fix Z-order stacking of patches and axes grid lines (bug #40722).
Rik <rik@octave.org>
parents: 18720
diff changeset
440 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
441 : opengl_tesselator (), renderer (r),
b0f529c3671d gl-render.cc: Replace custom min function with std::min.
Rik <rik@octave.org>
parents: 17602
diff changeset
442 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
443 first (true), tmp_vdata ()
12164
18e9a8da7d18 eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 12126
diff changeset
444 { }
7833
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
445
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
446 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
447 void begin (GLenum type)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
448 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
449 //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
450 first = true;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
451
18771
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
452 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
453 glShadeModel (GL_SMOOTH);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
454 else
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
455 glShadeModel (GL_FLAT);
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 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
458 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
459
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
460 glBegin (type);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
461 }
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
462
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
463 void end (void)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
464 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
465 //printf ("patch_tesselator::end\n");
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
466 glEnd ();
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
467 renderer->set_polygon_offset (false);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
468 }
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
469
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
470 void vertex (void *data)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
471 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
472 vertex_data::vertex_data_rep *v
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
473 = 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
474 //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
475
18768
75f8926deef1 Fix Z-order stacking of patches and axes grid lines (bug #40722).
Rik <rik@octave.org>
parents: 18720
diff changeset
476 // 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
477 // 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
478
18771
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
479 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
480 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
481 Matrix col = v->color;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
482
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
483 if (col.numel () == 3)
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 glColor3dv (col.data ());
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
486 if (light_mode > 0)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
487 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
488 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
489
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
490 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
491 buf[k] = (v->ambient * col(k));
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
492 glMaterialfv (LIGHT_MODE, GL_AMBIENT, buf);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
493
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
494 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
495 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
496 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, buf);
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
497
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
498 for (int k = 0; k < 3; k++)
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
499 buf[k] = v->specular * (v->specular_color_refl +
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
500 (1 - v->specular_color_refl) * col(k));
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
501 glMaterialfv (LIGHT_MODE, GL_SPECULAR, buf);
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
502
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
503 }
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
504 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
505 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
506
18771
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
507 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
508 glNormal3dv (v->normal.data ());
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 glVertex3dv (v->coords.data ());
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
511
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
512 first = false;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
513 }
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
514
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
515 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
516 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
517 //printf ("patch_tesselator::combine\n");
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
518
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
519 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
520 int vmax = 4;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
521
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
522 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
523 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
524 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
525
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
526 if (vmax == 4 && ! v[i])
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
527 vmax = i;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
528 }
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 Matrix vv (1, 3, 0.0);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
531 Matrix cc;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
532 Matrix nn (1, 3, 0.0);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
533 double aa = 0.0;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
534
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
535 vv(0) = xyz[0];
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
536 vv(1) = xyz[1];
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
537 vv(2) = xyz[2];
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
538
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
539 if (v[0]->color.numel ())
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
540 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
541 cc.resize (1, 3, 0.0);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
542 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
543 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
544 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
545 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
546
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
547 if (v[0]->normal.numel () > 0)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
548 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
549 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
550 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
551 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
552 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
553
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
554 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
555 aa += (w[iv] * v[iv]->alpha);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
556
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
557 vertex_data new_v (vv, cc, nn, aa, v[0]->ambient, v[0]->diffuse,
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
558 v[0]->specular, v[0]->specular_exp, v[0]->specular_color_refl);
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
559 tmp_vdata.push_back (new_v);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
560
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
561 *out_data = new_v.get_rep ();
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
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
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
564 private:
12122
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11586
diff changeset
565
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11586
diff changeset
566 // No copying!
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11586
diff changeset
567
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11586
diff changeset
568 patch_tesselator (const patch_tesselator&);
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11586
diff changeset
569
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11586
diff changeset
570 patch_tesselator& operator = (const patch_tesselator&);
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11586
diff changeset
571
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
572 opengl_renderer *renderer;
18771
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
573 int color_mode;
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
574 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
575 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
576 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
577 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
578 };
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
579
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
580 #else
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
581
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
582 class
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
583 opengl_renderer::patch_tesselator
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
584 {
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
585 // Dummy class.
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
586 };
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
587
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
588 #endif
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
589
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
590 opengl_renderer::opengl_renderer (void)
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
591 : toolkit (), xform (), xmin (), xmax (), ymin (), ymax (),
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
592 zmin (), zmax (), xZ1 (), xZ2 (), marker_id (), filled_marker_id (),
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
593 camera_pos (), camera_dir (), interpreter ("none"), txt_renderer ()
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
594 {
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
595 // This constructor will fail if we don't have OpenGL or if the data
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
596 // types we assumed in our public interface aren't compatible with the
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
597 // OpenGL types.
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
598
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
599 #if defined (HAVE_OPENGL)
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
600
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
601 // Ensure that we can't request an image larger than OpenGL can handle.
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
602 // FIXME: should we check signed vs. unsigned?
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
603
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
604 static bool ok = (sizeof (int) <= sizeof (GLsizei));
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
605
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
606 if (! ok)
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
607 error ("the size of GLsizei is smaller than the size of int");
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
608
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
609 #else
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
610
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
611 err_disabled_feature ("opengl_renderer", "OpenGL");
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
612
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
613 #endif
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
614 }
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
615
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
616 void
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
617 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
618 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
619 if (! go.valid_object ())
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
620 return;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
621
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
622 const base_properties& props = go.get_properties ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
623
14838
1abb7c083171 Make sure opengl_renderer::toolkit is defined.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 14138
diff changeset
624 if (! toolkit)
1abb7c083171 Make sure opengl_renderer::toolkit is defined.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 14138
diff changeset
625 toolkit = props.get_toolkit ();
1abb7c083171 Make sure opengl_renderer::toolkit is defined.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 14138
diff changeset
626
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
627 if (go.isa ("figure"))
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9687
diff changeset
628 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
629 else if (go.isa ("axes"))
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9687
diff changeset
630 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
631 else if (go.isa ("line"))
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9687
diff changeset
632 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
633 else if (go.isa ("surface"))
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9687
diff changeset
634 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
635 else if (go.isa ("patch"))
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9687
diff changeset
636 draw_patch (dynamic_cast<const patch::properties&> (props));
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
637 else if (go.isa ("light"))
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
638 draw_light (dynamic_cast<const light::properties&> (props));
7866
35e8d6199455 Add hggroup support in OpenGL renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7851
diff changeset
639 else if (go.isa ("hggroup"))
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9687
diff changeset
640 draw_hggroup (dynamic_cast<const hggroup::properties&> (props));
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
641 else if (go.isa ("text"))
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9687
diff changeset
642 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
643 else if (go.isa ("image"))
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9687
diff changeset
644 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
645 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
646 || 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
647 || go.isa ("uipushtool") || go.isa ("uitoggletool"))
20946
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20738
diff changeset
648 ; // SKIP
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
649 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
650 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
651 if (toplevel)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
652 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
653 }
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
654 else
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
655 {
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
656 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
657 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
658 }
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
659 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
660
21689
9467549bd5ff * gl-render.cc: Allow compilation without OPENGL.
John W. Eaton <jwe@octave.org>
parents: 21684
diff changeset
661 #if defined (HAVE_OPENGL)
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
662
21684
1449e3b98941 store OpenGL version info in figure properties
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
663 static std::string
1449e3b98941 store OpenGL version info in figure properties
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
664 gl_get_string (GLenum id)
1449e3b98941 store OpenGL version info in figure properties
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
665 {
1449e3b98941 store OpenGL version info in figure properties
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
666 // This is kind of ugly, but glGetString returns a pointer to GLubyte
1449e3b98941 store OpenGL version info in figure properties
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
667 // and there is no std::string constructor that matches. Is there a
1449e3b98941 store OpenGL version info in figure properties
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
668 // better way?
1449e3b98941 store OpenGL version info in figure properties
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
669
1449e3b98941 store OpenGL version info in figure properties
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
670 std::ostringstream buf;
1449e3b98941 store OpenGL version info in figure properties
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
671 buf << glGetString (id);
1449e3b98941 store OpenGL version info in figure properties
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
672 return std::string (buf.str ());
1449e3b98941 store OpenGL version info in figure properties
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
673 }
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
674
21689
9467549bd5ff * gl-render.cc: Allow compilation without OPENGL.
John W. Eaton <jwe@octave.org>
parents: 21684
diff changeset
675 #endif
21684
1449e3b98941 store OpenGL version info in figure properties
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
676
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
677 void
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9687
diff changeset
678 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
679 {
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
680 // Initialize OpenGL context
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
681
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
682 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
683
21689
9467549bd5ff * gl-render.cc: Allow compilation without OPENGL.
John W. Eaton <jwe@octave.org>
parents: 21684
diff changeset
684 #if defined (HAVE_OPENGL)
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
685
21684
1449e3b98941 store OpenGL version info in figure properties
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
686 props.set___gl_extensions__ (gl_get_string (GL_EXTENSIONS));
1449e3b98941 store OpenGL version info in figure properties
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
687 props.set___gl_renderer__ (gl_get_string (GL_RENDERER));
1449e3b98941 store OpenGL version info in figure properties
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
688 props.set___gl_vendor__ (gl_get_string (GL_VENDOR));
1449e3b98941 store OpenGL version info in figure properties
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
689 props.set___gl_version__ (gl_get_string (GL_VERSION));
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
690
21689
9467549bd5ff * gl-render.cc: Allow compilation without OPENGL.
John W. Eaton <jwe@octave.org>
parents: 21684
diff changeset
691 #endif
21684
1449e3b98941 store OpenGL version info in figure properties
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
692
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
693 // Draw children
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
694
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
695 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
696 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
697
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
698 void
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
699 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
700 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
701 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
702 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
703 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
704 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
705
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
706 // 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
707
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
708 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
709 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
710
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
711 // Draw children
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
712
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
713 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
714 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
715
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
716 void
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
717 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
718 {
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
719 #if defined (HAVE_OPENGL)
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
720
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
721 // 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
722
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
723 glEnable (GL_DEPTH_TEST);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
724 glDepthFunc (GL_LEQUAL);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
725 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
726 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
727 glEnable (GL_NORMALIZE);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
728
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13219
diff changeset
729 if (enhanced)
7907
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
730 {
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
731 glEnable (GL_BLEND);
18770
be8d7721ac16 Use OpenGL line smoothing when multisample is not available.
Rik <rik@octave.org>
parents: 18769
diff changeset
732 glEnable (GL_MULTISAMPLE);
be8d7721ac16 Use OpenGL line smoothing when multisample is not available.
Rik <rik@octave.org>
parents: 18769
diff changeset
733 GLint iMultiSample, iNumSamples;
be8d7721ac16 Use OpenGL line smoothing when multisample is not available.
Rik <rik@octave.org>
parents: 18769
diff changeset
734 glGetIntegerv (GL_SAMPLE_BUFFERS, &iMultiSample);
be8d7721ac16 Use OpenGL line smoothing when multisample is not available.
Rik <rik@octave.org>
parents: 18769
diff changeset
735 glGetIntegerv (GL_SAMPLES, &iNumSamples);
be8d7721ac16 Use OpenGL line smoothing when multisample is not available.
Rik <rik@octave.org>
parents: 18769
diff changeset
736 if (iMultiSample != GL_TRUE || iNumSamples == 0)
be8d7721ac16 Use OpenGL line smoothing when multisample is not available.
Rik <rik@octave.org>
parents: 18769
diff changeset
737 {
be8d7721ac16 Use OpenGL line smoothing when multisample is not available.
Rik <rik@octave.org>
parents: 18769
diff changeset
738 // 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
739 glDisable (GL_MULTISAMPLE);
be8d7721ac16 Use OpenGL line smoothing when multisample is not available.
Rik <rik@octave.org>
parents: 18769
diff changeset
740 glEnable (GL_LINE_SMOOTH);
be8d7721ac16 Use OpenGL line smoothing when multisample is not available.
Rik <rik@octave.org>
parents: 18769
diff changeset
741 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
742 }
7907
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
743 }
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
744 else
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
745 {
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
746 glDisable (GL_BLEND);
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
747 glDisable (GL_LINE_SMOOTH);
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
748 }
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
749
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
750 // Clear background
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
751
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20055
diff changeset
752 if (c.numel () >= 3)
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
753 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
754 glClearColor (c(0), c(1), c(2), 1);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
755 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
756 }
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
757
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
758 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
759
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
760 octave_unused_parameter (enhanced);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
761 octave_unused_parameter (c);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
762
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
763 // This shouldn't happen because construction of opengl_renderer
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
764 // objects is supposed to be impossible if OpenGL is not available.
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
765
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
766 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
767
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
768 #endif
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
769 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
770
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
771 void
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
772 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
773 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
774 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
775 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
776 {
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
777 #if defined (HAVE_OPENGL)
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
778
12126
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
779 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
780 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
781 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
782 {
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
783 double val = ticks(i);
18720
04adeda9b83d Revert ea22cf3e370b and 60df2fd04293 plotting grid/ticks over axes lines.
Rik <rik@octave.org>
parents: 18705
diff changeset
784 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
785 {
18771
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
786 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
787 {
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
788 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
789 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
790 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
791 {
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
792 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
793 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
794 }
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
795 }
18771
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
796 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
797 {
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
798 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
799 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
800 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
801 {
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
802 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
803 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
804 }
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
805 }
18771
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
806 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
807 {
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
808 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
809 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
810 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
811 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
812 }
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
813 }
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
814 }
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
815 glEnd ();
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
816 set_linestyle ("-", true);
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
817
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
818 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
819
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
820 octave_unused_parameter (gridstyle);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
821 octave_unused_parameter (ticks);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
822 octave_unused_parameter (lim1);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
823 octave_unused_parameter (lim2);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
824 octave_unused_parameter (p1);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
825 octave_unused_parameter (p1N);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
826 octave_unused_parameter (p2);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
827 octave_unused_parameter (p2N);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
828 octave_unused_parameter (xyz);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
829 octave_unused_parameter (is_3D);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
830
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
831 // This shouldn't happen because construction of opengl_renderer
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
832 // objects is supposed to be impossible if OpenGL is not available.
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
833
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
834 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
835
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
836 #endif
12126
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
837 }
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
838
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
839 void
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
840 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
841 double lim1, double lim2,
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
842 double p1, double p1N,
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
843 double p2, double p2N,
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
844 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
845 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
846 {
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
847 #if defined (HAVE_OPENGL)
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
848
12126
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
849 glBegin (GL_LINES);
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
850
12126
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
851 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
852 {
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
853 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
854
18720
04adeda9b83d Revert ea22cf3e370b and 60df2fd04293 plotting grid/ticks over axes lines.
Rik <rik@octave.org>
parents: 18705
diff changeset
855 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
856 {
18771
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
857 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
858 {
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
859 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
860 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
861 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
862 {
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
863 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
864 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
865 }
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
866 }
18771
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
867 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
868 {
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
869 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
870 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
871 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
872 {
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
873 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
874 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
875 }
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
876 }
18771
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
877 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
878 {
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
879 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
880 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
881 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
882 {
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
883 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
884 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
885 }
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
886 }
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
887 }
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
888 }
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
889
12126
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
890 glEnd ();
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
891
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
892 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
893
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
894 octave_unused_parameter (ticks);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
895 octave_unused_parameter (lim1);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
896 octave_unused_parameter (lim2);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
897 octave_unused_parameter (p1);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
898 octave_unused_parameter (p1N);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
899 octave_unused_parameter (p2);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
900 octave_unused_parameter (p2N);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
901 octave_unused_parameter (dx);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
902 octave_unused_parameter (dy);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
903 octave_unused_parameter (dz);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
904 octave_unused_parameter (xyz);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
905 octave_unused_parameter (mirror);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
906
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
907 // This shouldn't happen because construction of opengl_renderer
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
908 // objects is supposed to be impossible if OpenGL is not available.
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
909
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
910 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
911
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
912 #endif
12126
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
913 }
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
914
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
915 void
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
916 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
917 const string_vector& ticklabels,
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
918 double lim1, double lim2,
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
919 double p1, double p2,
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
920 int xyz, int ha, int va,
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
921 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
922 {
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
923 #if defined (HAVE_OPENGL)
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
924
16855
359ac80ecb30 Trim ticklabel strings and repeat them as necessary to fill tick marks (bug #39344)
Rik <rik@octave.org>
parents: 15467
diff changeset
925 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
926 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
927
359ac80ecb30 Trim ticklabel strings and repeat them as necessary to fill tick marks (bug #39344)
Rik <rik@octave.org>
parents: 15467
diff changeset
928 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
929 return;
359ac80ecb30 Trim ticklabel strings and repeat them as necessary to fill tick marks (bug #39344)
Rik <rik@octave.org>
parents: 15467
diff changeset
930
359ac80ecb30 Trim ticklabel strings and repeat them as necessary to fill tick marks (bug #39344)
Rik <rik@octave.org>
parents: 15467
diff changeset
931 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
932 {
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
933 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
934
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
935 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
936 {
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
937 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
938
359ac80ecb30 Trim ticklabel strings and repeat them as necessary to fill tick marks (bug #39344)
Rik <rik@octave.org>
parents: 15467
diff changeset
939 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
940 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
941 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
942
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
943 // 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
944 // 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
945 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
946 {
16855
359ac80ecb30 Trim ticklabel strings and repeat them as necessary to fill tick marks (bug #39344)
Rik <rik@octave.org>
parents: 15467
diff changeset
947 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
948 }
18771
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
949 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
950 {
16855
359ac80ecb30 Trim ticklabel strings and repeat them as necessary to fill tick marks (bug #39344)
Rik <rik@octave.org>
parents: 15467
diff changeset
951 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
952 }
18771
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
953 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
954 {
16855
359ac80ecb30 Trim ticklabel strings and repeat them as necessary to fill tick marks (bug #39344)
Rik <rik@octave.org>
parents: 15467
diff changeset
955 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
956 }
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
957
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
958 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
959 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
960 }
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
961 }
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
962
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
963 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
964
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
965 octave_unused_parameter (ticks);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
966 octave_unused_parameter (ticklabels);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
967 octave_unused_parameter (lim1);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
968 octave_unused_parameter (lim2);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
969 octave_unused_parameter (p1);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
970 octave_unused_parameter (p2);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
971 octave_unused_parameter (xyz);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
972 octave_unused_parameter (ha);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
973 octave_unused_parameter (va);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
974 octave_unused_parameter (wmax);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
975 octave_unused_parameter (hmax);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
976
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
977 // This shouldn't happen because construction of opengl_renderer
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
978 // objects is supposed to be impossible if OpenGL is not available.
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
979
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
980 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
981
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
982 #endif
12126
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
983 }
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
984
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 12125
diff changeset
985 void
21198
1adcdc518d9e provide wrapper for glFinish in opengl_renderer class
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
986 opengl_renderer::finish (void)
1adcdc518d9e provide wrapper for glFinish in opengl_renderer class
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
987 {
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
988 #if defined (HAVE_OPENGL)
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
989
21198
1adcdc518d9e provide wrapper for glFinish in opengl_renderer class
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
990 glFinish ();
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
991
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
992 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
993
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
994 // This shouldn't happen because construction of opengl_renderer
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
995 // objects is supposed to be impossible if OpenGL is not available.
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
996
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
997 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
998
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
999 #endif
21198
1adcdc518d9e provide wrapper for glFinish in opengl_renderer class
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
1000 }
1adcdc518d9e provide wrapper for glFinish in opengl_renderer class
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
1001
1adcdc518d9e provide wrapper for glFinish in opengl_renderer class
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
1002 void
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1003 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
1004 {
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1005 #if defined (HAVE_OPENGL)
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1006
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1007 // setup OpenGL transformation
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1008
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1009 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
1010
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1011 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
1012 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
1013
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1014 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
1015 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
1016
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
1017 #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
1018 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
1019 #else
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1020 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
1021 #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
1022
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1023 glGetIntegerv (GL_VIEWPORT, vw);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1024
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1025 glMatrixMode (GL_MODELVIEW);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1026 glLoadIdentity ();
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1027 glScaled (1, 1, -1);
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1028 glMultMatrixd (x_mat1.data ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1029 glMatrixMode (GL_PROJECTION);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1030 glLoadIdentity ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1031 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
1032 glMultMatrixd (x_mat2.data ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1033 glMatrixMode (GL_MODELVIEW);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1034
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1035 glClear (GL_DEPTH_BUFFER_BIT);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1036
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1037 // store axes transformation data
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1038
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1039 xform = props.get_transform ();
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1040
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1041 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
1042
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
1043 octave_unused_parameter (props);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
1044
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1045 // This shouldn't happen because construction of opengl_renderer
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1046 // objects is supposed to be impossible if OpenGL is not available.
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1047
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1048 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
1049
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1050 #endif
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1051 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1052
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1053 void
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1054 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
1055 {
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1056 #if defined (HAVE_OPENGL)
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1057
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
1058 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
1059 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
1060 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
1061
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1062 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
1063 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
1064 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
1065 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
1066 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
1067 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
1068 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
1069
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1070 // 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
1071 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
1072 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
1073
f684f7075aee Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents: 18667
diff changeset
1074 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
1075
20055
438485f6a479 Honor the axes stack order in gl2ps outputs (bug #44765)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20034
diff changeset
1076 if (! is2d)
438485f6a479 Honor the axes stack order in gl2ps outputs (bug #44765)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20034
diff changeset
1077 {
438485f6a479 Honor the axes stack order in gl2ps outputs (bug #44765)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20034
diff changeset
1078 // X plane
438485f6a479 Honor the axes stack order in gl2ps outputs (bug #44765)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20034
diff changeset
1079 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
1080 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
1081 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
1082 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
1083
438485f6a479 Honor the axes stack order in gl2ps outputs (bug #44765)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20034
diff changeset
1084 // Y plane
438485f6a479 Honor the axes stack order in gl2ps outputs (bug #44765)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20034
diff changeset
1085 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
1086 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
1087 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
1088 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
1089 }
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
1090
f684f7075aee Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents: 18667
diff changeset
1091 // 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
1092 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
1093 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
1094 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
1095 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
1096
f684f7075aee Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents: 18667
diff changeset
1097 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
1098
f684f7075aee Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents: 18667
diff changeset
1099 set_polygon_offset (false);
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1100
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1101 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
1102
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
1103 octave_unused_parameter (props);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
1104
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1105 // This shouldn't happen because construction of opengl_renderer
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1106 // objects is supposed to be impossible if OpenGL is not available.
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1107
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1108 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
1109
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1110 #endif
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1111 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1112
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1113 void
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1114 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
1115 {
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1116 #if defined (HAVE_OPENGL)
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1117
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
1118 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
1119 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
1120
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1121 bool xySym = props.get_xySym ();
18667
e42843ceff48 Fix axes bounding box not obeying 'layer' property.
Rik <rik@octave.org>
parents: 18658
diff changeset
1122 bool layer2Dtop = props.get_layer2Dtop ();
e42843ceff48 Fix axes bounding box not obeying 'layer' property.
Rik <rik@octave.org>
parents: 18658
diff changeset
1123 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
1124 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
1125 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
1126 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
1127 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
1128 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
1129 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
1130 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
1131 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
1132 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
1133 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
1134 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
1135 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
1136
13216
434e227b100b Improvements to plotyy.
Ben Abbott <bpabbott@mac.com>
parents: 13141
diff changeset
1137 bool plotyy = (props.has_property ("__plotyy_axes__"));
12443
24b38afd6a45 fix plotyy bugs #31800, #32211
Konstantinos Poulios <logari81@googlemail.com>
parents: 12334
diff changeset
1138
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1139 // Axes box
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 set_linestyle ("-", true);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1142 set_linewidth (props.get_linewidth ());
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1143
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
1144 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
1145
f684f7075aee Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents: 18667
diff changeset
1146 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
1147 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
1148
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 // 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
1150 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
1151 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
1152 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
1153
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 if (props.is_box ())
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1155 {
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
1156 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
1157 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
1158 if (! is2d)
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1159 {
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
1160 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
1161 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
1162 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
1163 glVertex3d (xPlane, ypTick, zpTickN);
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1164 }
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
1165 }
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
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 // 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
1168 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
1169 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
1170 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
1171
f684f7075aee Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents: 18667
diff changeset
1172 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
1173 {
f684f7075aee Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents: 18667
diff changeset
1174 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
1175 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
1176
f684f7075aee Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents: 18667
diff changeset
1177 if (! is2d)
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1178 {
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
1179 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
1180 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
1181 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
1182 glVertex3d (xpTick, yPlane, zpTickN);
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1183 }
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
1184 }
f684f7075aee Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents: 18667
diff changeset
1185
f684f7075aee Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents: 18667
diff changeset
1186 // Z box
20034
42c3a0829324 Skip z axes rendering when in 2D mode (bug #44752)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19898
diff changeset
1187 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
1188 {
20034
42c3a0829324 Skip z axes rendering when in 2D mode (bug #44752)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19898
diff changeset
1189 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
1190
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1191 if (xySym)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1192 {
20034
42c3a0829324 Skip z axes rendering when in 2D mode (bug #44752)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19898
diff changeset
1193 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
1194 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
1195 }
42c3a0829324 Skip z axes rendering when in 2D mode (bug #44752)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19898
diff changeset
1196 else
42c3a0829324 Skip z axes rendering when in 2D mode (bug #44752)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19898
diff changeset
1197 {
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
1198 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
1199 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
1200 }
20034
42c3a0829324 Skip z axes rendering when in 2D mode (bug #44752)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19898
diff changeset
1201
42c3a0829324 Skip z axes rendering when in 2D mode (bug #44752)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19898
diff changeset
1202 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
1203 {
20034
42c3a0829324 Skip z axes rendering when in 2D mode (bug #44752)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19898
diff changeset
1204 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
1205 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
1206
42c3a0829324 Skip z axes rendering when in 2D mode (bug #44752)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19898
diff changeset
1207 if (xySym)
42c3a0829324 Skip z axes rendering when in 2D mode (bug #44752)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19898
diff changeset
1208 {
42c3a0829324 Skip z axes rendering when in 2D mode (bug #44752)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19898
diff changeset
1209 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
1210 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
1211 }
42c3a0829324 Skip z axes rendering when in 2D mode (bug #44752)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19898
diff changeset
1212 else
42c3a0829324 Skip z axes rendering when in 2D mode (bug #44752)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19898
diff changeset
1213 {
42c3a0829324 Skip z axes rendering when in 2D mode (bug #44752)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19898
diff changeset
1214 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
1215 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
1216 }
42c3a0829324 Skip z axes rendering when in 2D mode (bug #44752)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19898
diff changeset
1217
42c3a0829324 Skip z axes rendering when in 2D mode (bug #44752)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19898
diff changeset
1218 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
1219 glVertex3d (xPlaneN, yPlaneN, zPlane);
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1220 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1221 }
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
1222
f684f7075aee Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents: 18667
diff changeset
1223 glEnd ();
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1224
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1225 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
1226
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
1227 octave_unused_parameter (props);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
1228
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1229 // This shouldn't happen because construction of opengl_renderer
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1230 // objects is supposed to be impossible if OpenGL is not available.
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1231
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1232 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
1233
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1234 #endif
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1235 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1236
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1237 void
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1238 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
1239 {
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1240 int xstate = props.get_xstate ();
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1241
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1242 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
1243 {
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
1244 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
1245 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
1246 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
1247 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
1248 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
1249 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
1250 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
1251 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
1252 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
1253 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
1254 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
1255 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
1256 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
1257 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
1258 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
1259 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
1260 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
1261 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
1262 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
1263
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 // 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
1265
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1266 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
1267 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
1268 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
1269 bool do_xminorgrid = (props.is_xminorgrid ()
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1270 && (minorgridstyle != "none"));
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1271 bool do_xminortick = props.is_xminortick ();
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1272 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
1273 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
1274 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
1275 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
1276 int hmax = 0;
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
1277 bool tick_along_z = nearhoriz || octave::math::isinf (fy);
12684
abfcb5d5641b Disable mirrored axes ticks for plottyy in ftlk
Konstantinos Poulios <logari81@googlemail.com>
parents: 12446
diff changeset
1278 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
1279
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1280 set_color (props.get_xcolor_rgb ());
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1281
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1282 // grid lines
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1283 if (do_xgrid)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1284 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
1285 yPlane, yPlaneN, layer2Dtop ? zPlaneN : zPlane,
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1286 zPlaneN, 0, (zstate != AXE_DEPTH_DIR));
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1287
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1288 // tick marks
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1289 if (tick_along_z)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1290 {
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1291 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
1292 zpTick, zpTickN, 0., 0.,
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
1293 octave::math::signum (zpTick-zpTickN)*fz*xticklen,
12684
abfcb5d5641b Disable mirrored axes ticks for plottyy in ftlk
Konstantinos Poulios <logari81@googlemail.com>
parents: 12446
diff changeset
1294 0, mirror);
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1295 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1296 else
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1297 {
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1298 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
1299 zpTick, zpTick, 0.,
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
1300 octave::math::signum (ypTick-ypTickN)*fy*xticklen,
12684
abfcb5d5641b Disable mirrored axes ticks for plottyy in ftlk
Konstantinos Poulios <logari81@googlemail.com>
parents: 12446
diff changeset
1301 0., 0, mirror);
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1302 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1303
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1304 // tick texts
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1305 if (xticklabels.numel () > 0)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1306 {
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1307 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
1308 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
1309
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1310 if (tick_along_z)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1311 render_ticktexts (xticks, xticklabels, x_min, x_max, ypTick,
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
1312 zpTick+octave::math::signum (zpTick-zpTickN)*fz*xtickoffset,
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1313 0, halign, valign, wmax, hmax);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1314 else
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1315 render_ticktexts (xticks, xticklabels, x_min, x_max,
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
1316 ypTick+octave::math::signum (ypTick-ypTickN)*fy*xtickoffset,
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1317 zpTick, 0, halign, valign, wmax, hmax);
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 // minor grid lines
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1321 if (do_xminorgrid)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1322 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
1323 yPlane, yPlaneN, layer2Dtop ? zPlaneN : zPlane,
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1324 zPlaneN, 0, (zstate != AXE_DEPTH_DIR));
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 // minor tick marks
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1327 if (do_xminortick)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1328 {
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1329 if (tick_along_z)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1330 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
1331 zpTick, zpTickN, 0., 0.,
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
1332 octave::math::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
1333 0, mirror);
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1334 else
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1335 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
1336 zpTick, zpTick, 0.,
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
1337 octave::math::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
1338 0., 0, mirror);
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1339 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1340
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12333
diff changeset
1341 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
1342 }
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 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
1345 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1346
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1347 void
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1348 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
1349 {
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1350 int ystate = props.get_ystate ();
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1351
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1352 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
1353 {
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
1354 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
1355 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
1356 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
1357 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
1358 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
1359 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
1360 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
1361 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
1362 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
1363 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
1364 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
1365 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
1366 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
1367 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
1368 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
1369 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
1370 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
1371 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
1372 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
1373
f684f7075aee Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents: 18667
diff changeset
1374 // 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
1375
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1376 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
1377 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
1378 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
1379 bool do_yminorgrid = (props.is_yminorgrid ()
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1380 && (minorgridstyle != "none"));
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1381 bool do_yminortick = props.is_yminortick ();
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1382 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
1383 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
1384 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
1385 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
1386 int hmax = 0;
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
1387 bool tick_along_z = nearhoriz || octave::math::isinf (fx);
12684
abfcb5d5641b Disable mirrored axes ticks for plottyy in ftlk
Konstantinos Poulios <logari81@googlemail.com>
parents: 12446
diff changeset
1388 bool mirror = props.is_box () && ystate != AXE_ANY_DIR
13216
434e227b100b Improvements to plotyy.
Ben Abbott <bpabbott@mac.com>
parents: 13141
diff changeset
1389 && (! props.has_property ("__plotyy_axes__"));
12321
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 set_color (props.get_ycolor_rgb ());
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1392
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1393 // grid lines
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1394 if (do_ygrid)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1395 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
1396 xPlane, xPlaneN, layer2Dtop ? zPlaneN : zPlane,
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1397 zPlaneN, 1, (zstate != AXE_DEPTH_DIR));
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1398
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1399 // tick marks
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1400 if (tick_along_z)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1401 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
1402 zpTick, zpTickN, 0., 0.,
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
1403 octave::math::signum (zpTick-zpTickN)*fz*yticklen,
12684
abfcb5d5641b Disable mirrored axes ticks for plottyy in ftlk
Konstantinos Poulios <logari81@googlemail.com>
parents: 12446
diff changeset
1404 1, mirror);
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1405 else
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1406 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
1407 zpTick, zpTick,
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
1408 octave::math::signum (xPlaneN-xPlane)*fx*yticklen,
12684
abfcb5d5641b Disable mirrored axes ticks for plottyy in ftlk
Konstantinos Poulios <logari81@googlemail.com>
parents: 12446
diff changeset
1409 0., 0., 1, mirror);
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1410
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1411 // tick texts
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1412 if (yticklabels.numel () > 0)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1413 {
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1414 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
1415 ? 1 : (! xyzSym || y2Dright ? 0 : 2));
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1416 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
1417
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1418 if (tick_along_z)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1419 render_ticktexts (yticks, yticklabels, y_min, y_max, xpTick,
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
1420 zpTick+octave::math::signum (zpTick-zpTickN)*fz*ytickoffset,
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1421 1, halign, valign, wmax, hmax);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1422 else
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1423 render_ticktexts (yticks, yticklabels, y_min, y_max,
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
1424 xpTick+octave::math::signum (xpTick-xpTickN)*fx*ytickoffset,
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1425 zpTick, 1, halign, valign, wmax, hmax);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1426 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1427
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1428 // minor grid lines
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1429 if (do_yminorgrid)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1430 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
1431 xPlane, xPlaneN, layer2Dtop ? zPlaneN : zPlane,
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1432 zPlaneN, 1, (zstate != AXE_DEPTH_DIR));
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1433
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1434 // minor tick marks
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1435 if (do_yminortick)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1436 {
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1437 if (tick_along_z)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1438 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
1439 zpTick, zpTickN, 0., 0.,
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
1440 octave::math::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
1441 1, mirror);
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1442 else
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1443 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
1444 zpTick, zpTick,
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
1445 octave::math::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
1446 0., 0., 1, mirror);
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1447 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1448
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12333
diff changeset
1449 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
1450 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1451 else
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1452 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
1453 }
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 void
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1456 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
1457 {
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1458 int zstate = props.get_zstate ();
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1459
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1460 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
1461 {
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
1462 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
1463 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
1464 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
1465 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
1466 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
1467 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
1468 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
1469 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
1470 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
1471 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
1472 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
1473 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
1474
f684f7075aee Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents: 18667
diff changeset
1475 // 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
1476
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1477 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
1478 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
1479 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
1480 bool do_zminorgrid = (props.is_zminorgrid ()
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1481 && (minorgridstyle != "none"));
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1482 bool do_zminortick = props.is_zminortick ();
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1483 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
1484 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
1485 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
1486 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
1487 int hmax = 0;
12684
abfcb5d5641b Disable mirrored axes ticks for plottyy in ftlk
Konstantinos Poulios <logari81@googlemail.com>
parents: 12446
diff changeset
1488 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
1489
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1490 set_color (props.get_zcolor_rgb ());
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1491
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1492 // grid lines
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1493 if (do_zgrid)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1494 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
1495 xPlane, xPlaneN, yPlane, yPlaneN, 2, true);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1496
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1497 // tick marks
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1498 if (xySym)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1499 {
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
1500 if (octave::math::isinf (fy))
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1501 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
1502 yPlane, yPlane,
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
1503 octave::math::signum (xPlaneN-xPlane)*fx*zticklen,
12684
abfcb5d5641b Disable mirrored axes ticks for plottyy in ftlk
Konstantinos Poulios <logari81@googlemail.com>
parents: 12446
diff changeset
1504 0., 0., 2, mirror);
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1505 else
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1506 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
1507 yPlane, yPlane, 0.,
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
1508 octave::math::signum (yPlane-yPlaneN)*fy*zticklen,
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1509 0., 2, false);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1510 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1511 else
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1512 {
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
1513 if (octave::math::isinf (fx))
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1514 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
1515 yPlaneN, yPlane, 0.,
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
1516 octave::math::signum (yPlaneN-yPlane)*fy*zticklen,
12684
abfcb5d5641b Disable mirrored axes ticks for plottyy in ftlk
Konstantinos Poulios <logari81@googlemail.com>
parents: 12446
diff changeset
1517 0., 2, mirror);
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1518 else
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1519 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
1520 yPlaneN, yPlane,
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
1521 octave::math::signum (xPlane-xPlaneN)*fx*zticklen,
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1522 0., 0., 2, false);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1523 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1524
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1525 // FIXME: tick texts
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1526 if (zticklabels.numel () > 0)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1527 {
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1528 int halign = 2;
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1529 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
1530
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1531 if (xySym)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1532 {
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
1533 if (octave::math::isinf (fy))
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1534 render_ticktexts (zticks, zticklabels, z_min, z_max,
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
1535 xPlaneN+octave::math::signum (xPlaneN-xPlane)*fx*ztickoffset,
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1536 yPlane, 2, halign, valign, wmax, hmax);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1537 else
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1538 render_ticktexts (zticks, zticklabels, z_min, z_max, xPlaneN,
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
1539 yPlane+octave::math::signum (yPlane-yPlaneN)*fy*ztickoffset,
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1540 2, halign, valign, wmax, hmax);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1541 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1542 else
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1543 {
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
1544 if (octave::math::isinf (fx))
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1545 render_ticktexts (zticks, zticklabels, z_min, z_max, xPlane,
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
1546 yPlaneN+octave::math::signum (yPlaneN-yPlane)*fy*ztickoffset,
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1547 2, halign, valign, wmax, hmax);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1548 else
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1549 render_ticktexts (zticks, zticklabels, z_min, z_max,
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
1550 xPlane+octave::math::signum (xPlane-xPlaneN)*fx*ztickoffset,
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1551 yPlaneN, 2, halign, valign, wmax, hmax);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1552 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1553 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1554
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1555 // minor grid lines
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1556 if (do_zminorgrid)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1557 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
1558 xPlane, xPlaneN, yPlane, yPlaneN, 2, true);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1559
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1560 // minor tick marks
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1561 if (do_zminortick)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1562 {
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1563 if (xySym)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1564 {
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
1565 if (octave::math::isinf (fy))
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1566 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
1567 yPlane, yPlane,
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
1568 octave::math::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
1569 0., 0., 2, mirror);
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1570 else
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1571 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
1572 yPlane, yPlane, 0.,
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
1573 octave::math::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
1574 0., 2, false);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1575 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1576 else
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1577 {
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
1578 if (octave::math::isinf (fx))
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1579 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
1580 yPlaneN, yPlane, 0.,
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
1581 octave::math::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
1582 0., 2, mirror);
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1583 else
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1584 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
1585 yPlaneN, yPlaneN,
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
1586 octave::math::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
1587 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
1588 }
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1589 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1590
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12333
diff changeset
1591 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
1592 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1593 else
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1594 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
1595 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1596
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1597 void
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1598 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
1599 {
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1600 #if defined (HAVE_OPENGL)
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1601
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1602 // Children
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1603
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1604 Matrix children = props.get_all_children ();
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1605 std::list<graphics_object> obj_list;
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1606 std::list<graphics_object>::iterator it;
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1607
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1608 // 1st pass: draw light objects
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1609
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1610 // 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
1611 // 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
1612
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
1613 num_lights = 0;
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
1614
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1615 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
1616 {
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
1617 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
1618
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1619 if (go.get_properties ().is_visible ())
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1620 {
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1621 if (go.isa ("light"))
21459
385b67d48dda Don't enable opengl lighting when no light object is present (bug #42006)
mmuetzel <markus.muetzel@gmx.de>
parents: 21353
diff changeset
1622 {
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
1623 if (num_lights < GL_MAX_LIGHTS)
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
1624 {
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
1625 current_light = GL_LIGHT0 + num_lights;
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
1626 set_clipping (go.get_properties ().is_clipping ());
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
1627 draw (go);
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
1628 num_lights++;
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
1629 }
21459
385b67d48dda Don't enable opengl lighting when no light object is present (bug #42006)
mmuetzel <markus.muetzel@gmx.de>
parents: 21353
diff changeset
1630 }
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1631 else
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1632 obj_list.push_back (go);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1633 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1634 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1635
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
1636 // disable other OpenGL lights
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
1637 for (int i = num_lights; i < GL_MAX_LIGHTS; i++)
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
1638 glDisable (GL_LIGHT0 + i);
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
1639
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
1640 // save camera position and set ambient light color before drawing
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
1641 // other objects
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
1642 view_vector = props.get_cameraposition ().matrix_value ();
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
1643
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
1644 float cb[4] = { 1.0, 1.0, 1.0, 1.0 };
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
1645 ColumnVector ambient_color = props.get_ambientlightcolor_rgb ();
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
1646 for (int i = 0; i < 3; i++)
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
1647 cb[i] = ambient_color(i);
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
1648 glLightfv (GL_LIGHT0, GL_AMBIENT, cb);
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
1649
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1650 // 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
1651
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1652 it = obj_list.begin ();
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1653 while (it != obj_list.end ())
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1654 {
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1655 graphics_object go = (*it);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1656
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1657 // 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
1658 // to "data"
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1659 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
1660 {
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1661 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
1662 draw (go);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1663
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1664 it = obj_list.erase (it);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1665 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1666 else
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1667 it++;
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1668 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1669
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1670 // 3rd pass: draw remaining objects
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1671
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1672 glDisable (GL_DEPTH_TEST);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1673
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1674 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
1675 {
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1676 graphics_object go = (*it);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1677
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1678 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
1679 draw (go);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1680 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1681
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1682 glEnable (GL_DEPTH_TEST);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1683
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1684 set_clipping (false);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1685
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1686 // FIXME: finalize rendering (transparency processing)
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1687 // FIXME: draw zoom box, if needed
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1688
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1689 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
1690
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
1691 octave_unused_parameter (props);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
1692
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1693 // This shouldn't happen because construction of opengl_renderer
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1694 // objects is supposed to be impossible if OpenGL is not available.
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1695
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1696 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
1697
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1698 #endif
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1699 }
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1700
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1701 void
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1702 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
1703 {
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1704 #if defined (HAVE_OPENGL)
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1705
17726
d449f4668b72 Print warning and abort plot if data range > max float (bug #40246)
Rik <rik@octave.org>
parents: 17651
diff changeset
1706 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
1707
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12333
diff changeset
1708 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
1709 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
1710 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
1711 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
1712 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
1713 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
1714
17732
dcc88366f94b Print warning and abort FLTK plot if data values < -maxfloat (bug #40246)
Rik <rik@octave.org>
parents: 17728
diff changeset
1715 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
1716 || 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
1717 {
18682
8c537222f1e5 gl-render.cc: Use class prefix, opengl_renderer or opengl_texture, when printing warning.
Rik <rik@octave.org>
parents: 18677
diff changeset
1718 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
1719 return;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1720 }
17726
d449f4668b72 Print warning and abort plot if data range > max float (bug #40246)
Rik <rik@octave.org>
parents: 17651
diff changeset
1721
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1722 setup_opengl_transformation (props);
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1723
19597
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19047
diff changeset
1724 // Disable line smoothing for axes
18770
be8d7721ac16 Use OpenGL line smoothing when multisample is not available.
Rik <rik@octave.org>
parents: 18769
diff changeset
1725 GLboolean antialias;
be8d7721ac16 Use OpenGL line smoothing when multisample is not available.
Rik <rik@octave.org>
parents: 18769
diff changeset
1726 glGetBooleanv (GL_LINE_SMOOTH, &antialias);
be8d7721ac16 Use OpenGL line smoothing when multisample is not available.
Rik <rik@octave.org>
parents: 18769
diff changeset
1727 if (antialias == GL_TRUE)
be8d7721ac16 Use OpenGL line smoothing when multisample is not available.
Rik <rik@octave.org>
parents: 18769
diff changeset
1728 glDisable (GL_LINE_SMOOTH);
be8d7721ac16 Use OpenGL line smoothing when multisample is not available.
Rik <rik@octave.org>
parents: 18769
diff changeset
1729
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1730 // draw axes object
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1731
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1732 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
1733 draw_axes_boxes (props);
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1734
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
1735 set_font (props);
20285
6db2ea5556a4 Make use of the axes "ticklabelinterpreter" property (bug #45438)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20232
diff changeset
1736 set_interpreter (props.get_ticklabelinterpreter ());
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
1737
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12321
diff changeset
1738 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
1739 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
1740 draw_axes_z_grid (props);
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1741
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1742 set_linestyle ("-");
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1743
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12333
diff changeset
1744 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
1745
18770
be8d7721ac16 Use OpenGL line smoothing when multisample is not available.
Rik <rik@octave.org>
parents: 18769
diff changeset
1746 // Re-enable line smoothing for children
be8d7721ac16 Use OpenGL line smoothing when multisample is not available.
Rik <rik@octave.org>
parents: 18769
diff changeset
1747 if (antialias == GL_TRUE)
be8d7721ac16 Use OpenGL line smoothing when multisample is not available.
Rik <rik@octave.org>
parents: 18769
diff changeset
1748 glEnable (GL_LINE_SMOOTH);
be8d7721ac16 Use OpenGL line smoothing when multisample is not available.
Rik <rik@octave.org>
parents: 18769
diff changeset
1749
12321
6ba28900706b opengl_renderer::draw_axes: simplify with subfunctions
John W. Eaton <jwe@octave.org>
parents: 12174
diff changeset
1750 draw_axes_children (props);
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1751
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1752 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
1753
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
1754 octave_unused_parameter (props);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
1755
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1756 // This shouldn't happen because construction of opengl_renderer
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1757 // objects is supposed to be impossible if OpenGL is not available.
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1758
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1759 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
1760
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1761 #endif
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1762 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1763
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1764 void
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9687
diff changeset
1765 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
1766 {
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1767 #if defined (HAVE_OPENGL)
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1768
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1769 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
1770 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
1771 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
1772
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1773 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
1774 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
1775 (has_z ? z.numel ()
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1776 : std::numeric_limits<int>::max ())));
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1777 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
1778
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1779 std::vector<octave_uint8> clip (n);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1780
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1781 if (has_z)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1782 for (int i = 0; i < n; i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1783 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
1784 else
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1785 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1786 double z_mid = (zmin+zmax)/2;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1787
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1788 for (int i = 0; i < n; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1789 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
1790 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1791
20738
f90295782d60 Accept color value of "none" for line objects (bug #44224).
Rik <rik@octave.org>
parents: 20711
diff changeset
1792 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
1793 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1794 set_color (props.get_color_rgb ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1795 set_linestyle (props.get_linestyle (), false);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1796 set_linewidth (props.get_linewidth ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1797
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1798 if (has_z)
10315
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 bool flag = false;
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 i = 1; i < n; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1803 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1804 if ((clip[i-1] & clip[i]) == clip_ok)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1805 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1806 if (! flag)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1807 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1808 flag = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1809 glBegin (GL_LINE_STRIP);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1810 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
1811 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1812 glVertex3d (x(i), y(i), z(i));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1813 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1814 else if (flag)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1815 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1816 flag = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1817 glEnd ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1818 }
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
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1821 if (flag)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1822 glEnd ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1823 }
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1824 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1825 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1826 bool flag = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1827
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1828 for (int i = 1; i < n; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1829 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1830 if ((clip[i-1] & clip[i]) == clip_ok)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1831 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1832 if (! flag)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1833 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1834 flag = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1835 glBegin (GL_LINE_STRIP);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1836 glVertex2d (x(i-1), y(i-1));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1837 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1838 glVertex2d (x(i), y(i));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1839 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1840 else if (flag)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1841 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1842 flag = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1843 glEnd ();
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 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1846
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1847 if (flag)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1848 glEnd ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1849 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1850
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1851 set_linewidth (0.5);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1852 set_linestyle ("-");
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1853 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1854
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1855 set_clipping (false);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1856
19864
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19861
diff changeset
1857 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
1858 && ! (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
1859 && props.markerfacecolor_is ("none")))
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1860 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1861 Matrix lc, fc;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1862
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1863 if (props.markeredgecolor_is ("auto"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1864 lc = props.get_color_rgb ();
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1865 else if (! props.markeredgecolor_is ("none"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1866 lc = props.get_markeredgecolor_rgb ();
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1867
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1868 if (props.markerfacecolor_is ("auto"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1869 fc = props.get_color_rgb ();
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1870 else if (! props.markerfacecolor_is ("none"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1871 fc = props.get_markerfacecolor_rgb ();
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1872
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1873 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
1874 props.get_linewidth ());
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1875
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1876 for (int i = 0; i < n; i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1877 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1878 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
1879 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
1880 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
1881 lc, fc);
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1882 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1883
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1884 end_marker ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1885 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1886
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1887 set_clipping (props.is_clipping ());
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1888
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1889 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
1890
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
1891 octave_unused_parameter (props);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
1892
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1893 // This shouldn't happen because construction of opengl_renderer
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1894 // objects is supposed to be impossible if OpenGL is not available.
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1895
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1896 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
1897
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1898 #endif
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1899 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1900
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1901 void
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9687
diff changeset
1902 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
1903 {
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1904 #if defined (HAVE_OPENGL)
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1905
9681
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
1906 const Matrix x = xform.xscale (props.get_xdata ().matrix_value ());
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
1907 const Matrix y = xform.yscale (props.get_ydata ().matrix_value ());
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
1908 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
1909
18100
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17787
diff changeset
1910 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
1911 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
1912
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1913 NDArray c;
9681
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
1914 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
1915
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1916 // FIXME: handle transparency
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1917 Matrix a;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1918
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1919 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
1920 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
1921
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1922 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
1923 (props.facecolor_is ("flat") ? 1 :
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1924 (props.facecolor_is ("interp") ? 2 :
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1925 (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
1926 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
1927 (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
1928 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
1929 (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
1930 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
1931 (props.edgecolor_is ("flat") ? 1 :
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1932 (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
1933 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
1934 (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
1935 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
1936 (props.edgealpha_is ("flat") ? 1 : 2));
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
1937 int bfl_mode = (props.backfacelighting_is ("lit") ? 0 :
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
1938 (props.backfacelighting_is ("reverselit") ? 1 : 2));
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1939
18771
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
1940 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
1941 : 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
1942 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
1943
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1944 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
1945 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
1946 float ss = props.get_specularstrength ();
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
1947 float se = props.get_specularexponent () * 5; // to fit Matlab
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
1948 float scr = props.get_specularcolorreflectance ();
8674
0d263850d582 Fix calculation of diffuse reflectance. Calculate surface normals here now.
Kai Habel
parents: 8377
diff changeset
1949 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
1950 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
1951
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
1952 opengl_texture tex;
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
1953
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1954 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
1955 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
1956 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
1957
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1958 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
1959
17558
e48a22b94727 Don't plot NaN values in cdata (bug #40114).
Rik <rik@octave.org>
parents: 17269
diff changeset
1960 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
1961 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
1962
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
1963 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
1964
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1965 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
1966 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1967 if (x_mat)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1968 i1 = i;
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1969
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
1970 for (int j = 0; j < zc; j++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1971 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1972 if (y_mat)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1973 j1 = j;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1974
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1975 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
1976 }
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1977 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1978
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1979 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
1980 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1981 // FIXME: implement alphadata conversion
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1982 //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
1983 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1984
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1985 if (fl_mode > 0 || el_mode > 0)
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
1986 glMaterialf (LIGHT_MODE, GL_SHININESS, se);
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1987
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
1988 // 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
1989 // 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
1990 if (fc_mode == TEXTURE)
7831
c7925666f0bf Add OpenGL texture wrapper class (not complete yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
1991 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
1992
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
1993 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
1994 {
7846
d7737a4268b7 Fix typos in property names (edgealpha/facealpha).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7838
diff changeset
1995 if (props.get_facealpha_double () == 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1996 {
18771
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
1997 if (fc_mode == UNIFORM || fc_mode == TEXTURE)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1998 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
1999 glColor3dv (fcolor.data ());
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 i = 0; i < 3; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2003 cb[i] = as * fcolor(i);
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 i = 0; i < 3; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2007 cb[i] = ds * fcolor(i);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2008 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2009
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2010 for (int i = 0; i < 3; i++)
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2011 cb[i] = ss * (scr + (1-scr) * fcolor(i));
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2012 glMaterialfv (LIGHT_MODE, GL_SPECULAR, cb);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2013 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2014 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2015
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2016 if ((fl_mode > 0) && (num_lights > 0))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2017 glEnable (GL_LIGHTING);
18771
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
2018 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
2019 : GL_FLAT);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2020 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
2021 if (fc_mode == TEXTURE)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2022 glEnable (GL_TEXTURE_2D);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2023
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2024 for (int i = 1; i < zc; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2025 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2026 if (y_mat)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2027 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2028 i1 = i-1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2029 i2 = i;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2030 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2031
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2032 for (int j = 1; j < zr; j++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2033 {
17589
c3aadd228c37 Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents: 17558
diff changeset
2034
c3aadd228c37 Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents: 17558
diff changeset
2035 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
2036 || clip(j-1, i) || clip(j, i))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2037 continue;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2038
18771
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
2039 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
2040 {
c3aadd228c37 Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents: 17558
diff changeset
2041 // "flat" only needs color at lower-left vertex
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
2042 if (! octave::math::finite (c(j-1,i-1)))
17589
c3aadd228c37 Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents: 17558
diff changeset
2043 continue;
c3aadd228c37 Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents: 17558
diff changeset
2044 }
18771
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
2045 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
2046 {
c3aadd228c37 Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents: 17558
diff changeset
2047 // "interp" needs valid color at all 4 vertices
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
2048 if (! (octave::math::finite (c(j-1, i-1)) && octave::math::finite (c(j, i-1))
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
2049 && octave::math::finite (c(j-1, i)) && octave::math::finite (c(j, i))))
17589
c3aadd228c37 Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents: 17558
diff changeset
2050 continue;
c3aadd228c37 Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents: 17558
diff changeset
2051 }
c3aadd228c37 Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents: 17558
diff changeset
2052
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2053 if (x_mat)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2054 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2055 j1 = j-1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2056 j2 = 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
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2059 glBegin (GL_QUADS);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2060
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2061 // Vertex 1
18771
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
2062 if (fc_mode == TEXTURE)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2063 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
2064 double (j-1) / (zr-1));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2065 else if (fc_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2066 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2067 // 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
2068 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2069 cb[k] = c(j-1, i-1, k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2070 glColor3fv (cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2071
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2072 if (fl_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2073 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2074 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2075 cb[k] *= as;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2076 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2077
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2078 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2079 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
2080 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2081
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2082 for (int k = 0; k < 3; k++)
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2083 cb[k] = ss * (scr + (1-scr) * c(j-1, i-1, k));
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2084 glMaterialfv (LIGHT_MODE, GL_SPECULAR, cb);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2085 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2086 }
8674
0d263850d582 Fix calculation of diffuse reflectance. Calculate surface normals here now.
Kai Habel
parents: 8377
diff changeset
2087 if (fl_mode > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2088 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2089 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
2090 + 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
2091 + n(j-1,i-1,2) * n(j-1,i-1,2));
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2092 double dir = 1.0;
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2093 if (bfl_mode > 0)
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2094 dir = (n(j-1,i-1,0) * view_vector(0) +
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2095 n(j-1,i-1,1) * view_vector(1) +
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2096 n(j-1,i-1,2) * view_vector(2) < 0) ?
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2097 ((bfl_mode > 1) ? 0.0 : -1.0) : 1.0;
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2098 glNormal3d (dir * n(j-1,i-1,0)/d,
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2099 dir * n(j-1,i-1,1)/d,
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2100 dir * n(j-1,i-1,2)/d);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2101 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2102 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
2103
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2104 // Vertex 2
18771
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
2105 if (fc_mode == TEXTURE)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2106 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
2107 else if (fc_mode == INTERP)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2108 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2109 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2110 cb[k] = c(j-1, i, k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2111 glColor3fv (cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2112
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2113 if (fl_mode > 0)
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 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2116 cb[k] *= as;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2117 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2118
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2119 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2120 cb[k] = ds * c(j-1, i, k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2121 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2122
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2123 for (int k = 0; k < 3; k++)
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2124 cb[k] = ss * (scr + (1-scr) * c(j-1, i, k));
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2125 glMaterialfv (LIGHT_MODE, GL_SPECULAR, cb);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2126 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2127 }
8674
0d263850d582 Fix calculation of diffuse reflectance. Calculate surface normals here now.
Kai Habel
parents: 8377
diff changeset
2128
18771
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
2129 if (fl_mode == GOURAUD)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2130 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2131 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
2132 + 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
2133 + n(j-1,i,2) * n(j-1,i,2));
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2134 double dir = 1.0;
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2135 if (bfl_mode > 0)
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2136 dir = (n(j-1,i,0) * view_vector(0) +
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2137 n(j-1,i,1) * view_vector(1) +
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2138 n(j-1,i,2) * view_vector(2) < 0) ?
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2139 ((bfl_mode > 1) ? 0.0 : -1.0) : 1.0;
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2140 glNormal3d (dir * n(j-1,i,0)/d,
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2141 dir * n(j-1,i,1)/d,
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2142 dir * n(j-1,i,2)/d);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2143 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2144
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2145 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
2146
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2147 // Vertex 3
18771
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
2148 if (fc_mode == TEXTURE)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2149 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
2150 else if (fc_mode == INTERP)
10315
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 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2153 cb[k] = c(j, i, k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2154 glColor3fv (cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2155
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2156 if (fl_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2157 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2158 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2159 cb[k] *= as;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2160 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2161
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2162 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2163 cb[k] = ds * c(j, i, k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2164 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2165
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2166 for (int k = 0; k < 3; k++)
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2167 cb[k] = ss * (scr + (1-scr) * c(j, i, k));
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2168 glMaterialfv (LIGHT_MODE, GL_SPECULAR, cb);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2169 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2170 }
18771
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
2171 if (fl_mode == GOURAUD)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2172 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2173 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
2174 + n(j,i,1) * n(j,i,1)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2175 + n(j,i,2) * n(j,i,2));
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2176 double dir = 1.0;
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2177 if (bfl_mode > 0)
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2178 dir = (n(j,i,0) * view_vector(0) +
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2179 n(j,i,1) * view_vector(1) +
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2180 n(j,i,2) * view_vector(2) < 0) ?
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2181 ((bfl_mode > 1) ? 0.0 : -1.0) : 1.0;
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2182 glNormal3d (dir * n(j,i,0)/d,
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2183 dir * n(j,i,1)/d,
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2184 dir * n(j,i,2)/d);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2185 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2186 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
2187
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2188 // Vertex 4
18771
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
2189 if (fc_mode == TEXTURE)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2190 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
2191 else if (fc_mode == INTERP)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2192 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2193 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2194 cb[k] = c(j, i-1, k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2195 glColor3fv (cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2196
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2197 if (fl_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2198 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2199 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2200 cb[k] *= as;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2201 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2202
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2203 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2204 cb[k] = ds * c(j, i-1, k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2205 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2206
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2207 for (int k = 0; k < 3; k++)
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2208 cb[k] = ss * (scr + (1-scr) * c(j, i-1, k));
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2209 glMaterialfv (LIGHT_MODE, GL_SPECULAR, cb);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2210 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2211 }
18771
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
2212 if (fl_mode == GOURAUD)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2213 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2214 d = sqrt (n(j,i-1,0) * n(j,i-1,0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2215 + n(j,i-1,1) * n(j,i-1,1)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2216 + n(j,i-1,2) * n(j,i-1,2));
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2217 double dir = 1.0;
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2218 if (bfl_mode > 0)
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2219 dir = (n(j,i-1,0) * view_vector(0) +
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2220 n(j,i-1,1) * view_vector(1) +
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2221 n(j,i-1,2) * view_vector(2) < 0) ?
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2222 ((bfl_mode > 1) ? 0.0 : -1.0) : 1.0;
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2223 glNormal3d (dir * n(j,i-1,0)/d,
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2224 dir * n(j,i-1,1)/d,
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2225 dir * n(j,i-1,2)/d);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2226 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2227 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
2228
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2229 glEnd ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2230 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2231 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2232
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2233 set_polygon_offset (false);
18771
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
2234 if (fc_mode == TEXTURE)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2235 glDisable (GL_TEXTURE_2D);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2236
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2237 if ((fl_mode > 0) && (num_lights > 0))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2238 glDisable (GL_LIGHTING);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2239 }
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2240 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2241 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2242 // FIXME: implement transparency
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2243 }
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2244 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2245
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2246 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
2247 {
7846
d7737a4268b7 Fix typos in property names (edgealpha/facealpha).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7838
diff changeset
2248 if (props.get_edgealpha_double () == 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2249 {
18771
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
2250 if (ec_mode == UNIFORM)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2251 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2252 glColor3dv (ecolor.data ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2253 if (fl_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2254 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2255 for (int i = 0; i < 3; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2256 cb[i] = as * ecolor(i);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2257 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2258
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2259 for (int i = 0; i < 3; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2260 cb[i] = ds * ecolor(i);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2261 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2262
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2263 for (int i = 0; i < 3; i++)
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2264 cb[i] = ss * (scr + (1-scr) * ecolor(i));
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2265 glMaterialfv (LIGHT_MODE, GL_SPECULAR, cb);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2266 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2267 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2268
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2269 if ((el_mode > 0) && (num_lights > 0))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2270 glEnable (GL_LIGHTING);
18771
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
2271 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
2272 : GL_FLAT);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2273
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2274 set_linestyle (props.get_linestyle (), false);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2275 set_linewidth (props.get_linewidth ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2276
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2277 // Mesh along Y-axis
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2278
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2279 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
2280 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2281 for (int i = 0; i < zc; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2282 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2283 if (y_mat)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2284 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2285 i1 = i-1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2286 i2 = i;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2287 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2288
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2289 for (int j = 1; j < zr; j++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2290 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2291 if (clip(j-1,i) || clip(j,i))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2292 continue;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2293
18771
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
2294 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
2295 {
c3aadd228c37 Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents: 17558
diff changeset
2296 // "flat" only needs color at lower-left vertex
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
2297 if (! octave::math::finite (c(j-1,i)))
17589
c3aadd228c37 Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents: 17558
diff changeset
2298 continue;
c3aadd228c37 Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents: 17558
diff changeset
2299 }
18771
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
2300 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
2301 {
c3aadd228c37 Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents: 17558
diff changeset
2302 // "interp" needs valid color at both vertices
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
2303 if (! (octave::math::finite (c(j-1, i)) && octave::math::finite (c(j, i))))
17589
c3aadd228c37 Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents: 17558
diff changeset
2304 continue;
c3aadd228c37 Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents: 17558
diff changeset
2305 }
c3aadd228c37 Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents: 17558
diff changeset
2306
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2307 if (x_mat)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2308 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2309 j1 = j-1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2310 j2 = j;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2311 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2312
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2313 glBegin (GL_LINES);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2314
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2315 // Vertex 1
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2316 if (ec_mode > 0)
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 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2319 cb[k] = c(j-1, i, k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2320 glColor3fv (cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2321
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2322 if (fl_mode > 0)
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 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2325 cb[k] *= as;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2326 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2327
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2328 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2329 cb[k] = ds * c(j-1, i, k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2330 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2331
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2332 for (int k = 0; k < 3; k++)
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2333 cb[k] = ss * (scr + (1-scr) * c(j-1, i, k));
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2334 glMaterialfv (LIGHT_MODE, GL_SPECULAR, cb);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2335 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2336 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2337 if (el_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2338 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2339 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
2340 + 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
2341 + n(j-1,i,2) * n(j-1,i,2));
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2342 double dir = 1.0;
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2343 if (bfl_mode > 0)
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2344 dir = (n(j-1,i,0) * view_vector(0) +
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2345 n(j-1,i,1) * view_vector(1) +
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2346 n(j-1,i,2) * view_vector(2) < 0) ?
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2347 ((bfl_mode > 1) ? 0.0 : -1.0) : 1.0;
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2348 glNormal3d (dir * n(j-1,i,0)/d,
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2349 dir * n(j-1,i,1)/d,
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2350 dir * n(j-1,i,2)/d);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2351 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2352 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
2353
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2354 // Vertex 2
18771
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
2355 if (ec_mode == INTERP)
10315
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 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2358 cb[k] = c(j, i, k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2359 glColor3fv (cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2360
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2361 if (fl_mode > 0)
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 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2364 cb[k] *= as;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2365 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2366
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2367 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2368 cb[k] = ds * c(j, i, k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2369 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2370
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2371 for (int k = 0; k < 3; k++)
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2372 cb[k] = ss * (scr + (1-scr) * c(j, i, k));
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2373 glMaterialfv (LIGHT_MODE, GL_SPECULAR, cb);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2374 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2375 }
18771
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
2376 if (el_mode == GOURAUD)
8674
0d263850d582 Fix calculation of diffuse reflectance. Calculate surface normals here now.
Kai Habel
parents: 8377
diff changeset
2377 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2378 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
2379 + n(j,i,1) * n(j,i,1)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2380 + n(j,i,2) * n(j,i,2));
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2381 double dir = 1.0;
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2382 if (bfl_mode > 0)
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2383 dir = (n(j,i,0) * view_vector(0) +
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2384 n(j,i,1) * view_vector(1) +
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2385 n(j,i,2) * view_vector(2) < 0) ?
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2386 ((bfl_mode > 1) ? 0.0 : -1.0) : 1.0;
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2387 glNormal3d (dir * n(j,i,0)/d,
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2388 dir * n(j,i,1)/d,
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2389 dir * n(j,i,2)/d);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2390 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2391 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
2392
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2393 glEnd ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2394 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2395 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2396 }
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 // Mesh along X-axis
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2399
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2400 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
2401 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2402 for (int j = 0; j < zr; j++)
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 (x_mat)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2405 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2406 j1 = j-1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2407 j2 = j;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2408 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2409
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2410 for (int i = 1; i < zc; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2411 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2412 if (clip(j,i-1) || clip(j,i))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2413 continue;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2414
18771
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
2415 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
2416 {
c3aadd228c37 Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents: 17558
diff changeset
2417 // "flat" only needs color at lower-left vertex
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
2418 if (! octave::math::finite (c(j,i-1)))
17589
c3aadd228c37 Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents: 17558
diff changeset
2419 continue;
c3aadd228c37 Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents: 17558
diff changeset
2420 }
18771
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
2421 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
2422 {
c3aadd228c37 Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents: 17558
diff changeset
2423 // "interp" needs valid color at both vertices
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
2424 if (! (octave::math::finite (c(j, i-1)) && octave::math::finite (c(j, i))))
17589
c3aadd228c37 Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents: 17558
diff changeset
2425 continue;
c3aadd228c37 Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents: 17558
diff changeset
2426 }
c3aadd228c37 Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents: 17558
diff changeset
2427
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2428 if (y_mat)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2429 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2430 i1 = i-1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2431 i2 = i;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2432 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2433
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2434 glBegin (GL_LINES);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2435
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2436 // Vertex 1
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2437 if (ec_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2438 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2439 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2440 cb[k] = c(j, i-1, k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2441 glColor3fv (cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2442
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2443 if (fl_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2444 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2445 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2446 cb[k] *= as;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2447 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2448
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2449 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2450 cb[k] = ds * c(j, i-1, k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2451 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2452
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2453 for (int k = 0; k < 3; k++)
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2454 cb[k] = ss * (scr + (1-scr) * c(j, i-1, k));
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2455 glMaterialfv (LIGHT_MODE, GL_SPECULAR, cb);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2456 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2457 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2458 if (el_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2459 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2460 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
2461 + 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
2462 + n(j,i-1,2) * n(j,i-1,2));
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2463 double dir = 1.0;
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2464 if (bfl_mode > 0)
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2465 dir = (n(j,i-1,0) * view_vector(0) +
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2466 n(j,i-1,1) * view_vector(1) +
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2467 n(j,i-1,2) * view_vector(2) < 0) ?
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2468 ((bfl_mode > 1) ? 0.0 : -1.0) : 1.0;
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2469 glNormal3d (dir * n(j,i-1,0)/d,
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2470 dir * n(j,i-1,1)/d,
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2471 dir * n(j,i-1,2)/d);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2472 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2473 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
2474
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2475 // Vertex 2
18771
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
2476 if (ec_mode == INTERP)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2477 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2478 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2479 cb[k] = c(j, i, k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2480 glColor3fv (cb);
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 if (fl_mode > 0)
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 k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2485 cb[k] *= as;
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 k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2489 cb[k] = ds * c(j, i, k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2490 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2491
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2492 for (int k = 0; k < 3; k++)
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2493 cb[k] = ss * (scr + (1-scr) * c(j, i, k));
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2494 glMaterialfv (LIGHT_MODE, GL_SPECULAR, cb);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2495 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2496 }
18771
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
2497 if (el_mode == GOURAUD)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2498 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2499 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
2500 + n(j,i,1) * n(j,i,1)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2501 + n(j,i,2) * n(j,i,2));
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2502 double dir = 1.0;
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2503 if (bfl_mode > 0)
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2504 dir = (n(j,i,0) * view_vector(0) +
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2505 n(j,i,1) * view_vector(1) +
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2506 n(j,i,2) * view_vector(2) < 0) ?
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2507 ((bfl_mode > 1) ? 0.0 : -1.0) : 1.0;
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2508 glNormal3d (dir * n(j,i,0)/d,
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2509 dir * n(j,i,1)/d,
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2510 dir * n(j,i,2)/d);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2511 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2512 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
2513
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2514 glEnd ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2515 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2516 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2517 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2518
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2519 set_linestyle ("-");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2520 set_linewidth (0.5);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2521
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2522 if ((el_mode > 0) && (num_lights > 0))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2523 glDisable (GL_LIGHTING);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2524 }
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2525 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2526 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2527 // FIXME: implement transparency
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2528 }
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2529 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2530
19864
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19861
diff changeset
2531 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
2532 && ! (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
2533 && 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
2534 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2535 // 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
2536 // 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
2537 // 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
2538
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2539 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
2540 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
2541
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2542 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
2543 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
2544 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
2545
20974
1edf15793cac maint: Use is_empty rather than "numel () == 0" for clarity.
Rik <rik@octave.org>
parents: 20955
diff changeset
2546 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
2547 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2548 mecolor = props.get_edgecolor_rgb ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2549 do_edge = ! props.edgecolor_is ("none");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2550 }
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2551
20974
1edf15793cac maint: Use is_empty rather than "numel () == 0" for clarity.
Rik <rik@octave.org>
parents: 20955
diff changeset
2552 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
2553 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2554 mfcolor = props.get_facecolor_rgb ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2555 do_face = ! props.facecolor_is ("none");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2556 }
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2557
20974
1edf15793cac maint: Use is_empty rather than "numel () == 0" for clarity.
Rik <rik@octave.org>
parents: 20955
diff changeset
2558 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
2559 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
2560
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2561 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
2562 props.get_linewidth ());
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2563
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2564 for (int i = 0; i < zc; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2565 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2566 if (y_mat)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2567 i1 = i;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2568
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2569 for (int j = 0; j < zr; j++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2570 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2571 if (clip(j,i))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2572 continue;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2573
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2574 if (x_mat)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2575 j1 = j;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2576
20974
1edf15793cac maint: Use is_empty rather than "numel () == 0" for clarity.
Rik <rik@octave.org>
parents: 20955
diff changeset
2577 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
2578 || (do_face && mfcolor.is_empty ()))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2579 {
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
2580 if (! octave::math::finite (c(j,i)))
17589
c3aadd228c37 Fix surf/mesh handling of NaN values in cdata (transparent) (bug #32275).
Rik <rik@octave.org>
parents: 17558
diff changeset
2581 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
2582
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2583 for (int k = 0; k < 3; k++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2584 cc(k) = c(j,i,k);
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
20974
1edf15793cac maint: Use is_empty rather than "numel () == 0" for clarity.
Rik <rik@octave.org>
parents: 20955
diff changeset
2587 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
2588 : Matrix ());
20974
1edf15793cac maint: Use is_empty rather than "numel () == 0" for clarity.
Rik <rik@octave.org>
parents: 20955
diff changeset
2589 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
2590 : Matrix ());
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2591
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2592 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
2593 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2594 }
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2595
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2596 end_marker ();
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2597 }
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2598
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2599 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
2600
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
2601 octave_unused_parameter (props);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
2602
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2603 // This shouldn't happen because construction of opengl_renderer
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2604 // objects is supposed to be impossible if OpenGL is not available.
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2605
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2606 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
2607
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2608 #endif
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2609 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
2610
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
2611 // 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
2612 // 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
2613 void
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9687
diff changeset
2614 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
2615 {
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2616 #if defined (HAVE_OPENGL)
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2617
18901
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18817
diff changeset
2618 // 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
2619 std::string msg;
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18817
diff changeset
2620 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
2621 {
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21724
diff changeset
2622 warning ("opengl_renderer: %s. Not rendering.", msg.c_str ());
18901
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18817
diff changeset
2623 return;
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18817
diff changeset
2624 }
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18817
diff changeset
2625
9681
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
2626 const Matrix f = props.get_faces ().matrix_value ();
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
2627 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
2628 Matrix c;
9681
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
2629 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
2630 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
2631
7870
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
2632 int nv = v.rows ();
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
2633 int nf = f.rows ();
b1823dfd6ec7 style fixes
John W. Eaton <jwe@octave.org>
parents: 7866
diff changeset
2634 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
2635
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2636 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
2637 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
2638 bool has_facealpha = false;
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2639 // FIXME: remove when patch object has normal computation (patch #8951)
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2640 bool has_normals = (n.rows () == nv);
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
2641
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
2642 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
2643 || 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
2644 (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
2645 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
2646 (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
2647 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
2648 (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
2649 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
2650 || 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
2651 (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
2652 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
2653 (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
2654 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
2655 (props.edgealpha_is ("flat") ? 1 : 2));
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2656 int bfl_mode = (props.backfacelighting_is ("lit") ? 0 :
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2657 (props.backfacelighting_is ("reverselit") ? 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
2658
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2659 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
2660 Matrix ecolor = props.get_edgecolor_rgb ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2661
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
2662 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
2663 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
2664 float ss = props.get_specularstrength ();
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2665 float se = props.get_specularexponent () * 5; // to fit Matlab
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2666 float scr = props.get_specularcolorreflectance ();
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
2667
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2668 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
2669
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2670 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
2671 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
2672 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
2673 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
2674 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
2675 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
2676
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2677 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
2678 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
2679
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2680 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
2681 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2682 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
2683 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
2684
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
2685 for (int j = 0; j < fcmax && ! octave::math::isnan (f(i,j)); j++, count++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2686 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
2687
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2688 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
2689 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
2690 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2691
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2692 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
2693 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2694 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
2695
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2696 if (c.rows () == 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2697 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2698 // 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
2699
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2700 if (fc_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2701 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2702 fcolor = c;
18771
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
2703 fc_mode = UNIFORM;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2704 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2705
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2706 if (ec_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2707 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2708 ecolor = c;
18771
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
2709 ec_mode = UNIFORM;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2710 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2711
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2712 c = Matrix ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2713 }
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
2714 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2715 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
2716 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2717
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2718 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
2719 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2720 // 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
2721 //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
2722 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
2723 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2724
7924
4976f66d469b miscellaneous cleanup
John W. Eaton <jwe@octave.org>
parents: 7914
diff changeset
2725 octave_idx_type fr = f.rows ();
7914
e998e81224b5 Various compilation fixes for MSVC.
John W. Eaton <jwe@octave.org>
parents: 7907
diff changeset
2726 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
2727
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2728 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
2729 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
2730 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2731 int idx = int (f(i,j) - 1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2732
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2733 Matrix vv (1, 3, 0.0);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2734 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
2735 Matrix nn (1, 3, 0.0);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2736 double aa = 1.0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2737
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2738 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
2739 if (has_z)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2740 vv(2) = v(idx,2);
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2741 if (has_normals)
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2742 {
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2743 double dir = 1.0;
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2744 if (bfl_mode > 0)
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2745 dir = (n(idx,0) * view_vector(0) +
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2746 n(idx,1) * view_vector(1) +
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2747 n(idx,2) * view_vector(2) < 0) ?
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2748 ((bfl_mode > 1) ? 0.0 : -1.0) : 1.0;
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2749 nn(0) = dir * n(idx,0);
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2750 nn(1) = dir * n(idx,1);
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2751 nn(2) = dir * n(idx,2);
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2752 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2753 if (c.numel () > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2754 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2755 cc.resize (1, 3);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2756 if (has_facecolor)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2757 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
2758 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2759 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
2760 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2761 if (a.numel () > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2762 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2763 if (has_facealpha)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2764 aa = a(i);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2765 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2766 aa = a(idx);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2767 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2768
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2769 vdata[i+j*fr] = vertex_data (vv, cc, nn, aa, as, ds, ss, se, scr);
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
2770 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2771
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2772 if (fl_mode > 0 || el_mode > 0)
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2773 glMaterialf (LIGHT_MODE, GL_SHININESS, 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
2774
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2775 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
2776 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2777 // 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
2778 if (props.get_facealpha_double () == 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2779 {
18771
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
2780 if (fc_mode == UNIFORM)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2781 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2782 glColor3dv (fcolor.data ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2783 if (fl_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2784 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2785 float cb[4] = { 0, 0, 0, 1 };
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2786
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2787 for (int i = 0; i < 3; i++)
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2788 cb[i] = as * fcolor(i);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2789 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2790
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2791 for (int i = 0; i < 3; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2792 cb[i] = ds * fcolor(i);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2793 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2794
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2795 for (int i = 0; i < 3; i++)
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2796 cb[i] = ss * (scr + (1-scr) * fcolor(i));
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2797 glMaterialfv (LIGHT_MODE, GL_SPECULAR, cb);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2798 }
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
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2801 if ((fl_mode > 0) && (num_lights > 0) && has_normals)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2802 glEnable (GL_LIGHTING);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2803
18768
75f8926deef1 Fix Z-order stacking of patches and axes grid lines (bug #40722).
Rik <rik@octave.org>
parents: 18720
diff changeset
2804 // 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
2805 // 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
2806 // 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
2807 // 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
2808 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
2809
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2810 for (int i = 0; i < nf; i++)
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 if (clip_f(i))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2813 continue;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2814
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2815 tess.begin_polygon (true);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2816 tess.begin_contour ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2817
18295
2ed9498e4a74 Change diagonal of FaceColor interpolation for patch objects to match Matlab.
Rik <rik@octave.org>
parents: 18134
diff changeset
2818 // 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
2819 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
2820 {
2ed9498e4a74 Change diagonal of FaceColor interpolation for patch objects to match Matlab.
Rik <rik@octave.org>
parents: 18134
diff changeset
2821 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
2822
2ed9498e4a74 Change diagonal of FaceColor interpolation for patch objects to match Matlab.
Rik <rik@octave.org>
parents: 18134
diff changeset
2823 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
2824 }
2ed9498e4a74 Change diagonal of FaceColor interpolation for patch objects to match Matlab.
Rik <rik@octave.org>
parents: 18134
diff changeset
2825
18134
647d806868ee Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents: 18100
diff changeset
2826 if (count_f(i) > 0)
647d806868ee Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents: 18100
diff changeset
2827 {
647d806868ee Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents: 18100
diff changeset
2828 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
2829
18771
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
2830 if (fc_mode == FLAT)
18134
647d806868ee Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents: 18100
diff changeset
2831 {
647d806868ee Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents: 18100
diff changeset
2832 // 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
2833 Matrix col = vv->color;
647d806868ee Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents: 18100
diff changeset
2834
647d806868ee Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents: 18100
diff changeset
2835 if (col.numel () == 3)
647d806868ee Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents: 18100
diff changeset
2836 {
647d806868ee Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents: 18100
diff changeset
2837 glColor3dv (col.data ());
647d806868ee Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents: 18100
diff changeset
2838 if (fl_mode > 0)
647d806868ee Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents: 18100
diff changeset
2839 {
647d806868ee Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents: 18100
diff changeset
2840 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
2841
647d806868ee Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents: 18100
diff changeset
2842 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
2843 cb[k] = (vv->ambient * col(k));
647d806868ee Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents: 18100
diff changeset
2844 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
647d806868ee Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents: 18100
diff changeset
2845
647d806868ee Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents: 18100
diff changeset
2846 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
2847 cb[k] = (vv->diffuse * col(k));
647d806868ee Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents: 18100
diff changeset
2848 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2849
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2850 for (int k = 0; k < 3; k++)
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2851 cb[k] = vv->specular * (vv->specular_color_refl
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2852 + (1-vv->specular_color_refl) * col(k));
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2853 glMaterialfv (LIGHT_MODE, GL_SPECULAR, cb);
18134
647d806868ee Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents: 18100
diff changeset
2854 }
647d806868ee Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents: 18100
diff changeset
2855 }
647d806868ee Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents: 18100
diff changeset
2856 }
647d806868ee Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents: 18100
diff changeset
2857
647d806868ee Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents: 18100
diff changeset
2858 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
2859 }
647d806868ee Color patch face based upon first vertex (bug #40247).
Rik <rik@octave.org>
parents: 18100
diff changeset
2860
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2861 tess.end_contour ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2862 tess.end_polygon ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2863 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2864
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2865 if ((fl_mode > 0) && (num_lights > 0) && has_normals)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2866 glDisable (GL_LIGHTING);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2867 }
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
2868 else
10315
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 // FIXME: implement transparency
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2871 }
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
2872 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2873
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2874 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
2875 {
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
2876 // 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
2877 if (props.get_edgealpha_double () == 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2878 {
18771
79f69742971a gl-render.cc: Use enum symbolic constants for code clarity.
Rik <rik@octave.org>
parents: 18770
diff changeset
2879 if (ec_mode == UNIFORM)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2880 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2881 glColor3dv (ecolor.data ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2882 if (el_mode > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2883 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2884 float cb[4] = { 0, 0, 0, 1 };
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2885
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2886 for (int i = 0; i < 3; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2887 cb[i] = (as * ecolor(i));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2888 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2889
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2890 for (int i = 0; i < 3; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2891 cb[i] = ds * ecolor(i);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2892 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2893
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2894 for (int i = 0; i < 3; i++)
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2895 cb[i] = ss * (scr + (1-scr) * ecolor(i));
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2896 glMaterialfv (LIGHT_MODE, GL_SPECULAR, cb);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2897 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2898 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2899
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2900 if ((el_mode > 0) && (num_lights > 0) && has_normals)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2901 glEnable (GL_LIGHTING);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2902
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2903 set_linestyle (props.get_linestyle (), false);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2904 set_linewidth (props.get_linewidth ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2905
18768
75f8926deef1 Fix Z-order stacking of patches and axes grid lines (bug #40722).
Rik <rik@octave.org>
parents: 18720
diff changeset
2906 // 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
2907 // 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
2908 // 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
2909 // 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
2910 // 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
2911 patch_tesselator tess (this, ec_mode, el_mode);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2912
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2913 for (int i = 0; i < nf; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2914 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2915 if (clip_f(i))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2916 {
18817
096b1a159d1f Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents: 18771
diff changeset
2917 // 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
2918 bool flag = false;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2919
18817
096b1a159d1f Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents: 18771
diff changeset
2920 glShadeModel ((ec_mode == INTERP || el_mode == GOURAUD)
096b1a159d1f Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents: 18771
diff changeset
2921 ? GL_SMOOTH : GL_FLAT);
096b1a159d1f Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents: 18771
diff changeset
2922
096b1a159d1f Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents: 18771
diff changeset
2923 // 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
2924 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
2925 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2926 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
2927 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2928 vertex_data::vertex_data_rep *vv
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2929 = 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
2930 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
2931 if (! flag)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2932 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2933 flag = true;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2934 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
2935 }
18817
096b1a159d1f Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents: 18771
diff changeset
2936 if (ec_mode != UNIFORM)
096b1a159d1f Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents: 18771
diff changeset
2937 {
096b1a159d1f Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents: 18771
diff changeset
2938 Matrix col = vv->color;
096b1a159d1f Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents: 18771
diff changeset
2939
096b1a159d1f Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents: 18771
diff changeset
2940 if (col.numel () == 3)
096b1a159d1f Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents: 18771
diff changeset
2941 glColor3dv (col.data ());
096b1a159d1f Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents: 18771
diff changeset
2942 }
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2943 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
2944 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2945 else if (flag)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2946 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2947 flag = false;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2948 glEnd ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2949 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2950 }
18817
096b1a159d1f Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents: 18771
diff changeset
2951 // 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
2952 // from vertex 0 to vertex N.
096b1a159d1f Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents: 18771
diff changeset
2953 int j = count_f(i)-1;
096b1a159d1f Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents: 18771
diff changeset
2954 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
2955 {
096b1a159d1f Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents: 18771
diff changeset
2956 vertex_data::vertex_data_rep *vv
096b1a159d1f Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents: 18771
diff changeset
2957 = vdata[i+j*fr].get_rep ();
096b1a159d1f Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents: 18771
diff changeset
2958 const Matrix m = vv->coords;
096b1a159d1f Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents: 18771
diff changeset
2959 if (ec_mode != UNIFORM)
096b1a159d1f Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents: 18771
diff changeset
2960 {
096b1a159d1f Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents: 18771
diff changeset
2961 Matrix col = vv->color;
096b1a159d1f Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents: 18771
diff changeset
2962
096b1a159d1f Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents: 18771
diff changeset
2963 if (col.numel () == 3)
096b1a159d1f Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents: 18771
diff changeset
2964 glColor3dv (col.data ());
096b1a159d1f Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents: 18771
diff changeset
2965 }
096b1a159d1f Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents: 18771
diff changeset
2966 glVertex3d (m(0), m(1), m(2));
096b1a159d1f Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents: 18771
diff changeset
2967 }
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2968
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2969 if (flag)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2970 glEnd ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2971 }
18817
096b1a159d1f Correctly render unclosed contour of a patch object.
Rik <rik@octave.org>
parents: 18771
diff changeset
2972 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
2973 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2974 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
2975 tess.begin_contour ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2976
18296
c8d6ca222bcc Make "edgecolor"="flat" for patch objects compatible with Matlab.
Rik <rik@octave.org>
parents: 18295
diff changeset
2977 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
2978 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2979 vertex_data::vertex_data_rep *vv
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2980 = 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
2981 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
2982 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2983
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2984 tess.end_contour ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2985 tess.end_polygon ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2986 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2987 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2988
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2989 set_linestyle ("-");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2990 set_linewidth (0.5);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2991
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
2992 if ((el_mode > 0) && (num_lights > 0) && has_normals)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2993 glDisable (GL_LIGHTING);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2994 }
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
2995 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2996 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2997 // FIXME: implement transparency
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
2998 }
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
2999 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
3000
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3001 if (! props.marker_is ("none")
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3002 && ! (props.markeredgecolor_is ("none")
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3003 && 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
3004 {
7838
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
3005 bool do_edge = ! props.markeredgecolor_is ("none");
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
3006 bool do_face = ! props.markerfacecolor_is ("none");
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
3007
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
3008 Matrix mecolor = props.get_markeredgecolor_rgb ();
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
3009 Matrix mfcolor = props.get_markerfacecolor_rgb ();
12446
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
3010
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
3011 bool has_markerfacecolor = false;
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
3012
20974
1edf15793cac maint: Use is_empty rather than "numel () == 0" for clarity.
Rik <rik@octave.org>
parents: 20955
diff changeset
3013 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
3014 || (mfcolor.is_empty () && ! props.markerfacecolor_is ("none")))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3015 {
12446
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
3016 Matrix mc = props.get_color_data ().matrix_value ();
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
3017
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
3018 if (mc.rows () == 1)
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
3019 {
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
3020 // 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
3021 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
3022 mfcolor = mc;
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
3023
20974
1edf15793cac maint: Use is_empty rather than "numel () == 0" for clarity.
Rik <rik@octave.org>
parents: 20955
diff changeset
3024 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
3025 mecolor = mc;
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
3026 }
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
3027 else
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
3028 {
20974
1edf15793cac maint: Use is_empty rather than "numel () == 0" for clarity.
Rik <rik@octave.org>
parents: 20955
diff changeset
3029 if (c.is_empty ())
12446
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
3030 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
3031 has_markerfacecolor = ((c.numel () > 0)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3032 && (c.rows () == f.rows ()));
12446
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
3033 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3034 }
7838
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
3035
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
3036
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
3037 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
3038 props.get_linewidth ());
7838
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
3039
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
3040 for (int i = 0; i < nf; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3041 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
3042 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3043 int idx = int (f(i,j) - 1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3044
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3045 if (clip(idx))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3046 continue;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3047
12446
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
3048 Matrix cc;
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
3049 if (c.numel () > 0)
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
3050 {
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
3051 cc.resize (1, 3);
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
3052 if (has_markerfacecolor)
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
3053 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
3054 else
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
3055 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
3056 }
f899f451fe76 Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents: 12443
diff changeset
3057
20974
1edf15793cac maint: Use is_empty rather than "numel () == 0" for clarity.
Rik <rik@octave.org>
parents: 20955
diff changeset
3058 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
3059 : Matrix ());
20974
1edf15793cac maint: Use is_empty rather than "numel () == 0" for clarity.
Rik <rik@octave.org>
parents: 20955
diff changeset
3060 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
3061 : Matrix ());
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3062
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3063 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
3064 }
7838
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
3065
0a2ba0053fbd Render marker of patch objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7837
diff changeset
3066 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
3067 }
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3068
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3069 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3070
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3071 octave_unused_parameter (props);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3072
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3073 // This shouldn't happen because construction of opengl_renderer
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3074 // objects is supposed to be impossible if OpenGL is not available.
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3075
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3076 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3077
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3078 #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
3079 }
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7831
diff changeset
3080
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7825
diff changeset
3081 void
21789
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
3082 opengl_renderer::draw_light (const light::properties &props)
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
3083 {
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
3084 #if defined (HAVE_OPENGL)
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
3085
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
3086 // enable light source
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
3087 glEnable (current_light);
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
3088
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
3089 // light position
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
3090 float pos[4] = { 0, 0, 0, 0 }; // X,Y,Z,attenuation
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
3091 Matrix lpos = props.get_position ().matrix_value ();
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
3092 for (int i = 0; i < 3; i++)
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
3093 pos[i] = lpos(i);
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
3094 glLightfv (current_light, GL_POSITION, pos);
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
3095
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
3096 // light color
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
3097 float col[4] = { 1, 1, 1, 1 }; // R,G,B,ALPHA (the latter has no meaning)
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
3098 Matrix lcolor = props.get_color ().matrix_value ();
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
3099 for (int i = 0; i < 3; i++)
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
3100 col[i] = lcolor(i);
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
3101 glLightfv (current_light, GL_DIFFUSE, col);
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
3102 glLightfv (current_light, GL_SPECULAR, col);
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
3103
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
3104 #else
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
3105
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
3106 octave_unused_parameter (props);
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
3107
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
3108 // This shouldn't happen because construction of opengl_renderer
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
3109 // objects is supposed to be impossible if OpenGL is not available.
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
3110
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
3111 panic_impossible ();
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
3112
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
3113 #endif
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
3114 }
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
3115
6afdf40be534 Implement graphics object "light" (patch #8943).
mmuetzel <markus.muetzel@gmx.de>
parents: 21782
diff changeset
3116 void
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9687
diff changeset
3117 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
3118 {
35e8d6199455 Add hggroup support in OpenGL renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7851
diff changeset
3119 draw (props.get_children ());
35e8d6199455 Add hggroup support in OpenGL renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7851
diff changeset
3120 }
35e8d6199455 Add hggroup support in OpenGL renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7851
diff changeset
3121
35e8d6199455 Add hggroup support in OpenGL renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7851
diff changeset
3122 void
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9687
diff changeset
3123 opengl_renderer::draw_text (const text::properties& props)
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3124 {
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3125 #if defined (HAVE_OPENGL)
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3126
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
3127 if (props.get_string ().is_empty ())
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3128 return;
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3129
19047
1288a2f27769 Handle non "points" fontunits properties (bug # 40158)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18906
diff changeset
3130 set_font (props);
1288a2f27769 Handle non "points" fontunits properties (bug # 40158)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18906
diff changeset
3131
13961
0fea4cf22f88 restore legend text with OpenGL + FLTK graphics (bug #34907)
John W. Eaton <jwe@octave.org>
parents: 13758
diff changeset
3132 Matrix pos = xform.scale (props.get_data_position ());
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
3133 const Matrix bbox = props.get_extent_matrix ();
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3134
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3135 // FIXME: handle margin and surrounding box
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
3136 bool blend = glIsEnabled (GL_BLEND);
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
3137
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
3138 glEnable (GL_BLEND);
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
3139 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
3140 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
3141 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
3142 glDrawPixels (bbox(2), bbox(3),
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
3143 GL_RGBA, GL_UNSIGNED_BYTE, props.get_pixels ().data ());
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
3144 glDisable (GL_ALPHA_TEST);
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
3145 if (! blend)
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
3146 glDisable (GL_BLEND);
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
3147
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3148 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3149
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3150 octave_unused_parameter (props);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3151
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3152 // This shouldn't happen because construction of opengl_renderer
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3153 // objects is supposed to be impossible if OpenGL is not available.
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3154
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3155 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3156
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3157 #endif
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3158 }
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3159
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3160 void
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9687
diff changeset
3161 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
3162 {
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3163 #if defined (HAVE_OPENGL)
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3164
9884
fed4aad2cdca handle indexed images in opengl renderer
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
3165 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
3166 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
3167 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
3168 int w = dv(1);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
3169
11093
d748acc75658 gl-render.cc: Treat images with scalar unique(x/ydata) like Matlab.
Ben Abbott <bpabbott@mac.com>
parents: 11026
diff changeset
3170 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
3171 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
3172
15069
7a3957ca99c3 Handle complex arguments in imagesc (bug #36866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14861
diff changeset
3173 // 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
3174 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
3175 return;
7a3957ca99c3 Handle complex arguments in imagesc (bug #36866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14861
diff changeset
3176
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
3177 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
3178 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
3179
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
3180 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
3181 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
3182
9681
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
3183 const ColumnVector p0 = xform.transform (x(0), y(0), 0);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
3184 const ColumnVector p1 = xform.transform (x(1), y(1), 0);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
3185
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
3186 if (octave::math::isnan (p0(0)) || octave::math::isnan (p0(1)) || octave::math::isnan (p1(0)) || octave::math::isnan (p1(1)))
17727
36d646ead233 Fix segfault when x or y data values are large (bug #39925).
Rik <rik@octave.org>
parents: 17726
diff changeset
3187 {
18682
8c537222f1e5 gl-render.cc: Use class prefix, opengl_renderer or opengl_texture, when printing warning.
Rik <rik@octave.org>
parents: 18677
diff changeset
3188 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
3189 return;
36d646ead233 Fix segfault when x or y data values are large (bug #39925).
Rik <rik@octave.org>
parents: 17726
diff changeset
3190 }
36d646ead233 Fix segfault when x or y data values are large (bug #39925).
Rik <rik@octave.org>
parents: 17726
diff changeset
3191
9687
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
3192 // image pixel size in screen pixel units
9950
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
3193 float pix_dx, pix_dy;
9687
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
3194 // image pixel size in normalized units
9950
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
3195 float nor_dx, nor_dy;
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
3196
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
3197 if (w > 1)
9950
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
3198 {
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
3199 pix_dx = (p1(0) - p0(0))/(w-1);
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
3200 nor_dx = (x(1) - x(0))/(w-1);
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
3201 }
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
3202 else
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
3203 {
10076
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9950
diff changeset
3204 const ColumnVector p1w = xform.transform (x(1) + 1, y(1), 0);
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9950
diff changeset
3205 pix_dx = p1w(0) - p0(0);
9950
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
3206 nor_dx = 1;
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
3207 }
10076
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9950
diff changeset
3208
9950
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
3209 if (h > 1)
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
3210 {
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
3211 pix_dy = (p1(1) - p0(1))/(h-1);
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
3212 nor_dy = (y(1) - y(0))/(h-1);
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
3213 }
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
3214 else
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
3215 {
10076
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9950
diff changeset
3216 const ColumnVector p1h = xform.transform (x(1), y(1) + 1, 0);
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9950
diff changeset
3217 pix_dy = p1h(1) - p0(1);
9950
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
3218 nor_dy = 1;
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
3219 }
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
3220
18682
8c537222f1e5 gl-render.cc: Use class prefix, opengl_renderer or opengl_texture, when printing warning.
Rik <rik@octave.org>
parents: 18677
diff changeset
3221 // 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
3222 // 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
3223
18100
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17787
diff changeset
3224 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
3225 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
3226 i0 = 0, i1 = h;
9687
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
3227
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
3228 float im_xmin = x(0) - nor_dx/2;
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
3229 float im_xmax = x(1) + nor_dx/2;
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
3230 float im_ymin = y(0) - nor_dy/2;
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
3231 float im_ymax = y(1) + nor_dy/2;
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
3232 if (props.is_clipping ()) // clip to axes
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
3233 {
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
3234 if (im_xmin < xmin)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3235 j0 += (xmin - im_xmin)/nor_dx + 1;
9687
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
3236 if (im_xmax > xmax)
21602
47c76e56a1de maint: Remove extra space between end of statement and semicolon.
Rik <rik@octave.org>
parents: 21459
diff changeset
3237 j1 -= (im_xmax - xmax)/nor_dx;
9687
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
3238
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
3239 if (im_ymin < ymin)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3240 i0 += (ymin - im_ymin)/nor_dy + 1;
9687
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
3241 if (im_ymax > ymax)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3242 i1 -= (im_ymax - ymax)/nor_dy;
9687
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
3243 }
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
3244 else // clip to viewport
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
3245 {
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
3246 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
3247 glGetFloatv (GL_VIEWPORT, vp);
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3248 // 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
3249
9687
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
3250 }
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
3251
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
3252 if (i0 >= i1 || j0 >= j1)
9687
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
3253 return;
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
3254
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
3255 glPixelZoom (pix_dx, -pix_dy);
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
3256 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
3257
86aa08bbc887 image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9682
diff changeset
3258 // by default this is 4
18683
44f0d1a53ead Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents: 18682
diff changeset
3259 glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
9680
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9616
diff changeset
3260
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9616
diff changeset
3261 // Expect RGB data
21660
53728df3e4c9 maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents: 21602
diff changeset
3262 if (dv.ndims () == 3 && dv(2) == 3)
9680
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9616
diff changeset
3263 {
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9616
diff changeset
3264 if (cdata.is_double_type ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3265 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3266 const NDArray xcdata = cdata.array_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3267
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3268 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
3269
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3270 for (int i = i0; i < i1; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3271 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3272 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
3273 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3274 a[idx] = xcdata(i,j,0);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3275 a[idx+1] = xcdata(i,j,1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3276 a[idx+2] = xcdata(i,j,2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3277 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3278 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3279
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3280 draw_pixels (j1-j0, i1-i0, a);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3281
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3282 }
18683
44f0d1a53ead Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents: 18682
diff changeset
3283 else if (cdata.is_single_type ())
44f0d1a53ead Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents: 18682
diff changeset
3284 {
44f0d1a53ead Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents: 18682
diff changeset
3285 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
3286
44f0d1a53ead Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents: 18682
diff changeset
3287 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
3288
44f0d1a53ead Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents: 18682
diff changeset
3289 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
3290 {
44f0d1a53ead Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents: 18682
diff changeset
3291 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
3292 {
44f0d1a53ead Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents: 18682
diff changeset
3293 a[idx] = xcdata(i,j,0);
44f0d1a53ead Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents: 18682
diff changeset
3294 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
3295 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
3296 }
44f0d1a53ead Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents: 18682
diff changeset
3297 }
44f0d1a53ead Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents: 18682
diff changeset
3298
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3299 draw_pixels (j1-j0, i1-i0, a);
18683
44f0d1a53ead Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents: 18682
diff changeset
3300
44f0d1a53ead Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents: 18682
diff changeset
3301 }
44f0d1a53ead Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents: 18682
diff changeset
3302 else if (cdata.is_uint8_type ())
44f0d1a53ead Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents: 18682
diff changeset
3303 {
44f0d1a53ead Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents: 18682
diff changeset
3304 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
3305
44f0d1a53ead Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents: 18682
diff changeset
3306 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
3307
44f0d1a53ead Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents: 18682
diff changeset
3308 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
3309 {
44f0d1a53ead Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents: 18682
diff changeset
3310 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
3311 {
44f0d1a53ead Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents: 18682
diff changeset
3312 a[idx] = xcdata(i,j,0);
44f0d1a53ead Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents: 18682
diff changeset
3313 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
3314 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
3315 }
44f0d1a53ead Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents: 18682
diff changeset
3316 }
44f0d1a53ead Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents: 18682
diff changeset
3317
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3318 draw_pixels (j1-j0, i1-i0, a);
18683
44f0d1a53ead Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents: 18682
diff changeset
3319
44f0d1a53ead Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents: 18682
diff changeset
3320 }
9680
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9616
diff changeset
3321 else if (cdata.is_uint16_type ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3322 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3323 const uint16NDArray xcdata = cdata.uint16_array_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3324
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3325 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
3326
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3327 for (int i = i0; i < i1; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3328 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3329 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
3330 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3331 a[idx] = xcdata(i,j,0);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3332 a[idx+1] = xcdata(i,j,1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3333 a[idx+2] = xcdata(i,j,2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3334 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3335 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3336
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3337 draw_pixels (j1-j0, i1-i0, a);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3338
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3339 }
9680
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9616
diff changeset
3340 else
18683
44f0d1a53ead Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents: 18682
diff changeset
3341 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
3342 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
3343 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
3344 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
3345
9680
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9616
diff changeset
3346 glPixelZoom (1, 1);
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3347
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3348 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3349
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3350 octave_unused_parameter (props);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3351
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3352 // This shouldn't happen because construction of opengl_renderer
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3353 // objects is supposed to be impossible if OpenGL is not available.
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3354
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3355 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3356
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3357 #endif
9680
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9616
diff changeset
3358 }
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9616
diff changeset
3359
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9616
diff changeset
3360 void
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3361 opengl_renderer::set_viewport (int w, int h)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3362 {
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3363 #if defined (HAVE_OPENGL)
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3364
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3365 glViewport (0, 0, w, h);
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3366
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3367 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3368
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3369 octave_unused_parameter (w);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3370 octave_unused_parameter (h);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3371
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3372 // This shouldn't happen because construction of opengl_renderer
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3373 // objects is supposed to be impossible if OpenGL is not available.
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3374
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3375 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3376
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3377 #endif
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3378 }
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3379
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3380 void
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3381 opengl_renderer::draw_pixels (int width, int height, const float *data)
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3382 {
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3383 #if defined (HAVE_OPENGL)
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3384
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3385 glDrawPixels (width, height, GL_RGB, GL_FLOAT, data);
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3386
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3387 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3388
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3389 octave_unused_parameter (width);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3390 octave_unused_parameter (height);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3391 octave_unused_parameter (data);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3392
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3393 // This shouldn't happen because construction of opengl_renderer
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3394 // objects is supposed to be impossible if OpenGL is not available.
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3395
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3396 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3397
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3398 #endif
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3399 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3400
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3401 void
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3402 opengl_renderer::draw_pixels (int width, int height, const uint8_t *data)
9950
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
3403 {
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3404 #if defined (HAVE_OPENGL)
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3405
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3406 glDrawPixels (width, height, GL_RGB, GL_UNSIGNED_BYTE, data);
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3407
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3408 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3409
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3410 octave_unused_parameter (width);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3411 octave_unused_parameter (height);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3412 octave_unused_parameter (data);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3413
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3414 // This shouldn't happen because construction of opengl_renderer
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3415 // objects is supposed to be impossible if OpenGL is not available.
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3416
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3417 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3418
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3419 #endif
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3420 }
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3421
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3422 void
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3423 opengl_renderer::draw_pixels (int width, int height, const uint16_t *data)
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3424 {
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3425 #if defined (HAVE_OPENGL)
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3426
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3427 glDrawPixels (width, height, GL_RGB, GL_UNSIGNED_SHORT, data);
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3428
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3429 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3430
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3431 octave_unused_parameter (width);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3432 octave_unused_parameter (height);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3433 octave_unused_parameter (data);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3434
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3435 // This shouldn't happen because construction of opengl_renderer
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3436 // objects is supposed to be impossible if OpenGL is not available.
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3437
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3438 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3439
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3440 #endif
9950
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
3441 }
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
3442
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9884
diff changeset
3443 void
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3444 opengl_renderer::set_color (const Matrix& c)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3445 {
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3446 #if defined (HAVE_OPENGL)
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3447
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3448 glColor3dv (c.data ());
21209
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
3449
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
3450 txt_renderer.set_color (c);
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3451
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3452 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3453
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3454 octave_unused_parameter (c);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3455
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3456 // This shouldn't happen because construction of opengl_renderer
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3457 // objects is supposed to be impossible if OpenGL is not available.
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3458
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3459 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3460
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3461 #endif
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3462 }
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3463
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3464 void
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3465 opengl_renderer::set_font (const base_properties& props)
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3466 {
21209
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
3467 txt_renderer.set_font (props.get ("fontname").string_value (),
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
3468 props.get ("fontweight").string_value (),
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
3469 props.get ("fontangle").string_value (),
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
3470 props.get ("fontsize_points").double_value ());
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3471 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3472
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3473 void
18768
75f8926deef1 Fix Z-order stacking of patches and axes grid lines (bug #40722).
Rik <rik@octave.org>
parents: 18720
diff changeset
3474 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
3475 {
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3476 #if defined (HAVE_OPENGL)
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3477
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3478 if (on)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3479 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3480 glEnable (GL_POLYGON_OFFSET_FILL);
7906
b3becd212f3f Draw markers above lines
John W. Eaton <jwe@octave.org>
parents: 7904
diff changeset
3481 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
3482 glPolygonOffset (offset, offset);
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3483 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3484 else
7906
b3becd212f3f Draw markers above lines
John W. Eaton <jwe@octave.org>
parents: 7904
diff changeset
3485 {
b3becd212f3f Draw markers above lines
John W. Eaton <jwe@octave.org>
parents: 7904
diff changeset
3486 glDisable (GL_POLYGON_OFFSET_FILL);
b3becd212f3f Draw markers above lines
John W. Eaton <jwe@octave.org>
parents: 7904
diff changeset
3487 glDisable (GL_POLYGON_OFFSET_LINE);
b3becd212f3f Draw markers above lines
John W. Eaton <jwe@octave.org>
parents: 7904
diff changeset
3488 }
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3489
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3490 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3491
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3492 octave_unused_parameter (on);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3493 octave_unused_parameter (offset);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3494
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3495 // This shouldn't happen because construction of opengl_renderer
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3496 // objects is supposed to be impossible if OpenGL is not available.
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3497
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3498 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3499
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3500 #endif
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3501 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3502
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3503 void
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3504 opengl_renderer::set_linewidth (float w)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3505 {
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3506 #if defined (HAVE_OPENGL)
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3507
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3508 glLineWidth (w);
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3509
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3510 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3511
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3512 octave_unused_parameter (w);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3513
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3514 // This shouldn't happen because construction of opengl_renderer
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3515 // objects is supposed to be impossible if OpenGL is not available.
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3516
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3517 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3518
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3519 #endif
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3520 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3521
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3522 void
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3523 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
3524 {
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3525 #if defined (HAVE_OPENGL)
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3526
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3527 bool solid = false;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3528
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3529 if (s == "-")
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3530 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3531 glLineStipple (1, static_cast<unsigned short> (0xFFFF));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3532 solid = true;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3533 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3534 else if (s == ":")
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3535 glLineStipple (1, static_cast<unsigned short> (0x8888));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3536 else if (s == "--")
18906
c0fb31c46e87 Change OpenGL dashed line style to 50% mark / 50% space.
Rik <rik@octave.org>
parents: 18901
diff changeset
3537 glLineStipple (1, static_cast<unsigned short> (0xF0F0));
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3538 else if (s == "-.")
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3539 glLineStipple (1, static_cast<unsigned short> (0x020F));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3540 else
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3541 glLineStipple (1, static_cast<unsigned short> (0x0000));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3542
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3543 if (solid && ! use_stipple)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3544 glDisable (GL_LINE_STIPPLE);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3545 else
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3546 glEnable (GL_LINE_STIPPLE);
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3547
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3548 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3549
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3550 octave_unused_parameter (s);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3551 octave_unused_parameter (use_stipple);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3552
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3553 // This shouldn't happen because construction of opengl_renderer
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3554 // objects is supposed to be impossible if OpenGL is not available.
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3555
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3556 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3557
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3558 #endif
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3559 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3560
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3561 void
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3562 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
3563 double z1, double z2)
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3564 {
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3565 #if defined (HAVE_OPENGL)
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3566
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3567 double dx = (x2-x1);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3568 double dy = (y2-y1);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3569 double dz = (z2-z1);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3570
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3571 x1 -= 0.001*dx; x2 += 0.001*dx;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3572 y1 -= 0.001*dy; y2 += 0.001*dy;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3573 z1 -= 0.001*dz; z2 += 0.001*dz;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3574
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3575 ColumnVector p (4, 0.0);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3576
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3577 p(0) = -1; p(3) = x2;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3578 glClipPlane (GL_CLIP_PLANE0, p.data ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3579 p(0) = 1; p(3) = -x1;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3580 glClipPlane (GL_CLIP_PLANE1, p.data ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3581 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
3582 glClipPlane (GL_CLIP_PLANE2, p.data ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3583 p(1) = 1; p(3) = -y1;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3584 glClipPlane (GL_CLIP_PLANE3, p.data ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3585 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
3586 glClipPlane (GL_CLIP_PLANE4, p.data ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3587 p(2) = 1; p(3) = -z1;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3588 glClipPlane (GL_CLIP_PLANE5, p.data ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3589
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3590 xmin = x1; xmax = x2;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3591 ymin = y1; ymax = y2;
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3592 zmin = z1; zmax = z2;
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3593
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3594 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3595
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3596 octave_unused_parameter (x1);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3597 octave_unused_parameter (x2);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3598 octave_unused_parameter (y1);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3599 octave_unused_parameter (y2);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3600 octave_unused_parameter (z1);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3601 octave_unused_parameter (z2);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3602
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3603 // This shouldn't happen because construction of opengl_renderer
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3604 // objects is supposed to be impossible if OpenGL is not available.
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3605
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3606 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3607
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3608 #endif
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3609 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3610
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3611 void
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3612 opengl_renderer::set_clipping (bool enable)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3613 {
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3614 #if defined (HAVE_OPENGL)
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3615
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3616 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
3617
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3618 if (enable != has_clipping)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3619 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3620 if (enable)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3621 for (int i = 0; i < 6; i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3622 glEnable (GL_CLIP_PLANE0+i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3623 else
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3624 for (int i = 0; i < 6; i++)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3625 glDisable (GL_CLIP_PLANE0+i);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3626 }
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3627
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3628 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3629
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3630 octave_unused_parameter (enable);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3631
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3632 // This shouldn't happen because construction of opengl_renderer
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3633 // objects is supposed to be impossible if OpenGL is not available.
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3634
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3635 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3636
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3637 #endif
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3638 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3639
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3640 void
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3641 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
3642 {
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3643 #if defined (HAVE_OPENGL)
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3644
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3645 # if defined (HAVE_FRAMEWORK_OPENGL)
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
3646 GLint vw[4];
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3647 # else
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3648 int vw[4];
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3649 # endif
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3650
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3651 glGetIntegerv (GL_VIEWPORT, vw);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3652
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3653 glMatrixMode (GL_PROJECTION);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3654 glPushMatrix ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3655 glLoadIdentity ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3656 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
3657 glMatrixMode (GL_MODELVIEW);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3658 glPushMatrix ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3659
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3660 set_clipping (false);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3661 set_linewidth (width);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3662
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3663 marker_id = make_marker_list (m, size, false);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3664 filled_marker_id = make_marker_list (m, size, true);
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3665
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3666 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3667
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3668 octave_unused_parameter (m);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3669 octave_unused_parameter (size);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3670 octave_unused_parameter (width);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3671
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3672 // This shouldn't happen because construction of opengl_renderer
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3673 // objects is supposed to be impossible if OpenGL is not available.
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3674
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3675 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3676
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3677 #endif
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3678 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3679
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3680 void
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3681 opengl_renderer::end_marker (void)
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3682 {
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3683 #if defined (HAVE_OPENGL)
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3684
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3685 glDeleteLists (marker_id, 1);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3686 glDeleteLists (filled_marker_id, 1);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3687
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3688 glMatrixMode (GL_MODELVIEW);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3689 glPopMatrix ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3690 glMatrixMode (GL_PROJECTION);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3691 glPopMatrix ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3692 set_linewidth (0.5f);
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3693
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3694 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3695
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3696 // This shouldn't happen because construction of opengl_renderer
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3697 // objects is supposed to be impossible if OpenGL is not available.
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3698
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3699 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3700
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3701 #endif
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3702 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3703
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3704 void
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3705 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
3706 const Matrix& lc, const Matrix& fc)
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3707 {
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3708 #if defined (HAVE_OPENGL)
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3709
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3710 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
3711
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3712 glLoadIdentity ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3713 glTranslated (tmp(0), tmp(1), -tmp(2));
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3714
7907
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
3715 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
3716 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3717 glColor3dv (fc.data ());
7906
b3becd212f3f Draw markers above lines
John W. Eaton <jwe@octave.org>
parents: 7904
diff changeset
3718 set_polygon_offset (true, -1.0);
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3719 glCallList (filled_marker_id);
7906
b3becd212f3f Draw markers above lines
John W. Eaton <jwe@octave.org>
parents: 7904
diff changeset
3720 if (lc.numel () > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3721 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3722 glColor3dv (lc.data ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3723 glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3724 glEdgeFlag (GL_TRUE);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3725 set_polygon_offset (true, -2.0);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3726 glCallList (filled_marker_id);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3727 glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3728 }
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3729 set_polygon_offset (false);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3730 }
7907
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
3731 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
3732 {
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3733 glColor3dv (lc.data ());
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3734 glCallList (marker_id);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3735 }
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3736
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3737 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3738
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3739 octave_unused_parameter (x);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3740 octave_unused_parameter (y);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3741 octave_unused_parameter (z);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3742 octave_unused_parameter (lc);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3743 octave_unused_parameter (fc);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3744
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3745 // This shouldn't happen because construction of opengl_renderer
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3746 // objects is supposed to be impossible if OpenGL is not available.
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3747
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3748 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3749
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3750 #endif
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3751 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3752
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3753 unsigned int
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3754 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
3755 bool filled) const
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3756 {
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3757 #if defined (HAVE_OPENGL)
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3758
7907
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
3759 char c = marker[0];
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
3760
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
3761 if (filled && (c == '+' || c == 'x' || c == '*' || c == '.'))
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
3762 return 0;
c350329da645 Implement basic line antialiasing
John W. Eaton <jwe@octave.org>
parents: 7906
diff changeset
3763
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3764 unsigned int ID = glGenLists (1);
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
3765 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
3766
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3767 // constants for the * marker
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3768 const double sqrt2d4 = 0.35355339059327;
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3769 double tt = sz*sqrt2d4;
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3770
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3771 glNewList (ID, GL_COMPILE);
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3772
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3773 switch (marker[0])
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3774 {
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3775 case '+':
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3776 glBegin (GL_LINES);
18769
ff39ddf84a19 * gl-render.cc (opengl_renderer::make_marker_list): Replace glVertex2f with
Rik <rik@octave.org>
parents: 18768
diff changeset
3777 glVertex2d (-sz/2, 0);
ff39ddf84a19 * gl-render.cc (opengl_renderer::make_marker_list): Replace glVertex2f with
Rik <rik@octave.org>
parents: 18768
diff changeset
3778 glVertex2d (sz/2, 0);
ff39ddf84a19 * gl-render.cc (opengl_renderer::make_marker_list): Replace glVertex2f with
Rik <rik@octave.org>
parents: 18768
diff changeset
3779 glVertex2d (0, -sz/2);
ff39ddf84a19 * gl-render.cc (opengl_renderer::make_marker_list): Replace glVertex2f with
Rik <rik@octave.org>
parents: 18768
diff changeset
3780 glVertex2d (0, sz/2);
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3781 glEnd ();
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3782 break;
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3783 case 'x':
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
3784 glBegin (GL_LINES);
18769
ff39ddf84a19 * gl-render.cc (opengl_renderer::make_marker_list): Replace glVertex2f with
Rik <rik@octave.org>
parents: 18768
diff changeset
3785 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
3786 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
3787 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
3788 glVertex2d (sz/2, -sz/2);
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3789 glEnd ();
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3790 break;
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3791 case '*':
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3792 glBegin (GL_LINES);
18769
ff39ddf84a19 * gl-render.cc (opengl_renderer::make_marker_list): Replace glVertex2f with
Rik <rik@octave.org>
parents: 18768
diff changeset
3793 glVertex2d (-sz/2, 0);
ff39ddf84a19 * gl-render.cc (opengl_renderer::make_marker_list): Replace glVertex2f with
Rik <rik@octave.org>
parents: 18768
diff changeset
3794 glVertex2d (sz/2, 0);
ff39ddf84a19 * gl-render.cc (opengl_renderer::make_marker_list): Replace glVertex2f with
Rik <rik@octave.org>
parents: 18768
diff changeset
3795 glVertex2d (0, -sz/2);
ff39ddf84a19 * gl-render.cc (opengl_renderer::make_marker_list): Replace glVertex2f with
Rik <rik@octave.org>
parents: 18768
diff changeset
3796 glVertex2d (0, sz/2);
ff39ddf84a19 * gl-render.cc (opengl_renderer::make_marker_list): Replace glVertex2f with
Rik <rik@octave.org>
parents: 18768
diff changeset
3797 glVertex2d (-tt, -tt);
ff39ddf84a19 * gl-render.cc (opengl_renderer::make_marker_list): Replace glVertex2f with
Rik <rik@octave.org>
parents: 18768
diff changeset
3798 glVertex2d (+tt, +tt);
ff39ddf84a19 * gl-render.cc (opengl_renderer::make_marker_list): Replace glVertex2f with
Rik <rik@octave.org>
parents: 18768
diff changeset
3799 glVertex2d (-tt, +tt);
ff39ddf84a19 * gl-render.cc (opengl_renderer::make_marker_list): Replace glVertex2f with
Rik <rik@octave.org>
parents: 18768
diff changeset
3800 glVertex2d (+tt, -tt);
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3801 glEnd ();
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3802 break;
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3803 case '.':
10924
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3804 {
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3805 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
3806
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3807 glBegin (GL_POLYGON);
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3808 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
3809 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
3810 glEnd ();
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3811 }
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3812 break;
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3813 case 's':
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3814 glBegin ((filled ? GL_POLYGON : GL_LINE_LOOP));
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3815 glVertex2d (-sz/2, -sz/2);
9681
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
3816 glVertex2d (-sz/2, sz/2);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
3817 glVertex2d (sz/2, sz/2);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
3818 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
3819 glEnd ();
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3820 break;
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3821 case 'o':
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3822 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3823 double ang_step = M_PI / 5;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3824
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3825 glBegin ((filled ? GL_POLYGON : GL_LINE_LOOP));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3826 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
3827 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
3828 glEnd ();
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3829 }
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3830 break;
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3831 case 'd':
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3832 glBegin ((filled ? GL_POLYGON : GL_LINE_LOOP));
9681
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
3833 glVertex2d (0, -sz/2);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
3834 glVertex2d (sz/2, 0);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
3835 glVertex2d (0, sz/2);
40775386ab58 gl-render.cc: style fixes
John W. Eaton <jwe@octave.org>
parents: 9680
diff changeset
3836 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
3837 glEnd ();
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3838 break;
10835
4bbd6f75f173 gl-render.cc: Transpose markers '^' and 'v'.
Ben Abbott <bpabbott@mac.com>
parents: 10402
diff changeset
3839 case 'v':
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3840 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
3841 glVertex2d (0, sz/2);
ff39ddf84a19 * gl-render.cc (opengl_renderer::make_marker_list): Replace glVertex2f with
Rik <rik@octave.org>
parents: 18768
diff changeset
3842 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
3843 glVertex2d (-sz/2, -sz/2);
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3844 glEnd ();
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3845 break;
10835
4bbd6f75f173 gl-render.cc: Transpose markers '^' and 'v'.
Ben Abbott <bpabbott@mac.com>
parents: 10402
diff changeset
3846 case '^':
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3847 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
3848 glVertex2d (0, -sz/2);
ff39ddf84a19 * gl-render.cc (opengl_renderer::make_marker_list): Replace glVertex2f with
Rik <rik@octave.org>
parents: 18768
diff changeset
3849 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
3850 glVertex2d (sz/2, sz/2);
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3851 glEnd ();
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3852 break;
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3853 case '>':
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3854 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
3855 glVertex2d (sz/2, 0);
ff39ddf84a19 * gl-render.cc (opengl_renderer::make_marker_list): Replace glVertex2f with
Rik <rik@octave.org>
parents: 18768
diff changeset
3856 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
3857 glVertex2d (-sz/2, -sz/2);
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3858 glEnd ();
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3859 break;
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3860 case '<':
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3861 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
3862 glVertex2d (-sz/2, 0);
ff39ddf84a19 * gl-render.cc (opengl_renderer::make_marker_list): Replace glVertex2f with
Rik <rik@octave.org>
parents: 18768
diff changeset
3863 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
3864 glVertex2d (sz/2, sz/2);
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3865 glEnd ();
7906
b3becd212f3f Draw markers above lines
John W. Eaton <jwe@octave.org>
parents: 7904
diff changeset
3866 break;
10924
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3867 case 'p':
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3868 {
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3869 double ang;
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3870 double r;
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
3871 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
3872
10924
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3873 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
3874 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
3875 {
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3876 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
3877 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
3878 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
3879 }
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3880 glEnd ();
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3881 }
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3882 break;
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3883 case 'h':
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3884 {
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3885 double ang;
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3886 double r;
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
3887 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
3888
10924
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3889 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
3890 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
3891 {
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3892 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
3893 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
3894 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
3895 }
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3896 glEnd ();
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3897 }
f56255a2b890 gl-render.cc: Matlab compatible markers for the OpenGL.
Ben Abbott <bpabbott@mac.com>
parents: 10835
diff changeset
3898 break;
7851
002b1d8460d2 added some more markers
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7846
diff changeset
3899 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
3900 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
3901 break;
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3902 }
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3903
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3904 glEndList ();
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3905
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3906 return ID;
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3907
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3908 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3909
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3910 octave_unused_parameter (marker);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3911 octave_unused_parameter (size);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3912 octave_unused_parameter (filled);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3913
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3914 // This shouldn't happen because construction of opengl_renderer
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3915 // objects is supposed to be impossible if OpenGL is not available.
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3916
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3917 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3918
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3919 #endif
7825
13871b7de124 Import sources for OpenGL-based renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3920 }
7874
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7870
diff changeset
3921
9834
92d8f35ff217 compute bounding boxes for text in opengl graphics backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
3922 void
92d8f35ff217 compute bounding boxes for text in opengl graphics backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
3923 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
3924 uint8NDArray& pixels,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10202
diff changeset
3925 Matrix& bbox,
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11385
diff changeset
3926 int halign, int valign, double rotation)
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3927 {
21209
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
3928 txt_renderer.text_to_pixels (txt, pixels, bbox, halign, valign,
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
3929 rotation, interpreter);
9834
92d8f35ff217 compute bounding boxes for text in opengl graphics backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
3930 }
92d8f35ff217 compute bounding boxes for text in opengl graphics backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
3931
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
3932 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
3933 opengl_renderer::text_to_strlist (const std::string& txt,
21209
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
3934 std::list<text_renderer::string>& lst,
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
3935 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
3936 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
3937 {
21209
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
3938 txt_renderer.text_to_strlist (txt, lst, bbox, halign, valign,
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
3939 rotation, interpreter);
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
3940 }
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
3941
9834
92d8f35ff217 compute bounding boxes for text in opengl graphics backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
3942 Matrix
92d8f35ff217 compute bounding boxes for text in opengl graphics backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
3943 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
3944 double x, double y, double z,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3945 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
3946 {
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3947 #if defined (HAVE_OPENGL)
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3948
21209
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
3949 Matrix bbox (1, 4, 0.0);
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
3950
9834
92d8f35ff217 compute bounding boxes for text in opengl graphics backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
3951 if (txt.empty ())
21209
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
3952 return bbox;
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
3953
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
3954 if (txt_renderer.ok ())
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
3955 {
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
3956 uint8NDArray pixels;
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
3957 text_to_pixels (txt, pixels, bbox, halign, valign, rotation);
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
3958
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
3959 bool blend = glIsEnabled (GL_BLEND);
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
3960
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
3961 glEnable (GL_BLEND);
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
3962 glEnable (GL_ALPHA_TEST);
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
3963 glRasterPos3d (x, y, z);
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
3964 glBitmap(0, 0, 0, 0, bbox(0), bbox(1), 0);
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
3965 glDrawPixels (bbox(2), bbox(3),
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
3966 GL_RGBA, GL_UNSIGNED_BYTE, pixels.data ());
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
3967 glDisable (GL_ALPHA_TEST);
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
3968
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
3969 if (! blend)
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
3970 glDisable (GL_BLEND);
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
3971 }
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3972
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3973 return bbox;
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3974
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3975 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3976
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3977 octave_unused_parameter (txt);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3978 octave_unused_parameter (x);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3979 octave_unused_parameter (y);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3980 octave_unused_parameter (z);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3981 octave_unused_parameter (halign);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3982 octave_unused_parameter (valign);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3983 octave_unused_parameter (rotation);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3984
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3985 // This shouldn't happen because construction of opengl_renderer
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3986 // objects is supposed to be impossible if OpenGL is not available.
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3987
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3988 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21689
diff changeset
3989
21353
e4fc19d8c6c3 remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3990 #endif
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8920
diff changeset
3991 }