终端仿真器在SDL中滚动 [英] Terminal Emulator scrolling in SDL

查看:113
本文介绍了终端仿真器在SDL中滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨大家:)

我一直在阅读有关libSDL(简单直接媒体层)的文章,它是一个可移植的库,用于创建游戏,模拟器等,即需要图形效果的应用程序而不是使用旧的传统控制台。

作为一个简单的练习,我一直在尝试模拟一个控制台(不是在很大程度上),我已经实现了基础知识(putchar,puts,printf),现在我正在尝试实现一个scroll()函数,它将滚动,即从第二行复制到最后一行到第一行和第二行。我是这样做的:

Hi guys :)
I've been reading about libSDL (Simple Direct Media Layer), which is a portable library designed for creating games, emulators etc. i.e. applications that require graphical effects rather than using the old legacy console.
As a simple exercise I've been trying to emulate a console (not to the very extent), I've implemented the basics (putchar, puts, printf) and now I'm trying to implement a scroll() function which'll scroll i.e. copy from the 2nd row to the last row to the 1st row and the second last row. Here's how I do it:

// End of screen?
if (screen_y >= GL_MAX_Y)
	{
		// Yes. Scroll
		// This basically involves copying a part of the screen on the screen itself
		SDL_Rect temp;
		temp.x = 0; // X co-ordinate 
		temp.y = FONT_HEIGHT; // Y-cord First Row (In scrolling, the 0th row is replaced by the 1st row)
		temp.h = GL_MAX_Y; // ...And copy till the last line
		temp.w = GL_MAX_X; // Width should be the screen
		// COPY!
		SDL_BlitSurface(screen, &temp, screen, NULL);
		// Set X to 0
		screen_x = 0;
		// Set Y to last row 
		screen_y = GL_MAX_Y - FONT_HEIGHT;
	}



滚动完美,但最后一行填充了第一行的垃圾。

有什么方法可以清除屏幕的最后一行吗?


This scrolls perfectly, but the last line is filled with junk from the first line.
Is there any way I can clear the last line of the screen?

推荐答案

这篇关于终端仿真器在SDL中滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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