Reputation: 321
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
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