Ejemplo n.º 1
0
void MainWidget::initializeGL()
{
    drawState = 0;

    initializeGLFunctions();

    qglClearColor(Qt::white);

    qDebug() << "Initializing shaders...";
    initShaders();

    qDebug() << "Initializing textures...";
    initTextures();

//! [2]
    // Enable depth buffer
    glEnable(GL_DEPTH_TEST);

    // Enable back face culling
    //glEnable(GL_CULL_FACE);
//! [2]

    qDebug() << "Initializing geometries...";
    FSController::getInstance()->geometries->init();

    // using QBasicTimer because its faster that QTimer
    timer->start(12, this);
}
Ejemplo n.º 2
0
void SQPrimitives::init(QGLShaderProgram *program)
{
    _program = program;
    initializeGLFunctions();
    glGenBuffers(2, _vboIds);
    initCubeGeometry();
}
Ejemplo n.º 3
0
void MainWidget::initializeGL()
{
    initializeGLFunctions();

    qglClearColor(Qt::black);

    qDebug() << "Initializing shaders...";
    initShaders();

    qDebug() << "Initializing textures...";
    initTextures();

//! [2]
    // Enable depth buffer
    glEnable(GL_DEPTH_TEST);

    // Enable back face culling
    glEnable(GL_CULL_FACE);
//! [2]

    qDebug() << "Initializing geometries...";
    geometries->init();

    // using QBasicTimer because its faster that QTimer
    timer->start(12, this);
}
/**
  OpenGL intialization.
  */
void MyQGLWidget::initializeGL()
{
    initializeGLFunctions(context());

    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);

    glShadeModel(GL_SMOOTH);
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);

    glEnable(GL_COLOR_MATERIAL);
    glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);

    glEnable(GL_DEPTH_TEST);
    glDepthFunc(GL_LEQUAL);
    glClearDepth(1.0f);

    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

    camera_.setPosition(50, 50, 125);
    camera_.lookAt(Vec3f(50, 50, 0), Vec3f(50, 50, 125), Vec3f(0, 1, 0));

    initMaze();
    initShaders();

    startUpdateLoop();
}
Ejemplo n.º 5
0
 void GeometryEngine::init()
 {
     initializeGLFunctions();
     glEnable(GL_COLOR_MATERIAL);	// color material
     glLineWidth(2.0);
     glPointSize(8.0);

 }
