开发者

Switch Between Graphic And Text Mode in Turbo C

Guys i am writing a simple graphic program to create a polygon of n sides by taking input from the user.After obtaining co-ordinates of vertices i would ask user to enter the vertex pairs between which he wants an edge.

To make this more interactive i thought i would gradually start drawing the polygon in graphic mode simulatneously i.e i would gradually add the edges and would display it to the user .Now i would again switch to the text mode to obtain further set of vertices between which he wants to insert edges.But what i found that as i switch between graphics and text mode everything开发者_JAVA技巧 which i draw in graphics mode is erased .

Guys is there any way or any function in turbo C compiler so that i could switch between text and graphic mode and at the same time restoring the contents of graphic mode.Should i use different compiler??


Switching between modes makes the video adapter lose all retained graphics. A workaround for this is to use a 'canvas', an in-memory bitmap that stores the pixels. You'd make modifications to this bitmap and blit it to the video adapter to make it visible. Not supported by this ancient graphics library you use. Review the CreateCompatibleDC() winapi function in you plan to get ahead.

This is hardly a problem. Simply re-render the graphics when you switch back to graphics mode. You do have to store a 'model' of the polygon so you can render it. Just store the vertex points.


You could use restorecrtmode(),setmode() and getmode() functions available in TURBO c library.These functions are present in graphics.h header file.


You may stay in graphics mode to get user input, but you will need to create a input function that works in graphic mode, reading char by char (getch()), composing your input and updating the graphic screen with the characters typed. If your graphic card have more then one page, you can use "setactivepage" and "setvisualpage" to create separated pages for the data entry and graphic.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