Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 1 year ago.
Improve this question
I am interested in making a GUI-intensive strategy game with C++ and GTK+. What I would like to know is how feasible it would be to add 2D game graphics to a GTK program. Basically I would be wanting something like a game screen, with interactable 2D graphics, flanked by menus and the ability to navigate to other screens that would be GUI only.
Note that I have never used GTK before, nor have I before programed a GUI (nor graphics either).
It's certainly possible with GTK, but you have to ask yourself whether you're using the right tool for the job. Use Clutter, which is much more suited to animation and integrates with GTK; or perhaps better yet, use a game programming toolkit.
Here's an example of two non-intensive proof-of-concept games written with Clutter, with links to their source code.
It's possible. I did it with GTK and Vala some time ago. Here is a blog post I wrote about it. Basically it's very much like the games you make with Java and Swing. Just override the expose signal and create a timer for regular redraws. Here's an article on developing a 2D Snake game in PyGTK.
In pseudocode, all you do for the game infrastructure is:
start()
{
tick_timer( 1.0 / FPS );
load_all_sprites_etc();
}
tick()
{
update();
game_board.expose(); // game_board is a GTKWidget, preferably a DrawingArea
}
expose_event() // connected to game_board
{
drawing_code();
}
update()
{
game_physics();
game_logic();
}
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I'm currently developing an OpenGL application and I want to use Qt for the other stuff. I want to use OpenGL like I use it with GLFW and without Qt functions. Just normal OpenGL. I cant find any site which uses Qt like id like to. So I only want to use Qt for the Windows and creating context and so on, but use OpenGL for the rest.
Thanks for your time.
There is an old-school QOpenGLWidget that will create an OpenGL context. That will give a window with an area to draw on.
Other option is the Scene Graph - OpenGL Under QML - pretty much the same, but it also allows to have QML user interface (buttons, edits, etc.) above your OpenGL rendering.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am trying to create a GUI for a tower of Hanoi application using Qt. I Already wrote the C++ code using recursion but I am a total beginner when it comes to working with Qt and creating GUI's and have just started familiarizing myself with it by creating a simple calculator GUI but don't have a clear idea how to tackle the Tower of Hanoi GUI especially on how to create the disks and pegs graphically.
Any tips or pointers on where to start would be welcome. Thank you.
I suggest to take a look at QGraphicsScene. It will take a while to get familiar, but it is the proper Qt tool for handling these kind of things.
Basically, QGraphicsScene is an abstract representation of, well, a graphics scene. It is a virtual canvas object to which you can add graphics items (QAbstractGraphicsItems) with various shapes and positions. It can then be rendered in a specialized view class called QGraphicsView.
A good starting point is the '40000 chips' example in Qt Creator.
I can recommend 2 options:
One would be using an OpenGL canvas inside your window and have objects loaded into your 2D scene. And when you need to move or rotate the objects, you would just need to know about translate and rotate functionalities.
You wouldn't need to do this with modern OpenGL, as it might be overwhelming at the starts. But OpenGL with fixed pipeline (legacy version) would be quite easy to learn. However, I should mention that QT and OpenGL can be a little trouble to use together for a beginner due to QT.
The other would be the QPainter to load and draw 2D images (of components of towers). It wouldn't be as realistic as an OpenGL equavelent, but it would get the job done as well.
You can find the functions available via QPainter in the following link. It has almost everything you would need and to move a part, just render using the initial position values added to the offset.
http://doc.qt.io/qt-5/qpainter.html
I also recommend watching a few videos on Youtube about translation in computer graphics, to understand the logic behind this common functionality about moving things in a scene in amounts dependent on other conditions.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
As an option for rendering UI over a game I am currently developing I was thinking about how viable QML (Qt5) would be. Given that you are limited to only drawing when Qt gives you the signal, how viable would writing a game such as; a first person shooter of the quality of say... ArmA 3 (graphically wise, not taking into account content creation or budget); be in Qt/QML on a desktop platform if you used QML for only a 2D interface over top of the game (think menus and HUDs)?
To be more specific, what sort of performance loss would you get by rendering a high-fidelity FPS game like this then rendering an interface over it using QML?
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have seen a couple topics about this already but they were a bit vague for me so I decided to make this. I'm working on a little adventure game just for fun in Qt, its basically just text on the screen and the player inputs commands into a line edit widget which I then process and do the related action/event. Thing is, I am a little confused on how to approach this. I don't want to dig myself a hole by manually coding in lots of commands and events per room because it seems to just be a pain later on. So then I thought about using some sort of database to store the information but which one should I use? I would love some advice from people who have tried something similar.
And here, these pictures are a rough outline of what I am trying to do.
Flowchart of states
Level tiles
Edit: I should add, the tiles for the level basically work like this. The light gray is a direction the player can move in, the dark gray parts are walls and the colors are various different actions you can do.
I don't particularly care for code, but I would like suggestions on what tools to use for this and maybe how to set them up right. Someone must know.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
I am looking for a GUI toolkit that is easy to use and cross-platform. Another major requirement of the GUI is that it should support zoom and pan. For example, I should be able to zoom in on a picture and enlarge buttons.
Something like this:
http://eaglemode.sourceforge.net/video.html
But it should have Windows support also (which to the best of my knowledge Eagle Mode doesn't have).
From what I understand, QT is a good UI and it can draw right on top of the OGL window. I think it resets the matrix before drawing the buttons. If I can prevent that reset, the GUI can be zoomed along with the rest of the items. Is there a simple hack to do just that?
Thanks,
This is doable in Qt 4.4 and above using the Qt Graphics View Framework. It makes it very easy to make these types of interfaces, since Widgets can now be placed on the scene (QGraphicsScene) using QGraphicsWidget and QGraphicsLayout.
The framework supports zooming, panning, rotating, etc - with animation.
Take a look at Piccolo2D, which has Java and .NET bindings.
It is the successor of Pad++, which was well ahead of its time: