Giter Site home page Giter Site logo

Comments (3)

pwuertz avatar pwuertz commented on July 19, 2024

I guess many features of this plotting library could be implemented using only the most ancient OpenGL functions, but one of the reasons for writing qmlplotting was to get some more experience in using the now preferred, non fixed-function interface (OpenGL >= 3.0). Choosing OpenGL 3.0 as a bare minimum already is a very conservative choice I think, and I don't really want to go back to writing OpenGL 2 code - especially since every reasonable driver supports OpenGL 3.

What's puzzeling is that apparently one has to explicitly activate non-legacy OpenGL functions in Qt5/OSX, but that doesn't sound like a big deal. So when you said "the plots are much better", you compared your GLSL 1.2 modified version to the original where all the shaders didn't compile, right? I'd be very confused if you are saying that the plots using the GLSL 1.2 code look different to the ones using the (working) GLSL 1.3 code.

So up to now you didn't activate the GL 3 core profile, correct? How are you running the test scenes? By just opening them with qmlscene? In this case I don't really know how/if the Qt developers provide the ability to select the OpenGL profile. If you are using PyQt, you could try selecting a more recent OpenGL version as described in that link you mentioned.

Again, I'm a bit confused about the way OpenGL is handled in Qt/OSX. On other systems it seems you just get whatever functionality your video driver provides right away.

from qmlplotting.

pwuertz avatar pwuertz commented on July 19, 2024

If you are using PyQt5, could you try this modified version of test.py?

import numpy as np
from PyQt5 import QtCore, QtGui, QtQuick, QtOpenGL

# request OpenGL Core Profile (required for OSX)
glformat = QtOpenGL.QGLFormat()
glformat.setProfile(QtOpenGL.QGLFormat.CoreProfile);
QtOpenGL.QGLFormat.setDefaultFormat(glformat)

# setup qml application
app = QtGui.QGuiApplication([])
win = QtQuick.QQuickView()
win.setSource(QtCore.QUrl.fromLocalFile("test.qml"))
win.setResizeMode(win.SizeRootObjectToView)
win.show()

# show opengl version
def print_gl_version(qglcontext):
    glformat = qglcontext.format()
    glversion = "%d.%d" % (glformat.majorVersion(), glformat.minorVersion())
    print "OpenGL version: %s" % glversion
win.openglContextCreated.connect(print_gl_version)

# get objects from qml context
root = win.rootObject()
items = ["source", "image", "button"]
source, image, button = (root.findChild(QtCore.QObject, n) for n in items)

# default image size
width = 512
height = 512

# define test function
def update_image(img):
    h, w = img.shape
    Y, X = np.ogrid[-1:1:1j*h, -1:1:1j*w]
    img[:] = X * Y
    img += .2 * (np.random.random(img.shape) - .5)

# update example1: use numpy array as DataSource
def update_data1():
    img_buffer = np.empty((height, width), dtype=np.double)
    update_image(img_buffer)
    source.setData2D(img_buffer.ctypes.data, width, height)

# update example2: modify array allocated/owned by DataSource
def update_data2():
    ptr = source.allocateData2D(width, height)
    ptr.setsize(width * height * np.dtype(np.double).itemsize)
    img_buffer = np.frombuffer(ptr, dtype=np.double, count=width*height)
    img_buffer = img_buffer.reshape([height, width])
    update_image(img_buffer)
    source.commitData()

# update image on button clicked
button.clicked.connect(update_data2)
update_data2()

app.exec_()

from qmlplotting.

ThomasVogelpohl avatar ThomasVogelpohl commented on July 19, 2024

Hi Peter,

I would never suggest to revert your code to an old version of openGL.

I am starting your examples with qmlscene. I have not tried my Python installation for a while, but might try your changed pyqt code.

For my fast test I just set the return GLSL(130, part of the code to return GLSL(120,
and that made a difference already. I did not change the code from IN to ATTRIBUTE and stuff.
So obviously the code was complaining about that once it run.

I am quite puzzled as well why the OSX version of Qt enables a 'legacy' code from per 2008 ... ?
A KDAB blog actually states that they have implemented using the core profile together with the Qt Quick scenegraph so it should work.

Somehow I am out of my depth here and I will have to stop and read some more.

But thanks fo your help and goodwill !!!

Best regards,
Thomas

from qmlplotting.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.