使用两个纹理SDL2显示视频

时间:2018-05-27 04:25:13

标签: c++ sdl-2

我需要构建一个界面,其中屏幕左侧显示一个流视频的一部分,右侧显示另一部分。像这样https://www.youtube.com/watch?v=fSPXpdVzamo

视频流保存在正在加载到纹理上的内存缓冲区中。我的问题是如何渲染纹理的一半,我尝试使用SDL_Rect,但没有任何反应。

这是我的代码的相关部分:

public class Soroco {

  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    BigInteger n = new BigInteger(br.readLine());
    BigInteger s0 = new BigInteger(br.readLine());
    BigInteger s1 = new BigInteger(br.readLine());
    BigInteger num = s(n, s0, s1);
    System.out.println(num);
    System.out.println(countTrailingZeroes(num));
  }

  static BigInteger s(BigInteger n, BigInteger s0, BigInteger s1) {
    if (n.equals(new BigInteger("0")))
        return s0;
    else if (n.equals(new BigInteger("1")))
        return s1;
    else {
        BigInteger n1=n.subtract(new BigInteger("1"));
        BigInteger n2=n.subtract(new BigInteger("2"));
        BigInteger n3=s(n1, s0, s1).multiply(s(n2, s0, s1));
        return n3;
    }
  }

  static int countTrailingZeroes(BigInteger num) {
    String str = String.valueOf(num);
    int count = 0;
    for (int i = 0; i < str.length(); i++)
        if (str.charAt(i) == '0')
            count++;
    return count;
  }
}

如果我尝试这样的话,它就不起作用了:

SDL_UpdateTexture(texture, NULL, buffer_start, fmt.fmt.pix.width * 2);
SDL_RenderClear(renderer);
SDL_RenderCopy(renderer, texture, NULL, NULL);
SDL_RenderPresent(renderer);

任何建议都会很棒!

1 个答案:

答案 0 :(得分:1)

如果没有你发布MCVE很难知道你哪里出错了。我的猜测是你的x位置错了。这是一个示例,我将展示如何以视频的方式绘制2个图像。

绿色图片:https://i.imgur.com/yaOG8Ng.png

红色图片:https://i.imgur.com/faKKShU.png

def rotation(N):
    return [N[i:] + N[:i] for i in range(len(N))]
K = [1, 9, 7]
print(rotation(K))