1#include "gl_performance_monitor.h"
2#include <cgv_gl/gl/gl.h>
3#include <cgv/render/attribute_array_binding.h>
4#include <cgv/render/shader_program.h>
15 if (positions.empty())
19 for (
const auto& p : positions)
23 glDrawArrays(GL_LINES, 0, (GLsizei)positions.size());
34 float w = xmax - xmin + 1;
35 float h = ymax - ymin + 1;
36 int dy = (int)(h / nr_display_cycles);
38 std::swap(ymin, ymax);
45 int min_i = -1, max_i = -1;
46 if (data.size() > 1) {
49 for (
unsigned i = 0; i < data.size() - 1; ++i, ++x) {
50 const frame_data& fdata = data[i];
51 compute_colors(fdata);
52 compute_positions(x,
int(ymin), 0, dy, fdata);
53 draw_computed_bars(ctx, prog);
55 if (min_i == -1 || data[i][data[i].size() - 2].time < data[min_i][data[min_i].size() - 2].time)
58 if (max_i == -1 || data[i][data[i].size() - 2].time > data[max_i][data[max_i].size() - 2].time)
61 if (!bar_config.empty()) {
62 int y = int(ymin - (bar_line_width + 4) / 2 - 4);
63 glLineWidth((
float)bar_line_width);
64 for (
int c = 0; c < (int)bar_config.size(); ++c) {
65 switch (bar_config[c]) {
68 draw_bar(ctx, prog, y, data[min_i]);
72 draw_bar(ctx, prog, y, data[max_i]);
75 draw_bar(ctx, prog, y, data.back());
78 std::cerr <<
"avg not yet supported" << std::endl;
81 y -= bar_line_width + 1;
90 compute_colors(fdata);
91 compute_positions(placement.
get_min_pnt()(0),y,placement.
get_extent()(0)/nr_display_cycles, 0, fdata);
92 draw_computed_bars(ctx, prog);
95void checkClientState()
98 glGetIntegerv(GL_CLIENT_ACTIVE_TEXTURE, &at);
101 std::cout << (glIsEnabled(GL_VERTEX_ARRAY)?
"V":
"v")
102 << (glIsEnabled(GL_NORMAL_ARRAY)?
"N":
"n")
103 << (glIsEnabled(GL_COLOR_ARRAY)?
"C":
"c");
105 for (
int i=0; i<8; ++i) {
106 glClientActiveTexture(GL_TEXTURE0+i);
107 std::cout << (glIsEnabled(GL_TEXTURE_COORD_ARRAY)?(
"0"+std::to_string(i)):
".");
109 std::cout << std::endl;
114 std::vector<vec2> lines;
119 float w = xmax - xmin + 1;
120 float h = ymax - ymin + 1;
121 float dy = h / nr_display_cycles;
123 std::swap(ymin, ymax);
127 lines.push_back(
vec2(xmin - 1, ymax + 1));
128 lines.push_back(
vec2(xmax + 1, ymax + 1));
129 lines.push_back(
vec2(xmax + 1, ymax + 1));
130 lines.push_back(
vec2(xmax + 1, ymin - 1));
131 lines.push_back(
vec2(xmax + 1, ymin - 1));
132 lines.push_back(
vec2(xmin - 1, ymin - 1));
133 lines.push_back(
vec2(xmin - 1, ymin - 1));
134 lines.push_back(
vec2(xmin - 1, ymax + 1));
136 if (nr_display_cycles > 1) {
138 for (
int i = 1; i < nr_display_cycles; ++i) {
139 lines.push_back(
vec2(xmin, y));
140 lines.push_back(
vec2(xmax, y));
147 glDrawArrays(GL_LINES, 0, (GLsizei) lines.size());
160 GLboolean is_depth = glIsEnabled(GL_DEPTH_TEST);
161 glDisable(GL_DEPTH_TEST);
164 glGetFloatv(GL_LINE_WIDTH, &lw);
169 draw_bars(ctx, prog);
170 draw_lines(ctx, prog);
176 glEnable(GL_DEPTH_TEST);
static bool enable_global_array(const context &ctx, int loc)
enable attribute array of given location
static bool set_global_attribute_array(const context &ctx, int loc, const vertex_buffer &vbo, type_descriptor td, size_t size, size_t offset, unsigned stride=0)
point array of vertex attribute at location loc to vertex buffer array array stored in CPU memory; in...
static bool disable_global_array(const context &ctx, int loc)
disable attribute array of given location
base class for all drawables, which is independent of the used rendering API.
virtual void set_color(const rgba &clr)
set the current color
virtual shader_program & ref_default_shader_program(bool texture_support=false)=0
return a reference to a shader program used to render without illumination
virtual unsigned int get_height() const =0
return the height of the window
virtual void push_pixel_coords()=0
use this to push new modelview and new projection matrices onto the transformation stacks such that x...
virtual void pop_pixel_coords()=0
pop previously pushed transformation matrices from modelview and projection stacks
a shader program combines several shader code fragments to a complete definition of the shading pipel...
bool enable(context &ctx)
enable the shader program
bool disable(context &ctx)
disable shader program and restore fixed functionality
cgv::math::fvec< float, 2 > vec2
declare type of 2d single precision floating point vectors