Пример #1
0
void gl_DrawScreen() {
	GLuint texture;

	_glClear( GL_COLOR_BUFFER_BIT );
	_glGenTextures(1, &texture);
	_glBindTexture( GL_TEXTURE_2D, texture );

	if ((VideoMode == 0) || (VideoMode == 2) || (VideoMode == 4)) {
		_glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
		_glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
		}
	else {
		_glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
		_glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
	}
	
	_glTexImage2D( GL_TEXTURE_2D, 0, 3, srv_screen->w, srv_screen->h, 0, GL_BGRA, GL_UNSIGNED_BYTE, texture_buffer );
	
	_glBegin( GL_QUADS );
	_glTexCoord2i( 0, 0 );
	_glVertex2i( 0, 0 );
	_glTexCoord2i( 1, 0 );
	_glVertex2i( screen_width, 0 );
	_glTexCoord2i( 1, 1 );
	_glVertex2i( screen_width, screen_height );
	_glTexCoord2i( 0, 1);
	_glVertex2i( 0, screen_height );
	_glEnd();
	
	_glDeleteTextures(1, &texture );
}
Пример #2
0
static void
_eglCreateImageKHR_get_image_size(EGLImageKHR image, image_info *info)
{
    GLuint fbo = 0;
    GLuint orig_fbo = 0;
    GLuint texture = 0;
    GLuint orig_texture;
    GLenum status;

    _glGetIntegerv(GL_FRAMEBUFFER_BINDING, (GLint *)&orig_fbo);
    _glGenFramebuffers(1, &fbo);
    _glBindFramebuffer(GL_FRAMEBUFFER, fbo);

    _glGetIntegerv(GL_TEXTURE_BINDING_2D, (GLint *)&orig_texture);
    _glGenTextures(1, &texture);
    _glBindTexture(GL_TEXTURE_2D, texture);

    _glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image);

    info->width = 0;
    info->height = 0;

    _glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
                            GL_TEXTURE_2D, texture, 0);
    status = _glCheckFramebufferStatus(GL_FRAMEBUFFER);
    if (status == GL_FRAMEBUFFER_COMPLETE) {
        if (detect_size(&info->width, &info->height) != 0)
            os::log("%s: can't detect image size\n", __func__);
    } else {
        os::log("%s: error: %x\n", __func__, status);
    }

    /* Don't leak errors to the traced application. */
    (void)_glGetError();

    _glBindTexture(GL_TEXTURE_2D, orig_texture);
    _glDeleteTextures(1, &texture);

    _glBindFramebuffer(GL_FRAMEBUFFER, orig_fbo);
    _glDeleteFramebuffers(1, &fbo);
}