Пример #1
0
void RenderBuffer::PrepareColorBuffer(GLsizei width, GLsizei height)
{
	glBindRenderbuffer(GL_RENDERBUFFER, _id);
    CHECK_OPENGL_ERROR();
	glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA4, width, height);
    CHECK_OPENGL_ERROR();
	glBindRenderbuffer(GL_RENDERBUFFER, 0);
    CHECK_OPENGL_ERROR();
}
Пример #2
0
void RenderBuffer::PrepareDepthBuffer(GLsizei width, GLsizei height)
{
	glBindRenderbuffer(GL_RENDERBUFFER, _id);
    CHECK_OPENGL_ERROR();
	glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height);
    CHECK_OPENGL_ERROR();
	glBindRenderbuffer(GL_RENDERBUFFER, 0);
    CHECK_OPENGL_ERROR();
}
Пример #3
0
oak::Window::Window(int x, int y, int w, int h, const std::string& name)
    : _lastWidth(-1),
      _lastHeight(-1),
      _lastX(-1),
      _lastY(-1)
{

    glutInitWindowSize(w, h);
    glutInitWindowPosition(x, y);
    _glutWindow = glutCreateWindow(name.c_str());

    _windowMap[_glutWindow] = this;

#ifdef Q_OS_WIN
    glewExperimental = GL_TRUE;
    glewInit();
    glGetError();
    CHECK_OPENGL_ERROR();
#endif

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

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

    glutDisplayFunc(paintCb);
    glutKeyboardFunc(keyCb);
    glutReshapeFunc(resizeCb);

    // ?
    resizeCb(w, h);
}
Пример #4
0
	void Device::MakeCurrentContext(void)
	{
		if (_deviceContext AND wglGetCurrentContext() != _renderContext)
			wglMakeCurrent(_deviceContext, _renderContext);

		CHECK_OPENGL_ERROR(SOURCE_LOCATION);
	}
Пример #5
0
RenderBuffer::RenderBuffer()
{
	glGenRenderbuffers(1, &_id);
    CHECK_OPENGL_ERROR();
}
Пример #6
0
RenderBuffer::~RenderBuffer()
{
	glDeleteRenderbuffers(1, &_id);
    CHECK_OPENGL_ERROR();
}
Пример #7
0
void depth_view_t::paintGL()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

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

    qglColor(Qt::white);

    auto histogram = _depth_map.get_histogram();
    if(histogram.size() > 0)
    {
        float factor[3] = {1, 1, 1};

        for (int y = 0; y < _depth_map.height(); ++y)
        {
            for (int x = 0; x < _depth_map.width(); ++x)
            {
                factor[0] = Colors[3][0];
                factor[1] = Colors[3][1];
                factor[2] = Colors[3][2];

                int hist_value = histogram[_depth_map.get(x,y)];
                auto& pix = _tex_map[x + _tex_map_width*y];
                pix.r = hist_value*factor[0];
                pix.g = hist_value*factor[1];
                pix.b = hist_value*factor[2];

                factor[0] = factor[1] = factor[2] = 1;
            }
        }

        glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, _tex_map_width, _tex_map_height, 0, GL_RGB, GL_UNSIGNED_BYTE, _tex_map.data());

        // Display the OpenGL texture map
        glColor4f(1,1,1,1);

        glEnable(GL_TEXTURE_2D);
        glBegin(GL_QUADS);

        // upper left
        glTexCoord2f(0, 0);
        glVertex2f(0, 0);
        // upper right
        glTexCoord2f((float)_depth_map.width()/(float)_tex_map_width, 0);
        glVertex2f(_width, 0);
        // bottom right
        glTexCoord2f((float)_depth_map.width()/(float)_tex_map_width, (float)_depth_map.height()/(float)_tex_map_height);
        glVertex2f(_width, _height);
        // bottom left
        glTexCoord2f(0, (float)_depth_map.height()/(float)_tex_map_height);
        glVertex2f(0, _height);

        glEnd();
        glDisable(GL_TEXTURE_2D);

        //paintTrack();
    }

    CHECK_OPENGL_ERROR();

    glPopMatrix();

    swapBuffers();
}
Пример #8
0
	void Device::SetViewport(UInt width, UInt height)
	{
		glViewport(0, 0, width, height);
		CHECK_OPENGL_ERROR(SOURCE_LOCATION);
	}
Пример #9
0
	void Device::Flush(void)
	{
		glFlush();
		CHECK_OPENGL_ERROR(SOURCE_LOCATION);
	}
Пример #10
0
	void Device::SwapChain(void)
	{
		SwapBuffers(_deviceContext);
		CHECK_OPENGL_ERROR(SOURCE_LOCATION);
	}
Пример #11
0
	void Device::DoneCurrentContext(void)
	{
		wglMakeCurrent(nullptr, nullptr);
		CHECK_OPENGL_ERROR(SOURCE_LOCATION);
	}
Пример #12
0
	void Device::ResetCurrentContext(void)
	{
		wglMakeCurrent(_deviceContext, nullptr);
		CHECK_OPENGL_ERROR(SOURCE_LOCATION);
	}