Ejemplo n.º 6
0
void OpenGLContainer::initializeGL() {
  initializeGLFunctions();  // It is very important that initializeGLFunctions() is at this location in the code
  glClearColor(.2, .2, .2, 1);
  glEnable(GL_DEPTH_TEST);
  glShadeModel(GL_SMOOTH);
  glEnable(GL_LIGHTING);  // requires glMaterial for the rendered objects to be viewed in color
  glEnable(GL_AUTO_NORMAL);
  glEnable(GL_NORMALIZE);
}
Ejemplo n.º 7
0
StelTexture::StelTexture() : loader(NULL), downloaded(false), isLoadingImage(false),
				   errorOccured(false), id(0), avgLuminance(-1.f)
{
	#if QT_VERSION>=0x040800
	initializeGLFunctions();
	#endif
	width = -1;
	height = -1;
}
Ejemplo n.º 8
0
void Canvas::initializeGL()
{
    initializeGLFunctions();

    mesh_shader.addShaderFromSourceFile(QGLShader::Vertex, ":/gl/mesh.vert");
    mesh_shader.addShaderFromSourceFile(QGLShader::Fragment, ":/gl/mesh.frag");
    mesh_shader.link();

    backdrop = new Backdrop();
}
Ejemplo n.º 9
0
void GLFluids::initializeGL()
{
    initializeGLFunctions();
    glGenBuffers(1, &vbo);
    glBindBuffer(GL_ARRAY_BUFFER, vbo);
    glBufferData(GL_ARRAY_BUFFER, sizeof(float2) * DS,
                 particles, GL_DYNAMIC_DRAW);
    glBindBuffer(GL_ARRAY_BUFFER, 0);
    cudaGraphicsGLRegisterBuffer(&cuda_vbo_resource, vbo, cudaGraphicsMapFlagsNone);

}
Ejemplo n.º 10
0
void ASprite::bindTexture(ATexture *fuckyou)
{
    initializeGLFunctions();
    m_texId = fuckyou->getTextureId();
    bindDefalutProgram();
    m_geometric.initParameter(fuckyou->width(),fuckyou->height(),
			      fuckyou->width(),fuckyou->height(),
			      0,0,
			      fuckyou->width(),fuckyou->height());
    initializeAll();
}
Ejemplo n.º 11
0
void ASprite::bindTexture(int textureId,int width,int height)
{
    initializeGLFunctions();
    m_texId = textureId;
    bindDefalutProgram();
    m_geometric.initParameter(width,height,
                  width,height,
                  0,0,
                  width,height);
    initializeAll();
}
Ejemplo n.º 12
0
void GeometryEngine::init()
{
    initializeGLFunctions();

    // Generate 2 VBOs
    glGenBuffers(2, vboIds);


    // Initializes cube geometry and transfers it to VBOs
    initCubeGeometry();
}
Ejemplo n.º 13
0
void MainWidget::initializeGL()
{
  initializeGLFunctions();
  qglClearColor(Qt::black);
  initShaders();
  initTextures();

  glEnable(GL_DEPTH_TEST);
  glEnable(GL_CULL_FACE);

  geometries.init(imageRatio);
}
Ejemplo n.º 14
0
void HistrogramStrech::initializeGL()
{
    // initialize GL function resolution for current context
    initializeGLFunctions();

    // init texture
    initTexture();

    // init vertex and fragment shaders
    initShaders();

    // initialize vertex buffer and write positions to vertex shader
    initVertexBuffer();
}
Ejemplo n.º 15
0
void AxisRenderer::render(const AxisCamera &camera, QGLShaderProgram &program, QGLBuffer &vertBuffer, QGLBuffer &indexBuffer, bool selected)
{
    qDebug()<<"[AxisRender] start of render";

    initializeGLFunctions();

    //bind the program for use
    if(!program.bind()){
        QMessageBox::critical(0, "Error", "Could not bind program for use");
        qFatal("Could not bind program for use");
    }

    qDebug()<<"[AxisRender] Drawing";

    //set up shader locations
    program.bind();
    GLint vertLoc = program.attributeLocation("vertex");
    Q_ASSERT(vertLoc != -1);
    GLint colorLoc = program.uniformLocation("color");
    Q_ASSERT(colorLoc != -1);
    GLint mvpLoc = program.uniformLocation("modelToCamera");
    Q_ASSERT(mvpLoc != -1);

    //set default color to a cyan
    QVector4D color(0.0f, .5f, 1.0f, 1.0f);

    //modify the color for selected geometry
    if(selected){
        qDebug()<<"[AxisRender] adding selection color";
        color = color + QVector4D(1.0f, 0.0f, 0.0f, 0.0f);
    }

    //set the uniform values
    program.setUniformValueArray(colorLoc, &color, 1);
    program.setUniformValueArray(mvpLoc, &camera.getProjMatrix(), 1);

    //bind and set the vertex buffer for attribute
    vertBuffer.bind();
    program.enableAttributeArray(vertLoc);
    program.setAttributeBuffer(vertLoc, GL_FLOAT, 0, 4);

    //bind the index buffer for the draw call
    indexBuffer.bind();

    qDebug()<<"[AxisRender] Drawing";

    //draw the index buffer NOTE: Hard set to 24 values for a box!
    glDrawElements(GL_LINES, 24, GL_UNSIGNED_INT, NULL);
}
Ejemplo n.º 16
0
QSGRenderer::QSGRenderer(QSGContext *context)
    : QObject()
    , m_clear_color(Qt::transparent)
    , m_clear_mode(ClearColorBuffer | ClearDepthBuffer)
    , m_current_opacity(1)
    , m_context(context)
    , m_root_node(0)
    , m_node_updater(0)
    , m_bindable(0)
    , m_changed_emitted(false)
    , m_mirrored(false)
    , m_is_rendering(false)
{
    initializeGLFunctions();
}
Ejemplo n.º 17
0
void GLWidget::initializeGL() {
    initializeGLFunctions();

    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_CULL_FACE);
    glCullFace(GL_BACK);
    glEnable(GL_BLEND);
    glDepthFunc(GL_LEQUAL);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    tFPS->start();
    tRender->start(16, this);

}
Ejemplo n.º 18
0
void WidgetAugmentedView::initialize()
{
    initializeGLFunctions();

    qDebug() << "OpenGL version:" << QString((const char*) glGetString(GL_VERSION));

    const float lightPos[] = { 0.05f, 0.5f, -0.4f, 0.0f };
    const float ambient[] = { 1.0f, 1.0f, 1.0f, 0.0f };

    glEnable(GL_LIGHT0);
    glLightfv(GL_LIGHT0, GL_POSITION, lightPos);
    glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);

    glCheckError();

    textureColor = RenderUtils::createTexture(ColorFrame::WIDTH, ColorFrame::HEIGHT);

    glCheckError();

    textureDepth = RenderUtils::createTexture(ColorFrame::WIDTH, ColorFrame::HEIGHT, GL_R16UI, GL_RED_INTEGER, GL_UNSIGNED_SHORT);

    glCheckError();

    shaderDefault.addShaderFromSourceCode(QGLShader::Vertex, QString(SHADER_DEFAULT_VERTEX));
    shaderDefault.addShaderFromSourceCode(QGLShader::Fragment, QString(SHADER_DEFAULT_FRAGMENT));
    shaderDefault.link();

    glCheckError();

    shader2D.addShaderFromSourceCode(QGLShader::Vertex, QString(SHADER_2D_VERTEX));
    shader2D.addShaderFromSourceCode(QGLShader::Fragment, QString(SHADER_2D_FRAGMENT));
    shader2D.link();

    glCheckError();

    shader2D.bind();
    shader2D.setUniformValue("colorMap", 0);
    shader2D.setUniformValue("depthMap", 1);
    shader2D.setUniformValue("zNear", static_cast<GLfloat>(zNear));
    shader2D.setUniformValue("zFar", static_cast<GLfloat>(zFar));
    shader2D.release();

    glCheckError();

    if (stream) stream->addNewFrameCallback(this, [this](const ColorFrame*, const DepthFrame*, const SkeletonFrame*) -> void {
        emit this->triggerRefresh();
    });
}
Ejemplo n.º 19
0
//  Opengl Callbacks.
//
//++++++++++++++++++++++
void glwidget::initializeGL() {

    //
    initializeGLFunctions();
    qglClearColor(Qt::black);
    create_shaders();
    create_geometry();

    // Enable depth buffer.
    //
    glEnable(GL_DEPTH_TEST);

    // Enable back face culling.
    //
    glEnable(GL_CULL_FACE);
}
Ejemplo n.º 20
0
void ImagesDisplay::initializeGL()
{
    image_aspect       =  1.0;
    ima_info.no_textures =  1;
    initializeGLFunctions();
    //qglClearColor(Qt::black);
    this->view_proj_function[0] = &ImagesDisplay::recalculate_perspective_frustrum;
    this->view_proj_function[1] = &ImagesDisplay::recalculate_perspective_frustrum;
    this->view_proj_function[2] = &ImagesDisplay::recalculate_perspective_frustrum;
    this->view_proj_function[3] = &ImagesDisplay::recalculate_perspective;
    this->view_proj_function[4] = &ImagesDisplay::recalculate_perspective;
    this->view_proj_function[5] = &ImagesDisplay::recalculate_perspective;

    this->paint_function[0] = &ImagesDisplay::paint_camera_frustrum;
    this->paint_function[1] = &ImagesDisplay::paint_projector_frustrum;
    this->paint_function[2] = &ImagesDisplay::paint_set_view;
    this->paint_function[3] = &ImagesDisplay::paint_preview_project;
    this->paint_function[4] = &ImagesDisplay::paint_projector_analysis;
    this->paint_function[5] = &ImagesDisplay::paint_3d_output;

    ima_info.current_step = 3;
    ima_info.step_color[0] = new QColor(Qt::blue);
    ima_info.step_color[1] = new QColor(Qt::magenta);
    ima_info.step_color[2] = new QColor(Qt::yellow);
    ima_info.step_color[3] = new QColor(Qt::red);
    ima_info.step_color[4] = new QColor(Qt::cyan);
    ima_info.step_color[5] = new QColor(Qt::green);

    qglClearColor(Qt::red);
    init_shaders();
    glEnable(GL_TEXTURE_2D);

    // Enable depth buffer
    glEnable(GL_DEPTH_TEST);

    // Enable back face culling so it is more efficient
    glEnable(GL_CULL_FACE);

    kernel.init();

    kernel.create_grid(&ima_info, 10, 10);

    // Use QBasicTimer because its faster than QTimer
    timer.start(12, this);
}
Ejemplo n.º 21
0
void AWidget::initializeGL()
{
    setCurrentScene(NULL);
    initializeGLFunctions();

    qglClearColor(Qt::black);

    //glEnable(GL_DEPTH_TEST);

    glEnable(GL_CULL_FACE);

    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    initDefalutShaderProgram();
    initResources();
    m_timer.start(15, this);
}
Ejemplo n.º 22
0
void HW3b::initializeGL()
{
    // initialize GL function resolution for current context
    initializeGLFunctions();
    initTexture();
    initShaders();
    initPoints();
    initVertexBuffer();
    
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_BLEND);
    glEnable(GL_LINE_SMOOTH);
