static void *lock(void *data, void **p_pixels) {
struct context *c = (context *)data;
int pitch;
SDL_LockMutex(c->mutex);
SDL_LockTexture(c->texture, NULL, p_pixels, &pitch);
return NULL; // Picture identifier, not needed here.
}
static void unlock(void *data, void *id, void *const *p_pixels) {-----------
struct context *c = (context *)data;
uint16_t *pixels = (uint16_t *)*p_pixels;
// We can also render stuff.
int x, y;
for(y = 10; y < 40; y++) {
for(x = 10; x < 40; x++) {
if(x < 13 || y < 13 || x > 36 || y > 36) {
pixels[y * VIDEOWIDTH + x] = 0xffff;
} else {
// RV16 = 5+6+5 pixels per color, BGR.
pixels[y * VIDEOWIDTH + x] = 0x02ff;
}
}
}
SDL_UnlockTexture(c->texture);
SDL_UnlockMutex(c->mutex);
}
static void display(void *data, void *id) {Ho provato a tradurle in pascal, ma sbaglio sicuramente nella dichiarazione delle variabili.
struct context *c = (context *)data;
SDL_Rect rect;
rect.w = VIDEOWIDTH;
rect.h = VIDEOHEIGHT;
rect.x = (int)((1. + .5 * sin(0.03 * c->n)) * (WIDTH - VIDEOWIDTH) / 2);
rect.y = (int)((1. + .5 * cos(0.03 * c->n)) * (HEIGHT - VIDEOHEIGHT) / 2);
SDL_SetRenderDrawColor(c->renderer, 0, 80, 0, 255);
SDL_RenderClear(c->renderer);
SDL_RenderCopy(c->renderer, c->texture, NULL, &rect);
SDL_RenderPresent(c->renderer);
}
static void *lock(void *data, void **p_pixels) {Mi aiutate con questa struttura a tradurla in Pascal. :-[
struct context *c = (context *)data;
static void *lock(void *data, void **p_pixels) {
struct context *c = (context *)data;
... ecc
libvlc_video_set_callbacks(mp, lock, unlock, display, &context);
libvlc_video_set_format(mp, "RV16", VIDEOWIDTH, VIDEOHEIGHT, VIDEOWIDTH*2);
type
lock_cb = function(
var data : Pointer;
var p_pixels : Pointer
); cdecl;
libvlc_video_set_callbacks(mp, &lock : lock_cb, .......);