Skip to content

Instantly share code, notes, and snippets.

@drojf
Created October 14, 2016 02:15
Show Gist options
  • Save drojf/676024bb40f60f7bc707206b9259abed to your computer and use it in GitHub Desktop.
Save drojf/676024bb40f60f7bc707206b9259abed to your computer and use it in GitHub Desktop.
Using IupMglPlot in OpenGL mode prints error "MathGL message - AddLight: light: ID is out of range" when graph updated
#include "stdafx.h"
#include "iup.h"
#include "iup_mglplot.h"
double plug_current_graph_y[100];
Ihandle * plot;
void update_gui_callback()
{
//every update event (like this redraw call, or mouse over) causes the error message to be printed
IupMglPlotSet1D(plot, 0, NULL, plug_current_graph_y, 100);
IupSetAttribute(plot, "REDRAW", NULL);
}
int main(int argc, char **argv)
{
IupOpen(&argc, &argv);
IupMglPlotOpen();
IupSetGlobal("MGLFONTS", "../etc/mglfonts");
//create MglPlot in OpenGL mode
plot = IupMglPlot();
int dataset_number = IupMglPlotNewDataSet(plot, 1);
IupSetAttribute(plot, "RASTERSIZE", "600x600");
IupSetAttribute(plot, "OPENGL", "YES"); //<--------In OpenGL mode only, when graph is updated, will always print "MathGL message - AddLight: light: ID is out of range"
IupShowXY(IupDialog(plot), IUP_CENTER, IUP_CENTER);
//Setup a timer to periodically update the graph
Ihandle * timer1 = IupTimer();
IupSetAttribute(timer1, "TIME", "200");
IupSetAttribute(timer1, "RUN", "YES");
IupSetCallback(timer1, "ACTION_CB", (Icallback)update_gui_callback);
IupMainLoop();
IupClose();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment