예제 #1
0
void aviVideoCallback(void* dummy, UInt32 time) 
{
    static char displayData[4 * 640 * (480 + 1)];

    FrameBuffer* frameBuffer;
    int bitDepth = 32;
    int bytesPerPixel = bitDepth / 8;
    char* dpyData = displayData;
    int width  = 320 * zoom;
    int height = 240 * zoom;
    int borderWidth;
    int displayPitch = width * bitDepth / 8;

    frameBuffer = frameBufferFlipViewFrame(1);
    if (frameBuffer == NULL) {
        frameBuffer = frameBufferGetWhiteNoiseFrame();
    }

    borderWidth = (320 - frameBuffer->maxWidth) * zoom / 2;

    if (properties->video.horizontalStretch) {
        if (borderWidth > 0) {
            // Render image one line higher, resizing will move it back to correct location
            videoRender(video, frameBuffer, bitDepth, zoom, 
                        dpyData + (height - 1 + 1) * displayPitch, 0, -1 * displayPitch, -1);
            stretchImage(dpyData, width, dpyData + displayPitch, width - 2 * borderWidth, displayPitch, height, bitDepth);
            borderWidth = 0;
        }
        else {
            videoRender(video, frameBuffer, bitDepth, zoom, 
                        dpyData + (height - 1) * displayPitch, 0, -1 * displayPitch, -1);
        }
    }
    else {
        videoRender(video, frameBuffer, bitDepth, zoom, 
                    dpyData + (height - 1) * displayPitch + borderWidth * bytesPerPixel, 0, -1 * displayPitch, -1);

        if (borderWidth > 0) {
            int h = height;
            while (h--) {
                memset(dpyData, 0, borderWidth * bytesPerPixel);
                memset(dpyData + (width - borderWidth) * bytesPerPixel, 0, borderWidth * bytesPerPixel);
                dpyData += displayPitch;
            }
        }
    }

    aviAddFrame(displayData, width * height * 4);
}
예제 #2
0
void piUpdateEmuDisplay()
{
	if (!shader.program) {
		fprintf(stderr, "Shader not initialized\n");
		return;
	}

	glClear(GL_COLOR_BUFFER_BIT);
	glViewport(0, 0, screenWidth, screenHeight);

	ShaderInfo *sh = &shader;

	glDisable(GL_BLEND);
	glUseProgram(sh->program);
	glUniformMatrix4fv(sh->u_vp_matrix, 1, GL_FALSE, &projection[0][0]);

	glActiveTexture(GL_TEXTURE0);
	glBindTexture(GL_TEXTURE_2D, textures[0]);

	FrameBuffer* frameBuffer;
	frameBuffer = frameBufferFlipViewFrame(properties->emulation.syncMethod == P_EMU_SYNCTOVBLANKASYNC);
	if (frameBuffer == NULL) {
		frameBuffer = frameBufferGetWhiteNoiseFrame();
	}
	int borderWidth = ((320 - frameBuffer->maxWidth) * ZOOM) >> 1;

	videoRender(video, frameBuffer, BIT_DEPTH, 1,
				msxScreen + borderWidth * BYTES_PER_PIXEL, 0, msxScreenPitch, -1);

	// if (borderWidth > 0) {
	// 	int h = height;
	// 	while (h--) {
	// 		memset(dpyData, 0, borderWidth * BYTES_PER_PIXEL);
	// 		memset(dpyData + (width - borderWidth) * BYTES_PER_PIXEL, 0, borderWidth * BYTES_PER_PIXEL);
	// 		dpyData += msxScreenPitch;
	// 	}
	// }

	glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, WIDTH, HEIGHT,
					GL_RGB, GL_UNSIGNED_SHORT_5_6_5, msxScreen);

	drawQuad(sh);

	glBindBuffer(GL_ARRAY_BUFFER, 0);
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

	eglSwapBuffers(display, surface);
}