|From:||Lars Jahr Røine|
|Subject:||Fwd: Implementation and Benchmarking of plotting function|
|Date:||Mon, 27 Feb 2012 18:20:52 +0100|
Hello,I asked a question about this on #Octave and wad advised to post my question here.
I've implemented a plotting function for plotting unstructured grids as an addition to a open source matlab toolbox which is currently being ported to Octave. My code is in C++ using OpenGL. I've now managed (I think) to move the functionality into the Octave C++ source code, but I run into problems when I try to benchmark.
What I've done so far is to implement a class Grid in grid.hpp and included this in gl-render.h. I'm also using a simple fps counter which I have included (FpsCounter.hpp). I have then made a new function in the opengl_renderer class called draw_unstructured_grid(const grid::properties &props), where grid::properties is a class I've implemented in the file graphics.h.in. In addition I've made a script file in /octave/scripts/plot/ called plot_grid.m which checks the input before sending it to the C++ code. I have made some modifications in the makefiles in /octave and in /octave/src (Which probably should be done in a different way, since I've now come to understand that the Makefiles shouldn't be modified directly). Here I have added -lGLEW a couple of places.
At first I had both a grid.hpp and a grid.cpp file, but then I got compile errors because the compiler couldn't find the files that where declared in grid.hpp but implemented in grid.cpp. I now assume this is because I didn't do anything to link my own code into octave. I noticed however that I was able to call functions that where fully implemented in the header file, grid.hpp. I therefore moved the entire implementation into grid.hpp and got my code to work. I am positive it works since I'm able to call my new plot_grid function from Octave, and I get a correct plot up and running. Debug print that I have in the methods in the grid class are also printed when running the Octave command. The fps-counter prints out results (incorrectly, but still it prints). How is this possible when I haven't linked my own code with the rest of the Octave code? (I guess this is more of a general C++ question, but still I hope I could get some help). And more importantly, how should I attack the problem of using both header and source files in Octave. Where do I make modifications so that my code is linked into the Octave code?
I originally thought I had gotten around the linkage problem by implementing all the code in the header-files until I tried to do some benchmarks. My idea was to make a large/infinite loop inside the draw function in /octave/src/DLD-FUNCTIONS/__init_fltk__.cc and then count the frames drawn inside the function I have implemented in the opengl_renderer class (draw_unsctructured_grid). When I did this the plots did not however appear (only the fltk window) until after the loop had finished. I got a tip from #Octave to call __fltk_redraw__() each time in the loop. To do this I had to forward declare __fltk_redraw__ because it is found in a later stage in the source file than the draw function. Octave compiles just fine, but I get an error when I call graphics_toolkit("fltk"):
error: feval: /octave/src/DLD-FUNCTIONS/__init_fltk__.oct: failed to load: /octave/src/DLD-FUNCTIONS/__init_fltk__.oct: undefined symbol: _ZN11OpenGL_fltk15__fltk_redraw__Ev
error: called from:error: /home/lars/master/master_repo/larsjr-master/octave-dev/octave/scripts/plot/graphics_toolkit.m at line 56, column 5
I would appreciate all advice on how to solve these problems, and explanations on what I'm doing wrong :) It would be very interesting to learn how to change Octave's build system in a correct way.
|[Prev in Thread]||Current Thread||[Next in Thread]|