C/C++ Graphics

1. What is the easy way to create a GUI and render graphics in C or C++ on Linux? Or is there even an easy way?

I've tried OpenGL and it was too weird. SDL was weird but not as much.

There are also PureBasic and Lazarus. They are not C or C++ but what the heck?
2. SDL2, GLFW (OpenGL) and may be FreeGLUT are the main rendering APIs I can think of.
Creating a GUI should be easy with for example Qt which also has some bindings for opengl. (there also projects out there which help with using SDL2 ant Qt together, but I've never tried those,..)
3. C/C++ is not easy, period. It's not a high level language, more like a high level assembler. Anyone who says it's easy is a web poser. If you're new to programming you may be better off with something simpler like python or perl.
4. Originally Posted by Hoser Rob
C/C++ is not easy, period. It's not a high level language, more like a high level assembler. Anyone who says it's easy is a web poser. If you're new to programming you may be better off with something simpler like python or perl.
What a pile of nonsense, particularly the bold part.
By the way, adding "period" at the end of a statement does not magically make it true. It's something feeble-minded fools do because they think it will enforce their ridiculous claims.
5. I need a compiled, not an interpreted, language.
6. Why must it be compiled? To processor code? To intermediate code?
7. Originally Posted by JVRaines
Why must it be compiled? To processor code? To intermediate code?
Execution speed.
8. Originally Posted by Groucho
Originally Posted by Hoser Rob
C/C++ is not easy, period. It's not a high level language, more like a high level assembler. Anyone who says it's easy is a web poser. If you're new to programming you may be better off with something simpler like python or perl.
What a pile of nonsense, particularly the bold part.
By the way, adding "period" at the end of a statement does not magically make it true. It's something feeble-minded fools do because they think it will enforce their ridiculous claims.
Brave statement Groucho... Plain C lacks of many things common in high level language and from programmer perspective it looks more like machine language than high level language... Don't be so tense Groucho.

@OP - BASIC compilers exist and if you are more familiar with BASIC then give a chance to BASIC. Or perhaps you should use something tailored for tasks as yours ( https://gstreamer.freedesktop.org/ ? )
9. Originally Posted by pandy
Originally Posted by Groucho
Originally Posted by Hoser Rob
C/C++ is not easy, period. It's not a high level language, more like a high level assembler. Anyone who says it's easy is a web poser. If you're new to programming you may be better off with something simpler like python or perl.
What a pile of nonsense, particularly the bold part.
By the way, adding "period" at the end of a statement does not magically make it true. It's something feeble-minded fools do because they think it will enforce their ridiculous claims.
Plain C lacks of many things common in high level language and from programmer perspective it looks more like machine language than high level language...
I was mainly referring to C++ which is clearly a high level language. The fact that C looks like machine language to some people is just a silly argument.

Originally Posted by pandy
Don't be so tense Groucho.
He, he, I'll do my best. It just pushes my buttons when someone without a frickin' clue spreads FUD.
10. Originally Posted by Groucho
I was mainly referring to C++ which is clearly a high level language. The fact that C looks like machine language to some people is just a silly argument.
Once again C++/C# is different story, C has plenty things common with ASM (operators are practically same as in inline asm).
It was designed to be compiled using a relatively straightforward compiler, to provide low-level access to memory, to provide language constructs that map efficiently to machine instructions, and to require minimal run-time support.
https://en.wikipedia.org/wiki/C_%28programming_language%29

Originally Posted by Groucho
He, he, I'll do my best. It just pushes my buttons when someone without a frickin' clue spreads FUD.
Personally feel ASM easier (condition is understanding of CPU and system architecture) than C but perhaps this is outcome of my youth programming experience where BASIC or ASM was only two practical approaches. Tried so many times to learn something modern but never succeeded.
11. Or perhaps you should use something tailored for tasks as yours
Such as???

I have already mentioned PureBasic and Lazarus. PureBasic is broken - it is not able to compile on Linux (compiles fine on Windows but has the flickering video problem we've been discussing).
12. There's .Net Core with System.Drawing.Common which runs on Linux. I have no idea how fast.
https://www.hanselman.com/blog/HowDoYouUseSystemDrawingInNETCore.aspx
13. Originally Posted by chris319
Such as???
For example dedicated multimedia framework https://gstreamer.freedesktop.org/ - you can use ffmpeg as plugin and i assume (sorry as i'm not a software guy) you have examples how to use it...
14. Personally feel ASM easier (condition is understanding of CPU and system architecture) than C but perhaps this is outcome of my youth programming experience where BASIC or ASM was only two practical approaches. Tried so many times to learn something modern but never succeeded.
It looks like you skipped the middle, Python, Java etc., and you do not want to go into OOP schemes. But trying that middle is not that overwhelming, I'd recommend Python since we are talking video here and we have thing like Vapoursynth already available. You'd be LOL every day learning Python, amazed how things are easy, especially with tons of moduls, support and tutorials that Python already has.
15. Python is an interpreted language. When you have 921,600 (720 x 1080) pixels to manipulate, it's going to be as slow as molasses. Each pixel must have lift, gamma and gain applied, as well as conversions between RGB and YUV.

Vapoursynth uses ffmpeg with all its unpredictability.
16. Like I wrote before, Qt is a good frame work when working with C++ (or Java or Python).
Depending on what you want to do there are XY additional libraries that could be used.
-> Assuming you know your way around C++ this is the way I would go.

In the end there are libraries for all mayor languages which allow basic graphic operations, depending on what you want to write yourself you will probably either way have to write OpenCL/OpenGL or Assembler code in case it needs to be fast.

In case you are no experienced programmer, using Python and at least partially using Vapoursynth and libav seems to make the most sense, since it has the lowest learning curve and the existing base operations should all be assembler optimized. (Vapoursynth doesn't have to use libav/ffmpeg at all,..)
17. Originally Posted by chris319
Python is an interpreted language. When you have 921,600 (720 x 1080) pixels to manipulate, it's going to be as slow as molasses. Each pixel must have lift, gamma and gain applied, as well as conversions between RGB and YUV.

Vapoursynth uses ffmpeg with all its unpredictability.
I have basically ancient PC (i5 650@3.20GHz) and it can render on screen 10bit UHD camcorder footage with 8 fps with ffms2 source plugin(using Vapoursynth with Python code and opencv to print it on screen or pyqt5 (QT5 libraries for Python), which works even better as gui. Sure you give it something more to process and it slows down. But you said you do not need to play it. Image processing codes work arrays or numpy arrays and access is pretty fast.
Citing from here:
"VapourSynth is an application for video manipulation. Or a plugin. Or a library. It’s hard to tell because it has a core library written in C++ and a Python module to allow video scripts to be created."
So it is not written in Python.
Not commenting about that it uses ffmpeg, because I use Vapoursynth or avisynth just because it is not ffmpeg. You have struggles with input and output color schemes and transfers, but using Vapoursynth you have basically everything under control. Vapoursynth uses source plugin that can or would not read matrix, color primaries, transfer . You can check it. Then you decide if you believe it or not. And now comes the part that you just can select props and set it as you want or use format conversions with your choice, rules are simple and pressed into one function , Vapoursynth plugin Resize. If I look at ffmpeg command lines its all over the place and it sounds complicated, or defaults might be used.
18. Originally Posted by chris319
Python is an interpreted language. When you have 921,600 (720 x 1080) pixels to manipulate, it's going to be as slow as molasses. Each pixel must have lift, gamma and gain applied, as well as conversions between RGB and YUV.

Vapoursynth uses ffmpeg with all its unpredictability.
Python compilers are available...
19. I just tested the same HEVC clip with the same source plugin, using Vapoursynth editor, which is written in C++ as well, and it gave me just about 2 fps more previewing it (meaning one YUV to RGB conversion was involved). He uses QT for his gui. Python code or Vapoursynth script (its the same) serves as a sort of wrapper but not handling heavy image processing. I would not try to reinvent wheel computing RGB values manually and when encountering a new format yet again looking for formulas. To manipulate YUV values or RGB , Expr can be handy (expressions), lut also. Just look into some py file that consists of filtering or they were ported from avisynth. Like havsfunc.py from HolyWu etc.

NOTE: to preview it on screen for example using QT there is other thing involved like creating pixmap that QT uses to put it on screen, not sure what it is internally what array, but just to get a picture
20. Originally Posted by Groucho
...
I was mainly referring to C++ which is clearly a high level language. The fact that C looks like machine language to some people is just a silly argument.
Source code can be high level but in actual development you cannot choose to not deal with low level crap like linking errors, incompatible options, runtimes...
21. Originally Posted by shekh
Originally Posted by Groucho
...
I was mainly referring to C++ which is clearly a high level language. The fact that C looks like machine language to some people is just a silly argument.
Source code can be high level but in actual development you cannot choose to not deal with low level crap like linking errors, incompatible options, runtimes...
The low level crap you're describing comes with every programming language. If you screw up in your code, the interpreter/compiler will notify you.
22. Originally Posted by Groucho
Originally Posted by shekh
Originally Posted by Groucho
...
I was mainly referring to C++ which is clearly a high level language. The fact that C looks like machine language to some people is just a silly argument.
Source code can be high level but in actual development you cannot choose to not deal with low level crap like linking errors, incompatible options, runtimes...
The low level crap you're describing comes with every programming language. If you screw up in your code, the interpreter/compiler will notify you.
You do not have a clue what I* was talking about.
23. I received my B.S. degree in computer science in the mid-1980s. Both C and C++ were classified as high-level programming languages at that time because they used recognizable words from a human language as instructions and were not tied to any particular processor. I don't know why some people here are claiming that they are low-level languages since the definition of "high-level programming language" has not changed in over 30 years.
24. Originally Posted by usually_quiet
I received my B.S. degree in computer science in the mid-1980s. Both C and C++ were classified as high-level programming languages at that time because they used recognizable words from a human language as instructions and were not tied to any particular processor. I don't know why some people here are claiming that they are low-level languages since the definition of "high-level programming language" has not changed in over 30 years.
It seems that to some people nowadays facts and established paradigms are insufficient. If it feels wrong, it must be wrong. Welcome to the 21st century.
25. Originally Posted by _Al_
Personally feel ASM easier (condition is understanding of CPU and system architecture) than C but perhaps this is outcome of my youth programming experience where BASIC or ASM was only two practical approaches. Tried so many times to learn something modern but never succeeded.
It looks like you skipped the middle, Python, Java etc., and you do not want to go into OOP schemes. But trying that middle is not that overwhelming, I'd recommend Python since we are talking video here and we have thing like Vapoursynth already available. You'd be LOL every day learning Python, amazed how things are easy, especially with tons of moduls, support and tutorials that Python already has.
Do you have some sample Python code to get me started working with mp4 files and manipulating the pixels therein?
26. C is not a "very high level" language, nor a "big" one, and is not specialized to any particular area of application. But its absence of restrictions and its generality make it more convenient and effective for many tasks than supposedly more powerful languages.
C is a relatively "low level" language. This characterization is not pejorative; it simply means that C deals with the same sort of objects that most computers do, namely characters, numbers, and addresses. These may be combined and moved about with the arithmetic and logical operators implemented by real machines.
C provides no operations to deal directly with composite objects such as character strings, sets, lists, or arrays. There are no operations that manipulate an entire array or string, although structures may be copied as a unit. The language does not define any storage allocation facility other than static definition and the stack discipline provided by the local variables of functions;there is
no heap or garbage collection. Finally, C itself provides no input/output facilities; there are no READ or WRITE statements, and no built-in file access methods. All of these higher-level mechanisms must be provided by explicitly called functions. Most C implementations have included a reasonably standard collection of such functions.
Similarly, C offers only straightforward, single-thread control flow: tests, loops, grouping, and sub-programs, but not multiprogramming, parallel operations, synchronization,or coroutines
Both quotes from "The C Programming Language" by Dennis Ritchie and Brian Kernighan .
27. Originally Posted by pandy
C is not a "very high level" language, nor a "big" one, and is not specialized to any particular area of application. But its absence of restrictions and its generality make it more convenient and effective for many tasks than supposedly more powerful languages.
C is a relatively "low level" language. This characterization is not pejorative; it simply means that C deals with the same sort of objects that most computers do, namely characters, numbers, and addresses. These may be combined and moved about with the arithmetic and logical operators implemented by real machines.
C provides no operations to deal directly with composite objects such as character strings, sets, lists, or arrays. There are no operations that manipulate an entire array or string, although structures may be copied as a unit. The language does not define any storage allocation facility other than static definition and the stack discipline provided by the local variables of functions;there is
no heap or garbage collection. Finally, C itself provides no input/output facilities; there are no READ or WRITE statements, and no built-in file access methods. All of these higher-level mechanisms must be provided by explicitly called functions. Most C implementations have included a reasonably standard collection of such functions.
Similarly, C offers only straightforward, single-thread control flow: tests, loops, grouping, and sub-programs, but not multiprogramming, parallel operations, synchronization,or coroutines
Both quotes from "The C Programming Language" by Dennis Ritchie and Brian Kernighan .
I programmed in C for several years and I still have an older edition of "The C Programming Language" on my bookshelf to this day. Note that the authors said C was a "relatively low level language" not that it is a low-level language. What they mean is that C lacks some advanced features that a number of more modern programming languages have built into them and provides some low-level operations that some newer languages don't provide.

The textbook computer science definition for high-level languages states that the language must provide a high level of abstraction, that instructions are likely to be recognizable words from a human language, and the language is not tied to any particular system architecture. C meets all of those requirements. I also programmed in an assembly language for a few years, which met none of those requirements and was a true low-level language.
28. Originally Posted by chris319
Do you have some sample Python code to get me started working with mp4 files and manipulating the pixels therein?
you load a clip choosing a source plugin, in example it is lsmas.LWLibavSource for mp4, and for example lowering luma by 10 you can use Expr:
Code:
from Vapoursynth import core
import vapoursynth as vs
file=r'F:\ma\path\to\file\my.mp4'
clip = core.lsmas.LWLibavSource(file)
#checking what color space file is, if you do not know
if clip.format.color_family == vs.ColorFamily.YUV:
space = 'YUV'  #there is also RGB, GRAY, YCOCG and COMPAT
value = 10
Y_expr = 'x {value} -'.format(value=value)
U_expr = ''
V_expr = ''
clip = core.std.Expr(clip, expr = [Y_expr,U_expr,V_expr])

#clip is YUV , so you need to get it on screen as RGB 8bit, assuming input is BT709:
if space == 'YUV':
rgb = core.resize.Bicubic(clip , matrix_in_s = '709', format = vs.RGB24, range ='limited')

#to get a frame from your rgb, for example first frame(0 , pyhon indexes from 0), but it could be any frame :
rgbFrame = rgb.get_frame(0)

#now you have RGB24 image that most gui's can put on screen, you just need to know what array and how arranged it has to be, so it is gui specific further

#to get it out thru vspipe.exe (encoding, piping it somewhere) you specify output:
clip.set_otput()
29. Originally Posted by usually_quiet
I programmed in C for several years and I still have an older edition of "The C Programming Language" on my bookshelf to this day. Note that the authors said C was a "relatively low level language" not that it is a low-level language. What they mean is that C lacks some advanced features that a number of more modern programming languages have built into them and provides some low-level operations that some newer languages don't provide.

The textbook computer science definition for high-level languages states that the language must provide a high level of abstraction, that instructions are likely to be recognizable words from a human language, and the language is not tied to any particular system architecture. C meets all of those requirements. I also programmed in an assembly language for a few years, which met none of those requirements and was a true low-level language.
Tried to close this OT discussion providing statement from C creators. It is quite obvious that C is NOT assembler but high level language - it provide sufficient abstraction layer and ISA independence/portability - that's all - anyway it is closer to machine (with sufficient abstraction layer that provide portability) than any other high level language known to me.

btw - assemblers use words (or they abbreviation) from natural human language - MOVE, MULU, NOP on MC68k .
It is even worse - Some CPU can use high level language directly for example FORTH has at least few silicone implementations where CPU directly perform FORTH so high level language act as machine code.
30. Here is the output of your Python demo:

>>>
Traceback (most recent call last):
File "C:\Archive\Python\test2.py", line 1, in <module>
from Vapoursynth import core
ImportError: No module named 'Vapoursynth'
>>>
Nice job.

Originally Posted by _Al_
Originally Posted by chris319
Do you have some sample Python code to get me started working with mp4 files and manipulating the pixels therein?
you load a clip choosing a source plugin, in example it is lsmas.LWLibavSource for mp4, and for example lowering luma by 10 you can use Expr:
Code:
from Vapoursynth import core
import vapoursynth as vs
file=r'F:\ma\path\to\file\my.mp4'
clip = core.lsmas.LWLibavSource(file)
#checking what color space file is, if you do not know
if clip.format.color_family == vs.ColorFamily.YUV:
space = 'YUV'  #there is also RGB, GRAY, YCOCG and COMPAT
value = 10
Y_expr = 'x {value} -'.format(value=value)
U_expr = ''
V_expr = ''
clip = core.std.Expr(clip, expr = [Y_expr,U_expr,V_expr])

#clip is YUV , so you need to get it on screen as RGB 8bit, assuming input is BT709:
if space == 'YUV':
rgb = core.resize.Bicubic(clip , matrix_in_s = '709', format = vs.RGB24, range ='limited')

#to get a frame from your rgb, for example first frame(0 , pyhon indexes from 0), but it could be any frame :
rgbFrame = rgb.get_frame(0)

#now you have RGB24 image that most gui's can put on screen, you just need to know what array and how arranged it has to be, so it is gui specific further

#to get it out thru vspipe.exe (encoding, piping it somewhere) you specify output:
clip.set_otput()

Statistics