コード例 #1
0
ファイル: SDL_render_d3d.c プロジェクト: zester/Mezzanine
static int
D3D_UpdateClipRect(SDL_Renderer * renderer)
{
    const SDL_Rect *rect = &renderer->clip_rect;
    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
    RECT r;
    HRESULT result;

    if (!SDL_RectEmpty(rect)) {
        IDirect3DDevice9_SetRenderState(data->device, D3DRS_SCISSORTESTENABLE, TRUE);
        r.left = rect->x;
        r.top = rect->y;
        r.right = rect->w + rect->w;
        r.bottom = rect->y + rect->h;

        result = IDirect3DDevice9_SetScissorRect(data->device, &r);
        if (result != D3D_OK) {
            D3D_SetError("SetScissor()", result);
            return -1;
        }
    } else {
        IDirect3DDevice9_SetRenderState(data->device, D3DRS_SCISSORTESTENABLE, FALSE);
    }
    return 0;
}
コード例 #2
0
ファイル: coords.c プロジェクト: odabugs/kof-combo-hitboxes
void setWindowDimensions(screen_dimensions_t *dimensions, int newXOffset, int newYOffset)
{
    int w = dimensions->width, h = dimensions->height;
    w = w - (newXOffset << 1);
    h = h - (newYOffset << 1);
    RECT scissorRect = { .right = (LONG)w, .bottom = (LONG)h };
    IDirect3DDevice9_SetScissorRect(d3dDevice, &scissorRect);
}
コード例 #3
0
ファイル: gld_driver_dx9.c プロジェクト: nikai3d/mesa
void gld_NEW_SCISSOR(
	struct gl_context *ctx)
{
	GLD_context			*gldCtx	= GLD_GET_CONTEXT(ctx);
	GLD_driver_dx9		*gld	= GLD_GET_DX9_DRIVER(gldCtx);

	// Bail if IHV driver cannot scissor
	if (!gld->bCanScissor)
		return;

	// Set scissor rect
	if (ctx->Scissor.Enabled) {
		RECT rcRect;
		// Keep in mind that RECT's need an extra row and column
		rcRect.left		= ctx->Scissor.X;
		rcRect.right	= ctx->Scissor.X + ctx->Scissor.Width; // + 1;
		rcRect.top 		= gldCtx->dwHeight - (ctx->Scissor.Y + ctx->Scissor.Height);
		rcRect.bottom 	= rcRect.top + ctx->Scissor.Height;
		IDirect3DDevice9_SetScissorRect(gld->pDev, &rcRect);
	}

	// Enable/disable scissor as required
	_GLD_DX9_DEV(SetRenderState(gld->pDev, D3DRS_SCISSORTESTENABLE, ctx->Scissor.Enabled));
}
コード例 #4
0
ファイル: coords.c プロジェクト: odabugs/kof-combo-hitboxes
void getGameScreenDimensions(HWND game, HWND overlay, screen_dimensions_t *dimensions)
{
    RECT clientRect;
    POINT clientTopLeft = { .x = 0, .y = 0 };
    GetClientRect(game, &clientRect);
    ClientToScreen(game, &clientTopLeft);
    int newLeftX = (int)clientTopLeft.x;
    int newTopY = (int)clientTopLeft.y;
    int newWidth = (int)clientRect.right;
    int newHeight = (int)clientRect.bottom;
    int newXOffset = 0, newYOffset = 0;

    // has the game window position and/or size changed since we last checked?
    bool changedPosition, changedSize, enlarged;
    changedPosition = (dimensions->leftX != newLeftX || dimensions->topY != newTopY);
    changedSize = (dimensions->width != newWidth || dimensions->height != newHeight);
    enlarged = (changedSize && (newWidth > dimensions->width || newHeight > dimensions->height));

    if (!changedPosition && !changedSize) {
        return;
    }
    dimensions->leftX = newLeftX;
    dimensions->topY = newTopY;

    dimensions->width = newWidth;
    dimensions->height = newHeight;
    double dblWidth = (double)newWidth;
    double dblHeight = (double)newHeight;
    dimensions->aspect = dblWidth / dblHeight;

    switch (dimensions->aspectMode)
    {
    case AM_FIXED:
    case AM_STRETCH:
        dimensions->xScale = dblWidth / dimensions->basicWidthAsDouble;
        dimensions->yScale = dblHeight / dimensions->basicHeightAsDouble;
        dimensions->leftOffset = 0;
        dimensions->topOffset = 0;
        break;
    case AM_PILLARBOX:
        newXOffset = setScreenOffsetsPillarboxed(dimensions, dblWidth, dblHeight);
        break;
    case AM_LETTERBOX:
        newYOffset = setScreenOffsetsLetterboxed(dimensions, dblWidth, dblHeight);
        break;
    case AM_WINDOW_FRAME:
        if (dimensions->aspect < dimensions->basicAspect)
        {
            newYOffset = setScreenOffsetsLetterboxed(dimensions, dblWidth, dblHeight);
        }
        else
        {
            newXOffset = setScreenOffsetsPillarboxed(dimensions, dblWidth, dblHeight);
        }
        break;
    default:
        printf("Encountered invalid aspect mode.");
        exit(EXIT_FAILURE);
    }

    if (!enlarged)
    {
        RECT fullscreenRect = { .right = (LONG)screenWidth, .bottom = (LONG)screenHeight };
        IDirect3DDevice9_SetScissorRect(d3dDevice, &fullscreenRect);
        IDirect3DDevice9_Clear(d3dDevice, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_RGBA(0, 0, 0, 0), 1.0f, 0);
    }
    setWindowDimensions(dimensions, newXOffset, newYOffset);
    MoveWindow(overlay,
               newLeftX + newXOffset, newTopY + newYOffset,
               (int)screenWidth, (int)screenHeight,
               true);
}