opengl - QT for OpenglEs on Desktop -


i have existing project uses opengles library (libglesv2.lib) on desktop platform.

now want use qt user interface using qglwidget. after calling opengl function in qglwidget::initializegl function access violation executing location 0x00000000 error @ code below,

   void myglwidget::initializegl()     {           if (!context()->create())             throw std::exception("no context :)");         context()->makecurrent();          glviewport(0, 0, 640, 480);     } 

if include library opengl32.lib glviewport function works when hit glgenframebuffers same error.

could please let me know how can configure project use qt opengles on desktop platform.

if include library opengl32.lib glviewport function works when hit glgenframebuffers same error.

glviewport opengl function found in every opengl version , profile since version 1. such it's available linking against basic opengl interface library.

glgenframebuffers function introduced opengl-3 (opengl-es 2, btw, opengl-es not natively supported on windows) , before can use it, have to

  1. check supported
  2. load opengl context dependent function pointer @ runtime variable symbol you're calling

failing second step give error encounter. failing first step try load it, loading may fail leading same result if didn't (2) @ all.

qt provides function loading checks , executions you, suggest use it: http://doc.qt.io/qt-4.8/qglfunctions.html

it's not perfect, gets job done.

update (from comments)

most have opengl loader library in project, resolves everything, before using qt did initialize it. using qt you've got mix of statically resolved symbols through opengl32.lib , symbols provided loader, yet loader not initialized. through code before integrating qt , initializing call (called after creating opengl context/window before doing opengl work).

my best guest be, egl bindings use implement opengl-es wrapper/loader. explained, windows doesn't natively support opengl-es (only regular opengl) , kind of compatibility layer required. layer that's getting in way now. news is, since you're on windows can use regular native opengl-3 instead; part opengl-es subset of opengl-3. you'll still need runtime load gl-3 functions, said, qt can you.

what do:

  • replace occurrences of #include <egl/egl.h> #include <gl/gl.h> – should rid of symbol shadowing.
  • next, classes in use of opengl functions made, add inheritance of qglfunctions in classes' namespaces dynamically loaded functions used.

note every class inherits qglfunctions must instanced when target opengl context made current or call initializefunctions on instances qglwidget::initializegl (or derivatives). have function initialization once each instance of class inheriting qglfunctions , initialization function must called when opengl context that's used active. said, qt's qglfunctions not perfect; if necessary function pointer loading on demand, cache result , in case of opengl context switch automatically reinitialize.


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -