0

Like opengl for C/C++, is there some library available for Bash shell scripting?

I was trying to create a simple 2D-game (Tower Of Hanoi) using Bash. What libraries do I need to start with the graphical objects like creating a cylinder, rings and so on?

Zanna
  • 70,465
  • 4
    Why would you want to use bash for graphical stuff? And what do you mean by graphics, exactly? If you want to implement openGL in bash, it would be simpler and more pleasant to remove your own pancreas using a plastic spoon. Joking apart, please [edit] your question and explain what sort of thing you are thinking of. Bash should not be considered a normal programming language. It is a shell with some limited programming capabilities. If you find yourself trying to do 3d graphics in bash, you are doing something wrong. – terdon Aug 01 '17 at 13:11
  • Thank you @terdon for your suggestion. I was just trying to plot a cylinder using shell scripts, and thought of using some graphics library but didnt find any. – rraj gautam Aug 01 '17 at 15:53
  • Yeah, that's because this is really not a job for a shell script. Use an actual programming language. Shells are not and should not be considered programming languages. You can, of course, write simple programs in a shell but that's not what they're best at and they are very, very limited in terms of what you can do. – terdon Aug 01 '17 at 16:34
  • Related: https://askubuntu.com/questions/115903/xfce-bash-gui-elements-in-shell-script/942007#942007 – Elder Geek Aug 01 '17 at 19:03
  • 3
    I don't think this question is unclear. The answer is "don't do it with bash, except really really basic stuff," but the question is perfectly clear. – Eliah Kagan Oct 16 '17 at 16:53

1 Answers1

6

Zenity is a tool to create dialogs and that is about it. No 3D in Bash. You need a coding language for that and not a shell script language.

It has the following options:

  --calendar                             Display calendar dialog
  --entry                                Display text entry dialog
  --error                                Display error dialog
  --info                                 Display info dialog
  --file-selection                       Display file selection dialog
  --list                                 Display list dialog
  --notification                         Display notification
  --progress                             Display progress indication dialog
  --question                             Display question dialog
  --warning                              Display warning dialog
  --scale                                Display scale dialog
  --text-info                            Display text information dialog

To create graphical methods for input by the user.

Example:

#!/bin/sh

if zenity --entry \
--title="Add new profile" \
--text="Enter name of new profile:" \
--entry-text "NewProfile"
  then echo $?
  else echo "No name entered"
fi

would show ...

enter image description here

But this is very much limited to those options.

If you want to create 3D applications (like games) use Python (pygame is a good choice), Perl or C/C++.


howtogeek has some more examples.

Rinzwind
  • 299,756