Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / qt / 2017-05

QOpenGLWidget override initializeGL and paintGL

6 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

max

How add QOpenGLWidget to qt5 bindings ?

Render OpenGL need override few virtual functions: initializeGL and paintGL.

How implement virtual functions ?

m

zeljko
to max
max wrote 6 lines
How add QOpenGLWidget to qt5 bindings ? Render OpenGL need override few virtual functions: initializeGL and paintGL. How implement virtual functions ?

It's not big problem to add QOpenGLxx to bindings but that's something I don't like. Qt5Pas should contain only base gui and widgets, maybe create separate Qt5PasOpenGL and qt5opengl.pas.
I've already added QSurface, QSurfaceType and QWindow classes which can be used for openGl

zeljko

MariuszB
to zeljko
Show quoted text 8 lines
It's not big problem to add QOpenGLxx to bindings but that's something I don't like. Qt5Pas should contain only base gui and widgets, maybe create separate Qt5PasOpenGL and qt5opengl.pas. I've already added QSurface, QSurfaceType and QWindow classes which can be used for openGl zeljko

I think about my needs, and I see that I do not need all QOpenGLx. Can you tell me how to create OpenGL context for windows or panel in Qt5 bindings ?
I'll ask some more crumbs ;)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/qt/attachments/20170526/816e6e13/attachment.html>

zeljko
to MariuszB
MariuszB wrote 12 lines
> It's not big problem to add QOpenGLxx to bindings but that's something > I don't like. Qt5Pas should contain only base gui and widgets, maybe > create separate Qt5PasOpenGL and qt5opengl.pas. > I've already added QSurface, QSurfaceType and QWindow classes which > can be used for openGl > > zeljko > I think about my needs, and I see that I do not need all QOpenGLx. Can you tell me how to create OpenGL context for windows or panel in Qt5 bindings ?

Really don't know :) Never played with OpenGL. Try to instantiate QApplication, create QWindow and via it's QSurfaceType set to OpenGL .. and see what happens :)

zeljko

max
to zeljko
Show quoted text 6 lines
Really don't know :) Never played with OpenGL. Try to instantiate QApplication, create QWindow and via it's QSurfaceType set to OpenGL .. and see what happens :) zeljko

For OpenGL we need "QOpenGLContext" only ;)

All function glXX are from "GL/gl.h"

Sample application in QT

////////////////////////////////////////////////////////////
//////////////// main.cpp
#include<QApplication>
#include<QWindow >
#include<QOpenGLContext >
//#include <QOpenGLFunctions>
#include<GL/gl.h >//

intmain(intargc,char*argv[])

{

QApplicationa(argc,argv);
QWindow*embed;
embed=newQWindow;
embed->setSurfaceType(QWindow::OpenGLSurface);
embed->setGeometry(QRect(50,50,640,480));
embed->setVisible(true);
QOpenGLContext*m_context;
m_context=newQOpenGLContext();
m_context->create();
m_context->makeCurrent(embed);
// <QOpenGLFunctions> version
//QOpenGLFunctions *f = m_context->functions();
//f->glClearColor(1.0,0,0,1.0);
//f->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// <GL/gl.h> VERSION
glClearColor(1.0,0,0,1.0);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
// Define shapes enclosed within a pair of glBegin and glEnd
glBegin(GL_QUADS);// Each set of 4 vertices form a quad
glColor3f(1.0f,0.0f,0.0f);// Red
glVertex2f(-0.8f,0.1f);// Define vertices in counter-clockwise (CCW) order
glVertex2f(-0.2f,0.1f);//  so that the normal (front-face) is facing you
glVertex2f(-0.2f,0.7f);
glVertex2f(-0.8f,0.7f);
glColor3f(0.0f,1.0f,0.0f);// Green
glVertex2f(-0.7f,-0.6f);
glVertex2f(-0.1f,-0.6f);
glVertex2f(-0.1f,0.0f);
glVertex2f(-0.7f,0.0f);
glColor3f(0.2f,0.2f,0.2f);// Dark Gray
glVertex2f(-0.9f,-0.7f);
glColor3f(1.0f,1.0f,1.0f);// White
glVertex2f(-0.5f,-0.7f);
glColor3f(0.2f,0.2f,0.2f);// Dark Gray
glVertex2f(-0.5f,-0.3f);
glColor3f(1.0f,1.0f,1.0f);// White
glVertex2f(-0.9f,-0.3f);
glEnd();
m_context->swapBuffers(embed);
returna.exec();

}

//////////////////////////////////////////////////////////// #------------------------------------------------- #
#ProjectcreatedbyQtCreator2017-05-26T18:32:13
#
#------------------------------------------------- QT+=coregui
LIBS+=-lglut-lopengl32
greaterThan(QT_MAJOR_VERSION,4):QT+=widgets
TARGET=nienazwany1
TEMPLATE=app
SOURCES+=main.cpp

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/qt/attachments/20170526/e47b0f9f/attachment-0001.html>

zeljko
to max
max wrote 8 lines
> Really don't know :) Never played with OpenGL. Try to instantiate > QApplication, create QWindow and via it's QSurfaceType set to OpenGL > .. and see what happens :) > > zeljko > For OpenGL we need "QOpenGLContext" only ;)

Of course, but I'm not planning to add it to Qt5Pas bindings in any case. It can be created as standalone Qt5OpenGLPas lib and qt5opengl.pas, so used