user3815068
user3815068

Reputation: 321

opengl + Qtwidget don't work

I'm creat a opengl program in qt application, and I'm using this video tutorial for this http://www.youtube.com/watch?v=1nzHSkY4K18. But my widget don't work, it does show image, only the image that was behind the screen. this and an example (from is my opengl view):

http://uploaddeimagens.com.br/imagens/screenshot_from_2014-07-09_02_44_19-png

And this is my codes:

my Qtwidget view:

#include "telafotos.h"
#include "ui_telafotos.h"

TelaFotos::TelaFotos(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::TelaFotos)
{
    ui->setupUi(this);
}

TelaFotos::~TelaFotos()
{
    delete ui;
}

My QGLWidget:

    #include "imagemfestivalgl.h"

ImagemFestivalGl::ImagemFestivalGl(QWidget *parent) :
    QGLWidget(parent)
{
}


void ImagemFestivalGl::initializeGL(){
    glClearColor(1,1,0,1);
}

void ImagemFestivalGl::paintGL(){

}

void ImagemFestivalGl::resizeGL(int w, int h){

}

Upvotes: 0

Views: 107

Answers (1)

ratchet freak
ratchet freak

Reputation: 48186

You need to set the viewport in resizeGL

void ImagemFestivalGl::resizeGL(int w, int h){
    glViewport (0,0,w,h);
}

and clear the draw buffers in paintGL

void ImagemFestivalGl::paintGL(){
    glClear (GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT);
}

This should result in a blank area

Upvotes: 1

Related Questions