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

OpenGL Support #23

Open
KJ7LNW opened this issue Dec 1, 2022 · 2 comments
Open

OpenGL Support #23

KJ7LNW opened this issue Dec 1, 2022 · 2 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@KJ7LNW
Copy link
Owner

KJ7LNW commented Dec 1, 2022

HELP WANTED

Would you like to volunteer to help with OpenGL support to xnec2c? Read on:

This first-pass implementation partially renders antenna patterns in OpenGL. Hurray! While the OpenGL work has been started, it needs some polish (ahem, quite a bit of polish)...plus, this is a feature that the original xnec2c author, Neoklis 5B4AZ, has always wanted.

-Eric, KJ7LNW

GOALS!

  • OpenGL for:
    • Radiation Pattern
    • E/H Field Pattern and animation
    • Physical Structure
  • Click to rotate the object
  • Mouse wheel to zoom
  • Middle click to pan
  • Shift+click to rotate light sources around the object
  • Transparency when clicking to rotate.
  • An optional transparent grid plane at (x,y)=0
  • Shaders
    • I'm open to any cool shader ideas you might have
    • It could be neat to have one or more light sources such that the light sources can rotate around the radiation pattern (or structure) with shift-click+drag.

Getting Started

git clone https://github.com/KJ7LNW/xnec2c.git
cd xnec2c
git checkout opengl
./autogen.sh
./configure
make
./src/xnec2c -j4 examples/airplane.nec

Once it loads:

  • Enable the "View->Radiation Pattern" checkbox and click "Gain Pattern" button on the "Radiation Patterns" window
  • When it loads there should be a small "GLArea Test" window. Resize the window to a reasonable size for your display.
  • The "GLArea Test" window will only update when "Radiation Patterns" is rotated.
  • To interact with the GLArea Test window, click and drag in the "Radiation Patterns" window (not the "GLArea Test" window) to change the OpenGL view.
  • To change the scale, use your mouse wheel to zoom over the "Radiation Patterns" window (not the "GLArea Test" window) and then rotate it so the GL window will redraw.

Development Considerations

There is a work-in-progress branch for OpenGL support using CGLM which you can see in this commit comparison: master...opengl . The branch is here: https://github.com/KJ7LNW/xnec2c/tree/opengl

If you would prefer to start fresh then I'm okay with that, the opengl branch is here as a reference in case it is useful. Ultimately your new branch would replace this current opengl branch and ultimately get merged into master.

  1. A new opengl.c and .h file should be created to store code for:
    • camera
    • arcball
    • vertex generation from NEC2 structures (from rad_pattern, see how rdpat_points or point_3d is created for colorization in Draw_Radiation_Pattern, but do it in a more "opengl-friendly way").
    • GTK UI hooks for pan/scale/rotate
    • other GL stuff
  2. A function from opengl.c for generating radition pattern vertexes should be hooked into src/draw_radiation.c:Draw_Radiation_Pattern().
    • Currently that logic is hard-coded into Draw_Radiation_Pattern() but that was just a convenient place to put it while testing. See the commits to understand what changed.
    • Right now the OpenGL data vertex structure is updated every time it is redrawn. This is unnecessary for OpenGL because the video card will handle it. The structure should be regenerated only when the frequency data is recalculated (like when the select frequency is changed).
  3. The current triangle creation logic isn't quite right and the radiation pattern isn't so clean. Note that theta is the azimuth and theta=0 is pointing in the direction of Z+! This is just how NEC2 was designed back in 1981...
  4. The configure.ac file should detect OpenGL libraries and link them as necessary. Some of this has been done already.
  5. CGLM should be a git submodule if it is not already
    • If you prefer a different vector/matrix math library vs CGLM then I'm open to it; it looked like CGLM was a good place to start since xnec2c is written in C, not in C++.
  6. Maintain shader version 1.20 support for older distributions, right now we don't need anything fancy.
  7. To the extent possible, widgets should be maintained as GTK Builder objects and expressed as XML in resources/xnec2c.glade. However, it might be easier to open-code as a first pass with gtk API calls and refactor into XML later.
  8. Rebase on the master branch
  9. Try to follow Linux Kernel commit practices and coding style for new code.

References

@KJ7LNW KJ7LNW added enhancement New feature or request help wanted Extra attention is needed labels Jan 10, 2023
@jerryd
Copy link

jerryd commented Nov 3, 2023

I was thinking about doing some work to convert to GTK4. Has anyone considered doing this? KF7RCC

@KJ7LNW
Copy link
Owner Author

KJ7LNW commented Nov 3, 2023

Generally speaking, we want to support deployment on any system that is still supported under long-term support by the distribution vendor. For example Oracle Linux 8 is supported until 2029, and it runs GTK 3. That means we cannot cut over to GTK 4 without backwards compatibility support.

If there are GTK4 features that would be nice to add, then that would be great, however they need to be detected by Autoconf in configure.ac and appropriate #ifdef checks need to be placed in the code so that it will still compile on older distributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants