2012-06-19 19:01:34 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
|
|
|
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
|
|
|
* Copyright (C) 2012 - Michael Lelli
|
2012-09-18 23:41:58 +00:00
|
|
|
*
|
2012-06-19 19:01:34 +00:00
|
|
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* RetroArch 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
#include <VG/openvg.h>
|
|
|
|
#include <EGL/egl.h>
|
2012-09-18 23:41:58 +00:00
|
|
|
#include "gfx_context.h"
|
2012-09-24 23:30:24 +00:00
|
|
|
#include "math/matrix_3x3.h"
|
2012-06-19 19:01:34 +00:00
|
|
|
#include "../libretro.h"
|
|
|
|
#include "../general.h"
|
|
|
|
#include "../driver.h"
|
|
|
|
|
|
|
|
#ifdef HAVE_FREETYPE
|
|
|
|
#include "fonts/fonts.h"
|
|
|
|
#include "../file.h"
|
|
|
|
#endif
|
|
|
|
|
2012-06-22 17:16:53 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2012-09-25 00:47:48 +00:00
|
|
|
const gfx_ctx_driver_t *driver;
|
2012-06-19 19:01:34 +00:00
|
|
|
uint32_t mScreenWidth;
|
|
|
|
uint32_t mScreenHeight;
|
|
|
|
float mScreenAspect;
|
|
|
|
bool mKeepAspect;
|
|
|
|
unsigned mTextureWidth;
|
|
|
|
unsigned mTextureHeight;
|
|
|
|
unsigned mRenderWidth;
|
|
|
|
unsigned mRenderHeight;
|
|
|
|
unsigned x1, y1, x2, y2;
|
2012-09-18 23:41:58 +00:00
|
|
|
unsigned frame_count;
|
2012-06-19 19:01:34 +00:00
|
|
|
VGImageFormat mTexType;
|
|
|
|
VGImage mImage;
|
2012-09-24 23:30:24 +00:00
|
|
|
math_matrix_3x3 mTransformMatrix;
|
2012-06-19 19:01:34 +00:00
|
|
|
VGint scissor[4];
|
|
|
|
|
|
|
|
#ifdef HAVE_FREETYPE
|
|
|
|
char *mLastMsg;
|
|
|
|
uint32_t mFontHeight;
|
|
|
|
VGFont mFont;
|
|
|
|
font_renderer_t *mFontRenderer;
|
|
|
|
bool mFontsOn;
|
|
|
|
VGuint mMsgLength;
|
|
|
|
VGuint mGlyphIndices[1024];
|
|
|
|
VGPaint mPaintFg;
|
|
|
|
VGPaint mPaintBg;
|
|
|
|
#endif
|
2012-09-24 19:19:07 +00:00
|
|
|
} vg_t;
|
2012-06-19 19:01:34 +00:00
|
|
|
|
2012-09-24 19:19:07 +00:00
|
|
|
static void vg_set_nonblock_state(void *data, bool state)
|
2012-06-19 19:01:34 +00:00
|
|
|
{
|
2012-09-25 00:47:48 +00:00
|
|
|
vg_t *vg = (vg_t*)data;
|
|
|
|
vg->driver->swap_interval(state ? 0 : 1);
|
2012-06-19 19:01:34 +00:00
|
|
|
}
|
|
|
|
|
2012-09-24 19:19:07 +00:00
|
|
|
static void *vg_init(const video_info_t *video, const input_driver_t **input, void **input_data)
|
2012-06-19 19:01:34 +00:00
|
|
|
{
|
2012-09-24 19:19:07 +00:00
|
|
|
vg_t *vg = (vg_t*)calloc(1, sizeof(vg_t));
|
|
|
|
if (!vg)
|
2012-09-18 23:41:58 +00:00
|
|
|
return NULL;
|
2012-06-19 19:01:34 +00:00
|
|
|
|
2012-09-25 00:47:48 +00:00
|
|
|
vg->driver = gfx_ctx_init_first(GFX_CTX_OPENVG_API);
|
2012-06-19 19:01:34 +00:00
|
|
|
|
2012-09-25 00:47:48 +00:00
|
|
|
if (!vg->driver)
|
2012-06-19 19:01:34 +00:00
|
|
|
{
|
2012-09-24 19:19:07 +00:00
|
|
|
free(vg);
|
2012-09-18 23:41:58 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2012-06-19 19:01:34 +00:00
|
|
|
|
2012-09-25 00:47:48 +00:00
|
|
|
vg->driver->get_video_size(&vg->mScreenWidth, &vg->mScreenHeight);
|
2012-09-24 19:19:07 +00:00
|
|
|
RARCH_LOG("Detecting screen resolution %ux%u.\n", vg->mScreenWidth, vg->mScreenHeight);
|
2012-06-19 19:01:34 +00:00
|
|
|
|
2012-09-25 00:47:48 +00:00
|
|
|
vg->driver->swap_interval(video->vsync ? 1 : 0);
|
2012-06-19 19:01:34 +00:00
|
|
|
|
2012-09-24 19:19:07 +00:00
|
|
|
vg->mTexType = video->rgb32 ? VG_sABGR_8888 : VG_sARGB_1555;
|
|
|
|
vg->mKeepAspect = video->force_aspect;
|
2012-06-19 19:01:34 +00:00
|
|
|
|
2012-09-25 00:47:48 +00:00
|
|
|
unsigned win_width = video->width;
|
|
|
|
unsigned win_height = video->height;
|
|
|
|
if (video->fullscreen && (win_width == 0) && (win_height == 0))
|
|
|
|
{
|
|
|
|
win_width = vg->mScreenWidth;
|
|
|
|
win_height = vg->mScreenHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!vg->driver->set_video_mode(vg->mScreenWidth, vg->mScreenHeight,
|
|
|
|
g_settings.video.force_16bit ? 15 : 0, video->fullscreen))
|
|
|
|
{
|
|
|
|
free(vg);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
vg->driver->get_video_size(&vg->mScreenWidth, &vg->mScreenHeight);
|
|
|
|
|
2012-06-19 19:01:34 +00:00
|
|
|
// check for SD televisions: they should always be 4:3
|
2012-09-24 19:19:07 +00:00
|
|
|
if ((vg->mScreenWidth == 640 || vg->mScreenWidth == 720) && (vg->mScreenHeight == 480 || vg->mScreenHeight == 576))
|
|
|
|
vg->mScreenAspect = 4.0f / 3.0f;
|
2012-06-19 19:01:34 +00:00
|
|
|
else
|
2012-09-24 19:19:07 +00:00
|
|
|
vg->mScreenAspect = (float)vg->mScreenWidth / vg->mScreenHeight;
|
2012-06-19 19:01:34 +00:00
|
|
|
|
|
|
|
VGfloat clearColor[4] = {0, 0, 0, 1};
|
|
|
|
vgSetfv(VG_CLEAR_COLOR, 4, clearColor);
|
|
|
|
|
2012-09-24 19:19:07 +00:00
|
|
|
vg->mTextureWidth = vg->mTextureHeight = video->input_scale * RARCH_SCALE_BASE;
|
2012-06-19 19:01:34 +00:00
|
|
|
// We can't use the native format because there's no sXRGB_1555 type and
|
|
|
|
// emulation cores can send 0 in the top bit. We lose some speed on
|
|
|
|
// conversion but I doubt it has any real affect, since we are only drawing
|
|
|
|
// one image at the end of the day. Still keep the alpha channel for ABGR.
|
2012-09-24 19:19:07 +00:00
|
|
|
vg->mImage = vgCreateImage(video->rgb32 ? VG_sABGR_8888 : VG_sXBGR_8888,
|
|
|
|
vg->mTextureWidth, vg->mTextureHeight,
|
2012-06-22 17:16:53 +00:00
|
|
|
video->smooth ? VG_IMAGE_QUALITY_BETTER : VG_IMAGE_QUALITY_NONANTIALIASED);
|
2012-09-24 19:19:07 +00:00
|
|
|
vg_set_nonblock_state(vg, !video->vsync);
|
2012-06-19 19:01:34 +00:00
|
|
|
|
2012-09-25 00:47:48 +00:00
|
|
|
vg->driver->input_driver(input, input_data);
|
2012-06-19 19:01:34 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_FREETYPE
|
|
|
|
if (g_settings.video.font_enable)
|
|
|
|
{
|
2012-09-24 19:19:07 +00:00
|
|
|
vg->mFont = vgCreateFont(0);
|
|
|
|
vg->mFontHeight = g_settings.video.font_size * (g_settings.video.font_scale ? (float) vg->mScreenWidth / 1280.0f : 1.0f);
|
2012-06-19 19:01:34 +00:00
|
|
|
|
|
|
|
const char *path = g_settings.video.font_path;
|
|
|
|
if (!*path || !path_file_exists(path))
|
|
|
|
path = font_renderer_get_default_font();
|
|
|
|
|
2012-09-24 19:19:07 +00:00
|
|
|
vg->mFontRenderer = font_renderer_new(path, vg->mFontHeight);
|
2012-06-19 19:01:34 +00:00
|
|
|
|
2012-09-24 19:19:07 +00:00
|
|
|
if (vg->mFont != VG_INVALID_HANDLE && vg->mFontRenderer)
|
2012-06-19 19:01:34 +00:00
|
|
|
{
|
2012-09-24 19:19:07 +00:00
|
|
|
vg->mFontsOn = true;
|
2012-06-19 19:01:34 +00:00
|
|
|
|
2012-09-24 19:19:07 +00:00
|
|
|
vg->mPaintFg = vgCreatePaint();
|
|
|
|
vg->mPaintBg = vgCreatePaint();
|
2012-06-19 19:01:34 +00:00
|
|
|
VGfloat paintFg[] = { g_settings.video.msg_color_r, g_settings.video.msg_color_g, g_settings.video.msg_color_b, 1.0f };
|
|
|
|
VGfloat paintBg[] = { g_settings.video.msg_color_r / 2.0f, g_settings.video.msg_color_g / 2.0f, g_settings.video.msg_color_b / 2.0f, 0.5f };
|
|
|
|
|
2012-09-24 19:19:07 +00:00
|
|
|
vgSetParameteri(vg->mPaintFg, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
|
|
|
|
vgSetParameterfv(vg->mPaintFg, VG_PAINT_COLOR, 4, paintFg);
|
2012-06-19 19:01:34 +00:00
|
|
|
|
2012-09-24 19:19:07 +00:00
|
|
|
vgSetParameteri(vg->mPaintBg, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
|
|
|
|
vgSetParameterfv(vg->mPaintBg, VG_PAINT_COLOR, 4, paintBg);
|
2012-06-19 19:01:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-09-24 19:19:07 +00:00
|
|
|
return vg;
|
2012-06-19 19:01:34 +00:00
|
|
|
}
|
|
|
|
|
2012-09-24 19:19:07 +00:00
|
|
|
static void vg_free(void *data)
|
2012-06-19 19:01:34 +00:00
|
|
|
{
|
2012-09-24 19:19:07 +00:00
|
|
|
vg_t *vg = (vg_t*)data;
|
2012-06-19 19:01:34 +00:00
|
|
|
|
2012-09-24 19:19:07 +00:00
|
|
|
vgDestroyImage(vg->mImage);
|
2012-06-19 19:01:34 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_FREETYPE
|
2012-09-24 19:19:07 +00:00
|
|
|
if (vg->mFontsOn)
|
2012-06-19 19:01:34 +00:00
|
|
|
{
|
2012-09-24 19:19:07 +00:00
|
|
|
vgDestroyFont(vg->mFont);
|
|
|
|
font_renderer_free(vg->mFontRenderer);
|
|
|
|
vgDestroyPaint(vg->mPaintFg);
|
|
|
|
vgDestroyPaint(vg->mPaintBg);
|
2012-06-19 19:01:34 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-09-25 00:47:48 +00:00
|
|
|
vg->driver->destroy();
|
2012-06-19 19:01:34 +00:00
|
|
|
|
2012-09-24 19:19:07 +00:00
|
|
|
free(vg);
|
2012-06-19 19:01:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef HAVE_FREETYPE
|
|
|
|
|
2012-09-24 19:19:07 +00:00
|
|
|
static void vg_render_message(vg_t *vg, const char *msg)
|
2012-06-19 19:01:34 +00:00
|
|
|
{
|
2012-09-24 19:19:07 +00:00
|
|
|
free(vg->mLastMsg);
|
|
|
|
vg->mLastMsg = strdup(msg);
|
2012-06-19 19:01:34 +00:00
|
|
|
|
2012-09-24 19:19:07 +00:00
|
|
|
if (vg->mMsgLength)
|
2012-06-19 19:01:34 +00:00
|
|
|
{
|
2012-09-24 19:19:07 +00:00
|
|
|
while (--vg->mMsgLength)
|
|
|
|
vgClearGlyph(vg->mFont, vg->mMsgLength);
|
2012-06-19 19:01:34 +00:00
|
|
|
|
2012-09-24 19:19:07 +00:00
|
|
|
vgClearGlyph(vg->mFont, 0);
|
2012-06-19 19:01:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct font_output_list out;
|
2012-09-24 19:19:07 +00:00
|
|
|
font_renderer_msg(vg->mFontRenderer, msg, &out);
|
2012-06-19 19:01:34 +00:00
|
|
|
struct font_output *head = out.head;
|
|
|
|
|
|
|
|
while (head)
|
|
|
|
{
|
2012-09-24 19:19:07 +00:00
|
|
|
if (vg->mMsgLength >= 1024)
|
2012-06-19 19:01:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
VGfloat origin[2], escapement[2];
|
|
|
|
VGImage img;
|
|
|
|
|
2012-06-22 17:16:53 +00:00
|
|
|
escapement[0] = head->advance_x;
|
|
|
|
escapement[1] = head->advance_y;
|
|
|
|
origin[0] = -head->char_off_x;
|
2012-07-10 11:40:13 +00:00
|
|
|
origin[1] = -head->char_off_y;
|
2012-06-19 19:01:34 +00:00
|
|
|
|
|
|
|
img = vgCreateImage(VG_A_8, head->width, head->height, VG_IMAGE_QUALITY_NONANTIALIASED);
|
|
|
|
|
|
|
|
// flip it
|
|
|
|
for (unsigned i = 0; i < head->height; i++)
|
|
|
|
vgImageSubData(img, head->output + head->pitch * i, head->pitch, VG_A_8, 0, head->height - i - 1, head->width, 1);
|
|
|
|
|
2012-09-24 19:19:07 +00:00
|
|
|
vgSetGlyphToImage(vg->mFont, vg->mMsgLength, img, origin, escapement);
|
2012-06-19 19:01:34 +00:00
|
|
|
vgDestroyImage(img);
|
|
|
|
|
2012-09-24 19:19:07 +00:00
|
|
|
vg->mMsgLength++;
|
2012-06-19 19:01:34 +00:00
|
|
|
head = head->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
font_renderer_free_output(&out);
|
|
|
|
|
2012-09-24 19:19:07 +00:00
|
|
|
for (unsigned i = 0; i < vg->mMsgLength; i++)
|
|
|
|
vg->mGlyphIndices[i] = i;
|
2012-06-19 19:01:34 +00:00
|
|
|
}
|
|
|
|
|
2012-09-24 19:19:07 +00:00
|
|
|
static void vg_draw_message(vg_t *vg, const char *msg)
|
2012-06-19 19:01:34 +00:00
|
|
|
{
|
2012-09-24 19:19:07 +00:00
|
|
|
if (!vg->mLastMsg || strcmp(vg->mLastMsg, msg))
|
|
|
|
vg_render_message(vg, msg);
|
2012-06-19 19:01:34 +00:00
|
|
|
|
|
|
|
vgSeti(VG_SCISSORING, VG_FALSE);
|
|
|
|
vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_STENCIL);
|
|
|
|
|
2012-06-22 17:16:53 +00:00
|
|
|
VGfloat origins[] = {
|
2012-09-24 19:19:07 +00:00
|
|
|
vg->mScreenWidth * g_settings.video.msg_pos_x - 2.0f,
|
|
|
|
vg->mScreenHeight * g_settings.video.msg_pos_y - 2.0f,
|
2012-06-22 17:16:53 +00:00
|
|
|
};
|
|
|
|
|
2012-06-19 19:01:34 +00:00
|
|
|
vgSetfv(VG_GLYPH_ORIGIN, 2, origins);
|
2012-09-24 19:19:07 +00:00
|
|
|
vgSetPaint(vg->mPaintBg, VG_FILL_PATH);
|
|
|
|
vgDrawGlyphs(vg->mFont, vg->mMsgLength, vg->mGlyphIndices, NULL, NULL, VG_FILL_PATH, VG_TRUE);
|
2012-06-19 19:01:34 +00:00
|
|
|
origins[0] += 2.0f;
|
|
|
|
origins[1] += 2.0f;
|
|
|
|
vgSetfv(VG_GLYPH_ORIGIN, 2, origins);
|
2012-09-24 19:19:07 +00:00
|
|
|
vgSetPaint(vg->mPaintFg, VG_FILL_PATH);
|
|
|
|
vgDrawGlyphs(vg->mFont, vg->mMsgLength, vg->mGlyphIndices, NULL, NULL, VG_FILL_PATH, VG_TRUE);
|
2012-06-19 19:01:34 +00:00
|
|
|
|
|
|
|
vgSeti(VG_SCISSORING, VG_TRUE);
|
|
|
|
vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_NORMAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2012-09-24 19:19:07 +00:00
|
|
|
static void vg_calculate_quad(vg_t *vg)
|
2012-06-19 19:01:34 +00:00
|
|
|
{
|
|
|
|
// set viewport for aspect ratio, taken from the OpenGL driver
|
2012-09-24 19:19:07 +00:00
|
|
|
if (vg->mKeepAspect)
|
2012-06-19 19:01:34 +00:00
|
|
|
{
|
|
|
|
float desired_aspect = g_settings.video.aspect_ratio;
|
|
|
|
|
|
|
|
// If the aspect ratios of screen and desired aspect ratio are sufficiently equal (floating point stuff),
|
|
|
|
// assume they are actually equal.
|
2012-09-24 19:19:07 +00:00
|
|
|
if (fabs(vg->mScreenAspect - desired_aspect) < 0.0001)
|
2012-06-19 19:01:34 +00:00
|
|
|
{
|
2012-09-24 19:19:07 +00:00
|
|
|
vg->x1 = 0;
|
|
|
|
vg->y1 = 0;
|
|
|
|
vg->x2 = vg->mScreenWidth;
|
|
|
|
vg->y2 = vg->mScreenHeight;
|
2012-06-19 19:01:34 +00:00
|
|
|
}
|
2012-09-24 19:19:07 +00:00
|
|
|
else if (vg->mScreenAspect > desired_aspect)
|
2012-06-19 19:01:34 +00:00
|
|
|
{
|
2012-09-24 19:19:07 +00:00
|
|
|
float delta = (desired_aspect / vg->mScreenAspect - 1.0) / 2.0 + 0.5;
|
|
|
|
vg->x1 = vg->mScreenWidth * (0.5 - delta);
|
|
|
|
vg->y1 = 0;
|
|
|
|
vg->x2 = 2.0 * vg->mScreenWidth * delta + vg->x1;
|
|
|
|
vg->y2 = vg->mScreenHeight + vg->y1;
|
2012-06-19 19:01:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-09-24 19:19:07 +00:00
|
|
|
float delta = (vg->mScreenAspect / desired_aspect - 1.0) / 2.0 + 0.5;
|
|
|
|
vg->x1 = 0;
|
|
|
|
vg->y1 = vg->mScreenHeight * (0.5 - delta);
|
|
|
|
vg->x2 = vg->mScreenWidth + vg->x1;
|
|
|
|
vg->y2 = 2.0 * vg->mScreenHeight * delta + vg->y1;
|
2012-06-19 19:01:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-09-24 19:19:07 +00:00
|
|
|
vg->x1 = 0;
|
|
|
|
vg->y1 = 0;
|
|
|
|
vg->x2 = vg->mScreenWidth;
|
|
|
|
vg->y2 = vg->mScreenHeight;
|
2012-06-19 19:01:34 +00:00
|
|
|
}
|
|
|
|
|
2012-09-24 19:19:07 +00:00
|
|
|
vg->scissor[0] = vg->x1;
|
|
|
|
vg->scissor[1] = vg->y1;
|
|
|
|
vg->scissor[2] = vg->x2 - vg->x1;
|
|
|
|
vg->scissor[3] = vg->y2 - vg->y1;
|
2012-06-19 19:01:34 +00:00
|
|
|
|
2012-09-24 19:19:07 +00:00
|
|
|
vgSetiv(VG_SCISSOR_RECTS, 4, vg->scissor);
|
2012-06-19 19:01:34 +00:00
|
|
|
}
|
|
|
|
|
2012-09-24 19:19:07 +00:00
|
|
|
static bool vg_frame(void *data, const void *frame, unsigned width, unsigned height, unsigned pitch, const char *msg)
|
2012-06-19 19:01:34 +00:00
|
|
|
{
|
2012-09-24 19:19:07 +00:00
|
|
|
vg_t *vg = (vg_t*)data;
|
|
|
|
vg->frame_count++;
|
2012-06-19 19:01:34 +00:00
|
|
|
|
2012-09-24 19:19:07 +00:00
|
|
|
if (width != vg->mRenderWidth || height != vg->mRenderHeight)
|
2012-06-19 19:01:34 +00:00
|
|
|
{
|
2012-09-24 19:19:07 +00:00
|
|
|
vg->mRenderWidth = width;
|
|
|
|
vg->mRenderHeight = height;
|
|
|
|
vg_calculate_quad(vg);
|
2012-09-24 23:30:24 +00:00
|
|
|
matrix_3x3_quad_to_quad(
|
2012-09-24 19:19:07 +00:00
|
|
|
vg->x1, vg->y1, vg->x2, vg->y1, vg->x2, vg->y2, vg->x1, vg->y2,
|
2012-06-19 19:01:34 +00:00
|
|
|
// needs to be flipped, Khronos loves their bottom-left origin
|
|
|
|
0, height, width, height, width, 0, 0, 0,
|
2012-09-24 23:30:24 +00:00
|
|
|
&vg->mTransformMatrix);
|
2012-06-19 19:01:34 +00:00
|
|
|
vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE);
|
2012-09-24 23:30:24 +00:00
|
|
|
vgLoadMatrix(vg->mTransformMatrix.data);
|
2012-06-19 19:01:34 +00:00
|
|
|
}
|
|
|
|
vgSeti(VG_SCISSORING, VG_FALSE);
|
2012-09-24 19:19:07 +00:00
|
|
|
vgClear(0, 0, vg->mScreenWidth, vg->mScreenHeight);
|
2012-06-19 19:01:34 +00:00
|
|
|
vgSeti(VG_SCISSORING, VG_TRUE);
|
|
|
|
|
2012-09-24 19:19:07 +00:00
|
|
|
vgImageSubData(vg->mImage, frame, pitch, vg->mTexType, 0, 0, width, height);
|
|
|
|
vgDrawImage(vg->mImage);
|
2012-06-19 19:01:34 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_FREETYPE
|
2012-09-24 19:19:07 +00:00
|
|
|
if (msg && vg->mFontsOn)
|
|
|
|
vg_draw_message(vg, msg);
|
2012-06-19 19:01:34 +00:00
|
|
|
#else
|
|
|
|
(void)msg;
|
|
|
|
#endif
|
|
|
|
|
2012-09-25 00:47:48 +00:00
|
|
|
vg->driver->swap_buffers();
|
2012-06-19 19:01:34 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-09-24 19:19:07 +00:00
|
|
|
static bool vg_alive(void *data)
|
2012-06-19 19:01:34 +00:00
|
|
|
{
|
2012-09-24 19:19:07 +00:00
|
|
|
vg_t *vg = (vg_t*)data;
|
2012-09-18 23:41:58 +00:00
|
|
|
bool quit, resize;
|
|
|
|
|
2012-09-25 00:47:48 +00:00
|
|
|
vg->driver->check_window(&quit,
|
2012-09-24 19:19:07 +00:00
|
|
|
&resize, &vg->mScreenWidth, &vg->mScreenHeight,
|
|
|
|
vg->frame_count);
|
2012-09-18 23:41:58 +00:00
|
|
|
return !quit;
|
2012-06-19 19:01:34 +00:00
|
|
|
}
|
|
|
|
|
2012-09-24 19:19:07 +00:00
|
|
|
static bool vg_focus(void *data)
|
2012-06-19 19:01:34 +00:00
|
|
|
{
|
2012-09-25 00:47:48 +00:00
|
|
|
vg_t *vg = (vg_t*)data;
|
|
|
|
return vg->driver->has_focus();
|
2012-06-19 19:01:34 +00:00
|
|
|
}
|
|
|
|
|
2012-09-24 19:19:07 +00:00
|
|
|
const video_driver_t video_vg = {
|
|
|
|
vg_init,
|
|
|
|
vg_frame,
|
|
|
|
vg_set_nonblock_state,
|
|
|
|
vg_alive,
|
|
|
|
vg_focus,
|
2012-06-19 19:01:34 +00:00
|
|
|
NULL,
|
2012-09-24 19:19:07 +00:00
|
|
|
vg_free,
|
|
|
|
"vg"
|
2012-06-19 19:01:34 +00:00
|
|
|
};
|