Qt and OpenGL Primitives in mobile resolution



  • 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.



  • Please post some compilable code that reproduces your problem.



  • 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).



  • Please try setting projection matrix with gluPerspective.



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



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



  • What were the parameters for gluPerspective?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.