Menu

Finer control of GLUT

Anonymous
2019-03-14
2019-03-16
  • Anonymous

    Anonymous - 2019-03-14

    Hi,

    I would like to introduce MathGL into a physics simulation program in C which plots some data in real-time.

    Currently I'm using the GLUT library directly, but I would like to move to something more advanced like MathGL. However, I would like to keep some parts in GLUT.

    The method mglCanvasGLUT::Window seems to be creating the GLUT context and directly setting the window size, registering the display and keyboard callbacks, and finally calling glutMainLoop().

    I would like to keep the control of GLUT and be able to handle multiple windows as well, using the idle callback function. What is the preferred way of interfacing MathGL with GLUT so that I can have finer control of the redraw loop?

    Currently, I did a small test, but some parts are not working properly, like showing the title. Also the axis appear with scaling:

    https://github.com/rodarima/cpic/blob/master/test/mgl.c

    I use gcc mgl.c -lm -lGL -lGLU -lglut -lmgl2-glut -lmgl2 -o mgl to compile.

    Best regards,
    Rodrigo.

     
  • Anonymous

    Anonymous - 2019-03-15

    Hi Alexey,

    I'm currently using mgl_create_graph_gl to create the canvas (similarly as by using mglGraph(1, w, h)). And the graphs are shown properly, but I'm not able to set the window size. The same behavior is shown by using the class mglGraph.

    By calling mgl_set_size with the new size, nothing happens. If I call mgl_get_width() always returns 1, same with the width.

    Also if I use glViewport(0,0,w,h), the graph is only scaled (so the text is deformed) and is not what I want.

    The only way I found to change the aspect ratio, is by manually calling to mglCanvas::SetSize(2, 1, true) which is then properly updated to 2x1. However some parts of the graph fail (vect_2d doesn't show anymore, neither the axis) while others work (contf).

    I attach to you the actual program, which shows the titles scaled.

    Best regards,
    Rodrigo.

     

Anonymous
Anonymous

Add attachments
Cancel