//    glEnable(GL_CULL_FACE);
    glEnable(GL_DEPTH_TEST);
    
    glClearColor(0.0, 0.0, 0.0, 0.0);	// set background color
    glColor3f   (1.0, 1.0, 0.0);		// set foreground color
}
Ejemplo n.º 23
0
void MainWidget::initializeGL()
{
	initializeGLFunctions();
	qglClearColor(Qt::black);
	initShaders();
	initObjects();

//! [2]
	// Enable depth buffer
	glEnable(GL_DEPTH_TEST);

	// Enable back face culling
	glEnable(GL_CULL_FACE);
//! [2]


	// Use QBasicTimer because its faster than QTimer
	timer.start(12, this);
}
Ejemplo n.º 24
0
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// HW3a::initializeGL:
//
// Initialization routine before display loop.
// Gets called once before the first time resizeGL() or paintGL() is called.
//
void
HW3a::initializeGL()
{
	// initialize GL function resolution for current context
	initializeGLFunctions();

	// init texture
	initTexture();

	// init vertex and fragment shaders
	initShaders();

	// initialize vertex buffer and write positions to vertex shader
	initVertexBuffer();

	// init state variables
	glClearColor(0.0, 0.0, 0.0, 0.0);	// set background color
	glColor3f   (1.0, 1.0, 0.0);		// set foreground color
}
Ejemplo n.º 25
0
void Widget::initializeGL()
{
    timer.setInterval (10);
    timer.setSingleShot(false);
    timer.start();
    connect(&timer, SIGNAL(timeout()), this, SLOT(onTimer()));

    initializeGLFunctions();

    printf("\n%s\n", glGetString(GL_VERSION));
    printf("%s\n", glGetString(GL_VENDOR));
    printf("%s\n", glGetString(GL_RENDERER));
    fflush (stdout);
    QImage part_img (":/match.png");
    for (int line = 0; line < part_img.height(); line++)
    {
        QRgb *pixel = (QRgb *)part_img.scanLine (line);
        for (int b = 0; b < part_img.width(); b++)
            if( 0 == qRed(pixel[b]) &&
                0 == qGreen(pixel[b]) &&
                0 == qBlue(pixel[b])
            ) {
                pixel[b] = 0x00ffffff;
            }
    }

    partTexture = bindTexture (part_img,
                         GL_TEXTURE_2D,
                         GL_RGBA,
                         QGLContext::DefaultBindOption);

    myShader.addShaderFromSourceFile(QGLShader::Vertex, ":/ground.vert");
    myShader.addShaderFromSourceFile(QGLShader::Fragment, ":/ground.frag");
    myShader.link();
    particle.addShaderFromSourceFile(QGLShader::Vertex,":/particle.vert");
    particle.addShaderFromSourceFile(QGLShader::Fragment,":/particle.frag");
    particle.link();

    terrainMesh.loadRawTriangles(":/terrain.raw");

    terrainTexture =bindTexture(QImage(":/terrain.jpg"));
}
Ejemplo n.º 26
0
//! [6]
void GLWidget::initializeGL()
{
    initializeGLFunctions();
    qglClearColor(qtPurple.dark());

    knot = new Knot(10);
    knot->init();

    initShaders();
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_CULL_FACE);
    glShadeModel(GL_SMOOTH);
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);
    glEnable(GL_MULTISAMPLE);
    static GLfloat lightPosition[4] = { 0.5, 5.0, 7.0, 1.0 };
    glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);

    z = -6.0;
}
Ejemplo n.º 27
0
void MainWidgetTFM::initializeGL()
{
	layer = 0;
	initArrays();

    initializeGLFunctions();
    qglClearColor(Qt::black);
    initShaders();
    initTextures();

    // Enable depth buffer
    glEnable(GL_DEPTH_TEST);

    // Enable back face culling
    glEnable(GL_CULL_FACE);

    geometries.init();

    // Use QBasicTimer because its faster than QTimer
    timer.start(12, this);
}
Ejemplo n.º 28
0
void SQEngine::initializeGL()
{
    initializeGLFunctions();
    qglClearColor(Qt::black);
    initShaders();
    initTextures();

    glEnable(GL_DEPTH_TEST);
    glEnable(GL_CULL_FACE);

//    glEnable(GL_BLEND);
//    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//    glDepthMask(false);

    SQStack::instance()->init(&_shaderProgram, _puzzleEngine);
    SQPrimitives::instance()->init(&_shaderProgram);
    emit perspectiveChanged();

    // using QBasicTimer because its faster that QTimer
    _renderTimer.start(1000.0f / FRAMES_PER_SECOND, this);
}
Ejemplo n.º 29
0
void GLWidget::initializeDraw(){
    glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSPROC)glXGetProcAddress((GLubyte*)"glDeleteVertexArrays");
    glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC)glXGetProcAddress((GLubyte*)"glGenVertexArrays");
    glBindVertexArray = (PFNGLBINDVERTEXARRAYPROC)glXGetProcAddress((GLubyte*)"glBindVertexArray");

    //load opengl functions
    initializeGLFunctions();

    //set the clear color to black
    glClearColor(0,0,0,1);

    //enable depth testing
    glEnable(GL_DEPTH_TEST);

    //load and initialize shaders
    //load the shaders, link the shader, and set the shader to be active
    shader = new QGLShaderProgram();
    shader->addShaderFromSourceFile(QGLShader::Vertex, ":/basic.vert");
    shader->addShaderFromSourceFile(QGLShader::Fragment, ":/basic.frag");
    shader->link();
    shader->bind();
}
Ejemplo n.º 30
0
void IMUView::initializeGL()
{

	initializeGLFunctions();
	QtGLInit(this);
  
	QtGLAddLight(QVector4D(20.0f, 5.0f, 0.0f, 1.0f), QVector3D(0.2f, 0.2f, 0.2f),
                    QVector3D(0.2f, 0.2f, 0.2f), QVector3D(0.4f, 0.4f, 0.4f));

	QtGLAddLight(QVector4D(-20.0f, 5.0f, 0.0f, 1.0f), QVector3D(0.0f, 0.0f, 0.0f),
                    QVector3D(0.2f, 0.2f, 0.2f), QVector3D(0.8f, 0.8f, 0.8f));

	QtGLAddLight(QVector4D(0.0f, 0.0f, 0.0f, 1.0f), QVector3D(0.0f, 0.0f, 0.0f),
					QVector3D(0.2f, 0.2f, 0.2f), QVector3D(0.5f, 0.5f, 0.5f));

    m_IMUWidget = new VRIMUWidget(globalGLWidget);

    if (m_IMUWidget) {
        m_IMUWidget->setRotation(QVector3D());
        m_IMUWidget->VRWidgetInit();
	}
}