Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling VisualizationSceneSolution3d from own application #274

Open
altineller opened this issue Feb 19, 2024 · 4 comments
Open

Calling VisualizationSceneSolution3d from own application #274

altineller opened this issue Feb 19, 2024 · 4 comments

Comments

@altineller
Copy link

altineller commented Feb 19, 2024

Hello,

I would like to use glVis for my own magnetometer calibration software. For this I am trying to use glVis as a library within QTCreator. I have solved all the dependency issues. And I have attempted to create a new VisualizationSceneSolution3d with a mesh and solution, and then callint SDLMainLoop(true), but it crashes.

   int         geom_ref_type = Quadrature1D::ClosedUniform;
   const char *mesh_file = "/home/can/gl/mfem/data/ref-cube.mesh";

   Mesh *mesh = new Mesh(mesh_file, 1, 1);
   int dim = mesh->Dimension();

   GLVisGeometryRefiner.SetType(geom_ref_type);

   H1_FECollection fec(1, 3);
   FiniteElementSpace fespace(mesh, &fec);
   GridFunction x(&fespace);
   x = 0;

   VisualizationSceneSolution3d * vss;
   vs = vss = new VisualizationSceneSolution3d(*mesh, x);
   SDLMainLoop(true);
   return 0;

And when I debugged it I got:

Screenshot from 2024-02-19 23-14-33

Indicating a problem with renderer.

How can I programmatically visualize a mesh, using glVis library within my own application?

Best Regards,
Can

@altineller
Copy link
Author

I have succeeded to recreate a GLVis scene:

`
stream_state.mesh.reset(meshRead);
stream_state.SetMeshSolution();
stream_state.Extrude1DMeshAndSolution();

// 0: use_soln, 1: use_vector_soln, 2: mesh
Session single_session(2, std::move(stream_state));
single_session.StartSession();

SDLMainLoop();
`

I would like to encapsulate the SDLoutput from GLVis in a QT Window. I need more information about this SDLMainLoop(). How can I for example call required functions from a render() subfunction?

Any ideas / recomendations / help greatly appreciated.

Best Regards,
-C

@v-dobrev
Copy link
Member

I'm not really sure if it is possible to use an SDL2 application (GLVis) inside a Qt application (your application). Maybe you can check the SDL2 forums and issues, see https://www.libsdl.org.

@altineller
Copy link
Author

I'm not really sure if it is possible to use an SDL2 application (GLVis) inside a Qt application (your application). Maybe you can check the SDL2 forums and issues, see https://www.libsdl.org.

Yes, I studied SDL a bit and quickly realized that it would not be the smartest thing to do.

I have mounted the core glvis code into a sdl imgui application, and I was able to run glvis frame within the imgui example application, with few minor problems, such as SDL already being open, etc.

Like many visualization applications GLVis consists of multiple threads / workers that does different things, is that correct? What points should I handle when running it as an SDL app inside an sdl application?

Best Regards,
C.

@v-dobrev
Copy link
Member

Like many visualization applications GLVis consists of multiple threads / workers that does different things, is that correct?

Yes, GLVis uses C++ threads.

What points should I handle when running it as an SDL app inside an sdl application?

I think you are the first to explore that. I suspect that as long as the events in the GLVis window are handled, things should work mostly fine.

@tzanio tzanio mentioned this issue Jun 19, 2024
22 tasks
@tzanio tzanio mentioned this issue Aug 7, 2024
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants