Skip to content
  • 0 Votes
    2 Posts
    130 Views
    JonBJ

    @misscoffee
    So just set the size of the view and/or scene to the full size of the screen/desktop. You can also use void QWidget::showFullScreen() (see the warnings there).

    Be aware that widgets/windows have borders, and a title bar unless you specify otherwise, so the view/scene may not occupy every pixel of the screen, unless you take action, if that matters to you. IIRC, graphics scene/view places coordinate (0,0) in the center with x,y increasing right/up. You can use setSceneRect() to alter this.

  • 0 Votes
    2 Posts
    438 Views
    jsulmJ

    @Mquaza said in QPainter drawRects without draging a line behind:

    How do you make it so, that 2 rectangles are moving across the scene?

    I would say change their coordinates?

  • 0 Votes
    3 Posts
    1k Views
    F

    @SGaist
    Thanks for answering.
    Basically, I am separating rendering and updating to have fixed-timestep updating (for physics etc) as well as as-fast-as-possible rendering with time interpolation. (Heavily heavily inspired from Gaffer on Games article)
    My code looks as follows (only slightly simplified):

    ... within my OpenGLContext void GLWindow::gameLoop() { const double delta = 1.0 / fixedUpdatesPerSecond; auto time = QDateTime::currentMSecsSinceEpoch(); double accumulated = 0.0; while (! this->terminate) { auto newTime = QDateTime::currentMSecsSinceEpoch(); double frameExecution = tdiff(time, newTime); time = newTime; accumulated += frameExecution; while (accumulated >= delta) { // Handle user input / system polling //However, since Qt has event driven polling, let's just call processEvents and then handle any input events by putting their results into a map. QCoreApplication::processEvents(); // Update our states this->updateState(delta); accumulated -= delta; } this->render(accumulated / delta); } }

    In the same class, I have updateState and render:

    void MyGL::updateState(float delta) { //... Bunch of commented-out code to make sure base loop works first if(myKeys.at(Qt::Key_W)) { cam->translateAlongForward(delta * 3.0); cam->update(); } } void MyGL::render(float aheadAlphaPercent) { this->update(); } void MyGL::paintGL() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); lambertShader->setViewProj(cam->matrix()); // a lot of other drawing stuff }

    I know that my rendering code itself works because I initially tested it by just using a QTimer.

    Instead, I now do the following:

    ...in main... QApplication a(argc, argv); QSurfaceFormat::setDefaultFormat(format); MainWindow w; w.show(); w.start(); //return a.exec(); // ^Dont^want^to^uncomment^this^ ... MainWindow::start (MainWindow is QMainWindow subclass)... uiElements->glWindow->gameLoop(); //glWindow is subclass of OpenGLContext

    As you can see, I tried to avoid calling Qt's blocking event loop in QApplication::exec, but am still polling events. However, this doesn't work properly, as described in my first post.

  • 0 Votes
    5 Posts
    2k Views
    M

    @mrjj Thank you for the link and regarding the multiplayer my teacher said that i can do either over the internet or LAN , i believe LAN is a much simplier thing to work with so i'd probably go with that if there are any stuff regarding this topic, for my graduation project it's required for game to be played by ( for example 4 ) players, but each player has to play the game on their own PC.
    @jksh ye i wanted to implement that into my game and of course like i said player vs the pc, but my professor said that i should put a multiplayer option in there aswell if i want to get a better grade.

  • Qt can't include anything

    Unsolved Tools
    10
    0 Votes
    10 Posts
    2k Views
    SGaistS

    Did you have any system update happening in between ?

  • 0 Votes
    1 Posts
    753 Views
    No one has replied
  • 0 Votes
    3 Posts
    1k Views
    H

    @SGaist I edited, thanks

  • QT Editor to my SFML game

    Solved General and Desktop
    3
    0 Votes
    3 Posts
    1k Views
    FelaugmarF

    @alex_malyu Thank you, I'll read more about this license.

  • 0 Votes
    2 Posts
    1k Views
    A

    i think the only things you need to do is open or shutdown bluetooth, find bluetooth devices and connect if needed. all the other things must have been done by the hardware vendor

  • 0 Votes
    2 Posts
    2k Views
    Chris KawaC

    Hi, welcome to devnet.

    A better and more portable design would be if an engine did not run its own loop. The most popular way to do that is to provide a kind of Initialize(), Frame() and Shutdown() interface that you could call from a loop provided by whatever windowing framework (most of them usually have that). The Frame() part would measure the time elapsed from last frame and advance the states proportionally to that.
    If you don't want to go that path (just make sure you really don't) you could also run the two loops in parallel, starting your engine's loop in a worker thread. This leads to some synchronization issues, but with some work could be manageable.

    Again - it's better if the engine does not provide it's own OpenGL bindings but uses the ones provided by the windowing framework (e.g. QOpenGLFunctions in case of Qt). There should be no problem in using GLEW along with Qt, just make sure you do your GLEW/OpenGL calls with a current GL context provided by Qt.

    QGLWidget is replaced now with a more modern QOpenGLWidget. If all you need is a window and input management (like with GLFW) then consider using QWindow with an OpenGL surface format instead. You will get better performance and drop the requirement of QtWidgets module.
    As for triggering the update - there's an update() method for that. You can call it how often you need and it will schedule OpenGL painting. The usual way to tackle this is either using a timer or calling update() at the end of the painting method to schedule updates "as often as possible" i.e. as often as v-sync allows.

  • 0 Votes
    1 Posts
    1k Views
    No one has replied
  • 0 Votes
    2 Posts
    1k Views
    ?

    @cudo Hi, please see http://www.qt.io/FAQ/ .

  • 0 Votes
    2 Posts
    807 Views
    G

    I'd like to bump this topic, it's been over 5 years and you'd think small sprites would be better respected and not blurry with the qt engine (as ya know, sprites came from the pixel era) , I've tried everything under the sun to get sprites that aren't blurry and it seems you have to basically use an AnimatedImage or your own sprite engine to make do.

    I would have modified the sprites item or made my own copy but I couldn't find a copy of its source

  • 0 Votes
    3 Posts
    2k Views
    SGaistS

    Just saw that you already posted the same question here

    Please, don't post the same questions multiple times in different sub forum. One is enough.

    Closing it.

  • 0 Votes
    3 Posts
    2k Views
    R

    Possibly the error is from the declaration of keyPressEvent

    protected: virtual void keyPressEvent(QKeyEvent *event);

    It might be better to have this handled in the parent class. When a graphics item is selected (clicked) store this information and move the item from the parent when the right key presses are seen. You might have a problem with losing focus otherwise.

  • 0 Votes
    1 Posts
    904 Views
    No one has replied