Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Qt and OpenGL Primitives in mobile resolution

Qt and OpenGL Primitives in mobile resolution

Scheduled Pinned Locked Moved Mobile and Embedded
7 Posts 3 Posters 3.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dinesh Balu
    wrote on last edited by
    #1

    Hi...

    I'm new to OpenGL in Qt..
    and I've been trying to draw points in screen corners... I'm using Nokia 900 simulator
    by default the co-ordinate range in openGL is
    X: -1 to 1
    Y: -1 to 1

    right?

    But here in mobile resolution it changes and couldn't predict the change ratio....

    how to solve this...?

    I've set the ViewPort width and height to 360 and 640.

    :)

    1 Reply Last reply
    0
    • Z Offline
      Z Offline
      ZapB
      wrote on last edited by
      #2

      Please post some compilable code that reproduces your problem.

      Nokia Certified Qt Specialist
      Interested in hearing about Qt related work

      1 Reply Last reply
      0
      • D Offline
        D Offline
        Dinesh Balu
        wrote on last edited by
        #3

        This is the OpenGL code..

        @#include "gameplay.h"

        GamePlay::GamePlay(QWidget *parent) :
        QGLWidget(parent)
        {
        setFormat(QGLFormat(QGL::DoubleBuffer | QGL::DepthBuffer));
        rotationX = -21.0;
        rotationY = -57.0;
        rotationZ = 0.0;
        faceColors[0] = Qt::red;
        faceColors[1] = Qt::green;
        faceColors[2] = Qt::blue;
        faceColors[3] = Qt::yellow;
        }

        void GamePlay::initializeGL()
        {
        qglClearColor(Qt::green);
        glShadeModel(GL_FLAT);
        glEnable(GL_DEPTH_TEST);
        glEnable(GL_CULL_FACE);
        }

        void GamePlay::resizeGL(int width,int height)
        {
        width=360;
        height=640;
        glViewport(0,0,width,height);
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        GLfloat x = GLfloat(width) / height;

        glFrustum(-x, x, -1, 1, 2.0, 15);
        glMatrixMode(GL_MODELVIEW);
        

        }

        void GamePlay::paintGL()
        {
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        draw();
        }

        void GamePlay::draw()
        {
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
        glTranslatef(0.0, 0, -10);

        glPointSize(4.0);
        glBegin(GL_POINTS);
        glVertex3f(0,0,0);
        glEnd();
        

        }

        @

        The draw function should draw a point of size 4 at the center of the screen.... right?

        I does draw a point but not in the Center of the screen(orgin).

        :)

        1 Reply Last reply
        0
        • M Offline
          M Offline
          minimoog77
          wrote on last edited by
          #4

          Please try setting projection matrix with gluPerspective.

          1 Reply Last reply
          0
          • D Offline
            D Offline
            Dinesh Balu
            wrote on last edited by
            #5

            No... I have tried that too... same effect...

            :)

            1 Reply Last reply
            0
            • D Offline
              D Offline
              Dinesh Balu
              wrote on last edited by
              #6

              Is this because of the simulator banner added by the QT in the output in simulator?

              :)

              1 Reply Last reply
              0
              • M Offline
                M Offline
                minimoog77
                wrote on last edited by
                #7

                What were the parameters for gluPerspective?

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved