Skip to content

Game Development

What can we say - we like games. And you can use Qt to write some. Questions? Ask here.
830 Topics 4.0k Posts
  • 0 Votes
    2 Posts
    525 Views
    uaniU

    my bad:

    ((Qt3DExtras::QTextureMaterial)material).setTexture(t);

    should have been

    ((Qt3DExtras::QTextureMaterial*)material)->setTexture(t);

    :facepalm:

    i'm sorry for bothering you.

    However the "status changed" signal i'm still not receiving.

  • 0 Votes
    4 Posts
    337 Views
    Chris KawaC

    I mean MSVC as the compiler

    Ok, so you asked why you can't use it.
    Well, you can.

  • Troubles with Arduino to Qt.

    Unsolved
    2
    0 Votes
    2 Posts
    211 Views
    SGaistS

    Hi and welcome to devnet,

    One way could be to use the serial port of your Arduino to communicate with the computer.

  • 0 Votes
    5 Posts
    563 Views
    M

    @JoeCFD thank you Joe,
    I found the solution on github
    https://github.com/jonaias/DynamicFontSizeWidgets

  • 0 Votes
    2 Posts
    224 Views
    SGaistS

    Hi,

    Did you try to use qWaitForWindowExposed ?

  • Do we still need to call XFlush in Qt 6?

    Unsolved
    4
    0 Votes
    4 Posts
    346 Views
    J.HilkJ

    @mhn2 afaik Q_WS_X11 was a Qt4 define, and was replaced by the much better Qt Platform Abstraction system.
    https://doc.qt.io/qt-6/qpa.html

    the x11 support still exists, you find that now here:
    https://doc.qt.io/qt-6/linux.html

  • 0 Votes
    2 Posts
    254 Views
    8Observer88

    I should use DrawPolygon to draw segments of colliders when I use boxes to draw borders around game objects. DrawSegment() will be called when an instance of b2EdgeShape is created:

    b2EdgeShape edgeShape; edgeShape.SetOneSided(b2Vec2(0.f, 0.f), b2Vec2(1.f, 0.f), b2Vec2(2.f, 0.f), b2Vec2(3.f, 0.f)); m_pEdgeBody = m_pWorld->CreateBody(&bdef); m_pEdgeBody->CreateFixture(&edgeShape, 2.f);
  • 1 Votes
    4 Posts
    287 Views
    8Observer88

    Usually, this implies some sort of pointer problem.

    @newQOpenGLWidget thank you! You set a direction for me. I forgot to get the uMvpMatrix location in the ColliderEdge class. I will publish a simple example in the next time when I ask a question.

    Note. This answer is from StackOverflow

  • 0 Votes
    4 Posts
    283 Views
    Chris KawaC

    That last one -bloom is a postprocess effect and it has nothing to do with shadows. Also there's no raytracing involved in the shadow technique described in the previous link.

    In the shadow-mapping technique described there you render the scene multiple times.
    For each light you set up a model-view-projection matrix to match the light source point of view i.e. you render the scene from the position and direction of your spotlight, so that it's a circle that fills the framebuffer. Each light gets its own depth buffer like that. You don't need a color buffer in that pass, only the depth information is what's of interest here. This basically "encodes" the distance of each object to each light in the depth buffer. That depth buffer is called a shadowmap.

    Then, in the second pass, you bind these shadowmaps as input and when you draw your scene to the actual framebuffer you reproject the 3d position of the pixel you're currently drawing to the light space coordinates and compare the resulting depth value with that in the shadowmap. If it's smaller then pixel is in the direct light. If it's larger it's in the shadow.

    For the shadowmap you use a square depth texture and as for the size of it games usually have shadow quality preset for that e.g. low/medium/high. The bigger the texture the less jaggy the shadows will be but also it's gonna be slower because there's more depth information to write. Games usually use shadowmaps somewhere in the range 512x512 to 2048x2048 (remember that power of two sized textures are much faster on the GPU). Some types of games can get away with smaller ones, but you have to experiment what looks good for you.

    As for when are the shadowmaps rendered - it depends. If your scene is static and your lights don't move you can render them once at the start and reuse. If you want the lights to move or have moving objects in the scene you'll need to re-render shadowmaps more often.

    Games usually do multiple different optimizations to make the shadowmaps rendering less costly. First of all limit the maximum number of dynamic light sources i.e. render shadows only for a couple of the closest lights. Detect if anything in the light cone changed (i.e. something moved into or out of the light cone) and only re-render that shadowmap then. Limit the amount of moving lights. Render only the most important objects into the shadowmaps and don't include those that contribute little to the whole image.
    But these are optimizations for later. For starters I suggest to try and do a single closest light shadowmap and render whole scene to it so you can learn how to do it.

  • how to transfer data from one interface to another

    Unsolved
    5
    0 Votes
    5 Posts
    354 Views
    D

    Set layout to widget that is showing.
    Then add qlinedit to the layout using add widget

  • How is Lighting determined?

    Solved
    6
    0 Votes
    6 Posts
    384 Views
    Chris KawaC

    Like if I used phong glsl type of shading does that automatically use the bdrf rendering?

    The method of rendering and a BRDF selection are two separate topics. All of them can use the same BRDF. To make it super simple BRDF is the equation that you have in your vertex/pixel shader for calculating a color. The rendering method is about how you get to invoke those shaders.

    The first method is slow for certain scenarios, like tons of lights but is superb for others. Modern game engines usually have a mix of 2 or all 3 of these methods for different types of objects. For example you could have deferred lighting as a base method for most solid objects, forward pass for translucent stuff like glass and raytracing for global illumination (indirect lighting). Up to about a decade ago pretty much all popular engines used mostly forward renderers but nowadays everything is a hybrid of multiple techniques.

    But all that can be a bit overwhelming, so don't try to jump on all of these at once. Pick one and implement that for a start.

    how do I select which rendering style?

    It's like choosing bubble sort or quick sort. They are just different algorithms suitable for different tasks, so you just pick one that is best for your situation. You can use both if you want.

    Forward renderer is the easier one. For each light you set its properties as shader constants and just draw each object with a shader that implements e.g. Phong's equation using these constants. You draw that directly to the framebuffer (assuming you don't want to do any postprocessing later like blur, bloom, chromatic aberration etc.).

    Deferred approach is a two-pass algorithm on the other hand. In the first pass you set up a framebuffer with multiple attachments, one texture for each element of a g-buffer. You render each object and a shader writes to these buffers information about the objects' materials - normals, color, roughness etc. In the second pass you take these textures and set them up as multitexture input, bind another buffer containing light information like positions, color, falloff etc. and then do a draw call with that. In that pass you use the same BRDF as in the forward rendering but he difference is that object information is encoded in the g-buffer textures and not as vertex attributes of individual draws. The second pass goes to the single output framebuffer (again assuming no postprocess passes).
    Here's a tutorial on that technique: Deferred Shading.

    Shadows are yet another topic and I wouldn't try to do them until you have a grasp of basic lighting. In forward and deferred rendering they are an effect separate from lighting. Yes, I know, it sounds weird, but shadows are not part of lighting in those techniques. They are calculated as an entirely separate pass using techniques like shadow mapping, cascading maps, PCF, VSM, PCSS or others. For example some good explanation of VSM technique is shown in one of the GPU Gems books I mentioned: Summed-Area Variance Shadow Maps. But again - I wouldn't worry about shadows just yet. Do basic direct lighting first and get comfortable with it before you move on.

    In raytracing shadows show up kinda naturally and automatically, because this technique is the closest to what real light does. Shadows are just places where the rays can't reach. Raytracing is a bit more advanced technique and I wouldn't start with it though, especially since it is now hardware accelerated on many GPUs, but OpenGL has no direct API support for it, so Vulcan or DirectX12 are better suited for that task..

  • how to make a turn-based battle system

    Unsolved
    8
    0 Votes
    8 Posts
    399 Views
    D

    The signal emitted can be caught by a class that controls the QPainter, the slot can be as such

    Class visualizer { Public slot: Void character_health_affected { //show blood or shake effect styled images //timeout the blood, hide/delete blood effects after a few seconds } }
  • 0 Votes
    3 Posts
    322 Views
    D

    @Chris-Kawa wow I can’t believe I missed that.
    I’m sure that is the issue, I will try this solution right away.

  • could someone tell me how i apply the state machine

    Unsolved
    6
    0 Votes
    6 Posts
    293 Views
    JonBJ

    @milhao
    Have you had a look at, say

    https://doc.qt.io/qt-5/qtwidgets-statemachine-eventtransitions-example.html https://cpp.hotexamples.com/examples/-/QStateMachine/-/cpp-qstatemachine-class-examples.html
  • Help with QPainter arc math

    Unsolved
    2
    0 Votes
    2 Posts
    175 Views
    S

    Sorry, I should have provided some code to test it.

    #include <QtWidgets> unsigned long f = 0; class Character : public QWidget { public: Character(); ~Character(); QPixmap *getPixmap(); protected: void paintEvent(QPaintEvent *e); }; Character::Character() : QWidget(){} Character::~Character(){} void Character::paintEvent(QPaintEvent *event){ Q_UNUSED(event); QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); painter.setRenderHint(QPainter::SmoothPixmapTransform); painter.setBrush(QBrush(QColor(255, 255, 255))); painter.drawEllipse(QRectF(0, 0, 79, 79)); for(int i = (f % 10); i <= 80; i += 10){ if(i<50) painter.drawArc(0, i, 79, 80-i*1.5, 0, 180*16); else painter.drawArc(0, 50-(i-50), 79, (i-55)*2, 180*16, 180*16); } painter.end(); f++; } int main(int argc, char *argv[]){ QApplication app(argc, argv); Character *c = new Character(); QTimer t; QObject::connect(&t, &QTimer::timeout, c, static_cast<void(QWidget::*)()>(&QWidget::update)); t.start(30); c->show(); return app.exec(); }
  • How to change texts and image by button multiple times

    Solved
    10
    0 Votes
    10 Posts
    536 Views
    SGaistS

    Sure you can use the same button for the sequence.

  • how to check the output of the QCombobox box

    Solved
    5
    0 Votes
    5 Posts
    272 Views
    ApprenticeRenoA

    @milhao
    I assume you drag and drop a comboBox in you're ui.file and then set the items, if this is you're case you can try :

    -Go to the ui.file , right click on the comboBox , GoToSlot -> select on CurrentTextChanged, then , in the method that is created automathically you write this:

    void MainWindow::on_comboBox_1_currentTextChanged(const QString &arg1) { if(ui->comboBox_1->currentText()=="elf"){ qDebug()<<" you have chosen --> "<<ui->comboBox_1->currentText(); }else if(ui->comboBox_1->currentText()=="human"){ qDebug()<<" you have chosen --> "<<ui->comboBox_1->currentText(); } }
  • 0 Votes
    1 Posts
    217 Views
    No one has replied
  • 0 Votes
    3 Posts
    1k Views
    8Observer88

    The falling COLLADA (.dae) cube using PySide6, PyQt6, Bullet Physics, and OpenGL 3.3:

    PySide6: https://github.com/8Observer8/falling-collada-cube-bullet-physics-opengl33-pyside6 PyQt6: https://github.com/8Observer8/falling-collada-cube-bullet-physics-opengl33-pyqt6

    You should install these packages:

    pip install PySide6 (or PyQt6) pip install PyOpenGL pip install numpy pip install Panda3D (for Bullet Physics)

    falling-collada-cube.gif

  • 0 Votes
    5 Posts
    1k Views
    8Observer88

    A few basic changes in PyQt6 regarding shader-based OpenGL graphics