44 #include "../eglconvenience/qeglconvenience.h" 45 #include "../eglconvenience/qeglplatformcontext.h" 49 #include <KD/NV_initialize.h> 56 #ifdef QEGL_EXTRA_DEBUG 57 struct AttrInfo { EGLint attr;
const char *
name; };
58 static struct AttrInfo attrs[] = {
59 {EGL_BUFFER_SIZE,
"EGL_BUFFER_SIZE"},
60 {EGL_ALPHA_SIZE,
"EGL_ALPHA_SIZE"},
61 {EGL_BLUE_SIZE,
"EGL_BLUE_SIZE"},
62 {EGL_GREEN_SIZE,
"EGL_GREEN_SIZE"},
63 {EGL_RED_SIZE,
"EGL_RED_SIZE"},
64 {EGL_DEPTH_SIZE,
"EGL_DEPTH_SIZE"},
65 {EGL_STENCIL_SIZE,
"EGL_STENCIL_SIZE"},
66 {EGL_CONFIG_CAVEAT,
"EGL_CONFIG_CAVEAT"},
67 {EGL_CONFIG_ID,
"EGL_CONFIG_ID"},
68 {EGL_LEVEL,
"EGL_LEVEL"},
69 {EGL_MAX_PBUFFER_HEIGHT,
"EGL_MAX_PBUFFER_HEIGHT"},
70 {EGL_MAX_PBUFFER_PIXELS,
"EGL_MAX_PBUFFER_PIXELS"},
71 {EGL_MAX_PBUFFER_WIDTH,
"EGL_MAX_PBUFFER_WIDTH"},
72 {EGL_NATIVE_RENDERABLE,
"EGL_NATIVE_RENDERABLE"},
73 {EGL_NATIVE_VISUAL_ID,
"EGL_NATIVE_VISUAL_ID"},
74 {EGL_NATIVE_VISUAL_TYPE,
"EGL_NATIVE_VISUAL_TYPE"},
75 {EGL_SAMPLES,
"EGL_SAMPLES"},
76 {EGL_SAMPLE_BUFFERS,
"EGL_SAMPLE_BUFFERS"},
77 {EGL_SURFACE_TYPE,
"EGL_SURFACE_TYPE"},
78 {EGL_TRANSPARENT_TYPE,
"EGL_TRANSPARENT_TYPE"},
79 {EGL_TRANSPARENT_BLUE_VALUE,
"EGL_TRANSPARENT_BLUE_VALUE"},
80 {EGL_TRANSPARENT_GREEN_VALUE,
"EGL_TRANSPARENT_GREEN_VALUE"},
81 {EGL_TRANSPARENT_RED_VALUE,
"EGL_TRANSPARENT_RED_VALUE"},
82 {EGL_BIND_TO_TEXTURE_RGB,
"EGL_BIND_TO_TEXTURE_RGB"},
83 {EGL_BIND_TO_TEXTURE_RGBA,
"EGL_BIND_TO_TEXTURE_RGBA"},
84 {EGL_MIN_SWAP_INTERVAL,
"EGL_MIN_SWAP_INTERVAL"},
85 {EGL_MAX_SWAP_INTERVAL,
"EGL_MAX_SWAP_INTERVAL"},
87 #endif //QEGL_EXTRA_DEBUG 91 , m_format(
QImage::Format_Invalid)
92 , m_platformContext(0)
95 #ifdef QEGL_EXTRA_DEBUG 100 #ifdef QEGL_EXTRA_DEBUG 103 if (!eglBindAPI(EGL_OPENGL_ES_API)) {
104 qWarning(
"Could not bind GL_ES API\n");
108 m_dpy = eglGetDisplay(display);
109 if (
m_dpy == EGL_NO_DISPLAY) {
110 qWarning(
"Could not open egl display\n");
115 if (!eglInitialize(
m_dpy, &major, &minor)) {
116 qWarning(
"Could not initialize egl display\n");
120 qWarning(
"Initialized display %d %d\n", major, minor);
122 int swapInterval = 1;
124 if (!swapIntervalString.
isEmpty()) {
126 swapInterval = swapIntervalString.
toInt(&ok);
130 eglSwapInterval(
m_dpy, swapInterval);
144 if (depthString.
toInt() == 16) {
168 if (kdInitializeNV() == KD_ENOTINITIALIZED) {
169 qFatal(
"Did not manage to initialize openkode");
173 kdRealizeWindow(window,&eglWindow);
176 m_surface = eglCreateWindowSurface(
m_dpy, config, eglWindow, NULL);
178 qWarning(
"Could not create the egl surface: error = 0x%x\n", eglGetError());
184 #ifdef QEGL_EXTRA_DEBUG 185 qWarning(
"Configuration %d matches requirements\n", (
int)config);
189 if (eglGetConfigAttrib(
m_dpy, config, attrs[
index].attr, &value)) {
197 EGLint attribList[32];
201 attribList[temp++] = EGL_CONTEXT_CLIENT_VERSION;
202 attribList[temp++] = 2;
203 attribList[temp++] = EGL_NONE;
Format
The following image formats are available in Qt.
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
bool isNull() const
Returns true if the rectangle is a null rectangle, otherwise returns false.
#define QT_END_NAMESPACE
This macro expands to.
EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QPlatformWindowFormat &format, bool highestPixelFormat, int surfaceType)
The QByteArray class provides an array of bytes.
int depth() const
Reimplement in subclass to return current depth of the screen.
QPlatformGLContext * m_platformContext
NativeWindowType EGLNativeWindowType
#define QT_BEGIN_NAMESPACE
This macro expands to.
Q_GUI_EXPORT EGLDisplay display()
static bool isEmpty(const char *str)
Q_CORE_EXPORT void qWarning(const char *,...)
The QImage class provides a hardware-independent image representation that allows direct access to th...
void createAndSetPlatformContext() const
Q_CORE_EXPORT void qFatal(const char *,...)
The QPlatformGLContext class provides an abstraction for native GL contexts.
int toInt(bool *ok=0, int base=10) const
Returns the byte array converted to an int using base base, which is 10 by default and must be betwee...
QPlatformGLContext * platformContext() const
QImage::Format format() const
Reimplement in subclass to return the image format which corresponds to the screen format...
QRect geometry() const
Reimplement in subclass to return the pixel geometry of the screen.
The QRect class defines a rectangle in the plane using integer precision.
NativeDisplayType EGLNativeDisplayType
QEglFSScreen(EGLNativeDisplayType display)
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.