<commit_before>/*
 * GStreamer
 * Copyright (C) 2009 <NAME> <<EMAIL>>
 * Copyright (C) 2009 <NAME> <<EMAIL>>
 * Copyright (C) 2010 <NAME> <<EMAIL>>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#include <QtGui>
#include "gstthread.h"
#include "qglrenderer.h"
#include "pipeline.h"


#if defined(Q_WS_MAC)
extern void *qt_current_nsopengl_context();
#endif

/**
 * GluPerspective is part of the GLU library, and not supported as of newer (3.x?)
 * versions of OpenGL. An easy way to update the example is to write your own
 * replacement, something like this:
 * 
 * See http://stackoverflow.com/questions/9210118/qts-opengl-samples-complain-about-some-errors-and-wont-run
 */
void gluPerspective(double fovy,double aspect, double zNear, double zFar)
{
     // Start in projection mode.
     glMatrixMode(GL_PROJECTION);
     glLoadIdentity();
     double xmin, xmax, ymin, ymax;
     ymax = zNear * tan(fovy * M_PI / 360.0);
     ymin = -ymax;
     xmin = ymin * aspect;
     xmax = ymax * aspect;
     glFrustum(xmin, xmax, ymin, ymax, zNear, zFar);
}

QGLRenderer::QGLRenderer(const QString &videoLocation,
                         QWidget *parent)
  : QGLWidget(parent),
    videoLoc(videoLocation),
    gst_thread(NULL),
    closing(false),
    frame(NULL)
{
    move(20, 10);
    resize(640, 480);
}

QGLRenderer::~QGLRenderer()
{
}

void
QGLRenderer::initializeGL()
{
    GLContextID ctx;

#if defined(Q_WS_WIN)
    ctx.contextId = wglGetCurrentContext();
    ctx.dc = wglGetCurrentDC();
#elif defined (Q_WS_MAC)
    ctx.contextId = (NSOpenGLContext*) qt_current_nsopengl_context();
#elif defined(Q_WS_X11)
    ctx.contextId = glXGetCurrentContext();
    const char *display_name = getenv("DISPLAY");
    if(display_name == NULL)
    {
        // actually we should look for --display command line parameter here
        display_name = ":0.0";
    }
    ctx.display = XOpenDisplay(display_name);
    ctx.wnd = this->winId();
#endif

    // We need to unset Qt context before initializing gst-gl plugin.
    // Otherwise the attempt to share gst-gl context with Qt will fail.
    this->doneCurrent();
    this->gst_thread = <commit_msg>qglwtextureshare example: disable setting display<commit_after>/*
 * GStreamer
 * Copyright (C) 2009 <NAME> <<EMAIL>>
 * Copyright (C) 2009 <NAME> <<EMAIL>>
 * Copyright (C) 2010 <NAME> <<EMAIL>>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#include <QtGui>
#include "gstthread.h"
#include "qglrenderer.h"
#include "pipeline.h"


#if defined(Q_WS_MAC)
extern void *qt_current_nsopengl_context();
#endif

/**
 * GluPerspective is part of the GLU library, and not supported as of newer (3.x?)
 * versions of OpenGL. An easy way to update the example is to write your own
 * replacement, something like this:
 * 
 * See http://stackoverflow.com/questions/9210118/qts-opengl-samples-complain-about-some-errors-and-wont-run
 */
void gluPerspective(double fovy,double aspect, double zNear, double zFar)
{
     // Start in projection mode.
     glMatrixMode(GL_PROJECTION);
     glLoadIdentity();
     double xmin, xmax, ymin, ymax;
     ymax = zNear * tan(fovy * M_PI / 360.0);
     ymin = -ymax;
     xmin = ymin * aspect;
     xmax = ymax * aspect;
     glFrustum(xmin, xmax, ymin, ymax, zNear, zFar);
}

QGLRenderer::QGLRenderer(const QString &videoLocation,
                         QWidget *parent)
  : QGLWidget(parent),
    videoLoc(videoLocation),
    gst_thread(NULL),
    closing(false),
    frame(NULL)
{
    move(20, 10);
    resize(640, 480);
}

QGLRenderer::~QGLRenderer()
{
}

void
QGLRenderer::initializeGL()
{
    GLContextID ctx;

#if defined(Q_WS_WIN)
    ctx.contextId = wglGetCurrentContext();
    ctx.dc = wglGetCurrentDC();
#elif defined (Q_WS_MAC)
    ctx.contextId = (NSOpenGLContext*) qt_current_nsopengl_context();
#elif defined(Q_WS_X11)
// XXX: aalex disabled this:
//     ctx.contextId = glXGetCurrentContext();
//     const char *display_name = getenv("DISPLAY");
//     if(display_name == NULL)
//     {
//         // actually we should look for --display command line parameter here
//         display_name = ":0.0";
//     }
//     ctx.display = XOpenDisplay(display_name);
//     ctx.wnd = this->winId();
#endif

    // We need to unset Qt context before initializing gst-gl plugin.
    // Otherwise the attempt to share gst-gl context with Qt will fail.
    this->doneCurrent();
    this->gst_thread = 
{'fraction_non_alphanumeric': 0.10882352941176471, 'fraction_numerical': 0.01833910034602076, 'mean_word_length': 3.4435049961568023, 'pattern_counts': {'":': 2, '<': 23, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6031878', 'n_tokens_mistral': 1918, 'n_tokens_neox': 1810, 'n_words': 610}