Graphics.h刷新屏幕 [英] Graphics.h refresh screen

查看:332
本文介绍了Graphics.h刷新屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我制作了一个小程序,显示一个3D立方体,您可以使用箭头键在任何轴上缩放。唯一的问题是,即时通讯使用 cleardevice(); 来刷新多维数据集(以便缩放多维数据集时不会出现拖尾现象)。工作正常,只是每次使用此方法刷新多维数据集时,屏幕都会瞬间黑屏,导致令人讨厌的闪烁。每当用户更改立方体时,是否有更好的方式来刷新屏幕?
我确实研究过这个,但我无法找到任何合适的东西(也许我只是在研究不好,但我找不到任何对我来说)

解决方案

有两种处理方法:


  1. 双缓冲



    我不使用 BGI ,所以我坚持他们的文档。对于WinBGIm,您可以使用



    关于oldstyle BGI 使用这个:

      int oldv = getvisualpage(); 
    int olda = getactivepage();
    setvisualpage(olda);
    setactivepage(oldv);


  2. 使用与显示器的垂直同步
    $ b

    在调用 cleardevice(); 之前,您需要等待 VSync 。在 DOS 上,您可以使用 VGA BIOS 或直接 VGA / VESA 访问来获取信号。在较高的操作系统中,您需要使用某种gfx API 或驱动程序 API 以获取 VSync

    >

    在这两种情况下,请查阅目标平台的文档。

  3. I made a small program that displays a 3d cube that you can scale on any axis using the arrow keys. Only problem is that im using cleardevice(); for refreshing the cube ( so that there is no "smearing" when scaling the cube ). that works fine its just that every time the cube refreshes using this method the screen goes black for a split second resulting in annoying flickering. Is there a better way of refreshing the screen every time the user changes the cube? I did actually research this but i wasnt able to find anything suitable (Maybe im just bad at researching but i couldn't find anything for the live of me)

    解决方案

    there are 2 ways to handle this:

    1. Double buffering

      I do not use BGI so I stick to their docs. for WinBGIm you can use

      On oldstyle BGI use this:

      int oldv = getvisualpage( );
      int olda = getactivepage( );
      setvisualpage(olda);
      setactivepage(oldv);
      

    2. use vertical synchronization with monitor

      You need to wait for VSync before calling cleardevice();. On DOS you can use VGA BIOS or direct VGA/VESA access to obtain the signal. On higher OS you need to use some kind of gfx API or Driver API to get VSync.

      In both cases consult the documentation for target platform.

    这篇关于Graphics.h刷新屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