Commits

Anonymous committed a7fa136

Graphics library abstraction layer.

  • Participants

Comments (0)

Files changed (3)

+The GraphLib directory provides a common API for using
+graphics.  There will be several different versions of
+GraphLib for communicating with different graphics
+libraries.  The only one available right now is one
+that uses BGI.  This is for portabillity.  The GraphLib
+libary itself never draws graphics.
+#include <Graphics.H>
+#include <StdIO.H>
+#include <ConIO.H>
+#include <StdLib.H>
+#pragma hdrstop
+
+#include "GraphLib\BGI\GraphLib.H"
+/*-------------------------------------------------------------------------*/
+void GraphLib_StartIBM8514LO()
+{
+		int gdriver, gmode, errorcode;
+		gdriver = VGA;
+      gmode = IBM8514LO;
+
+		initgraph(&gdriver, &gmode, ""); /* use BGI to start it */
+		errorcode = graphresult(); /* Get possible error code */
+
+		if (errorcode != grOk) /* Not OK? */
+		{
+			fprintf(stderr, "Graphics error: %s\n", grapherrormsg(errorcode));
+			fprintf(stderr, "Press any key to terminate!\n");
+			while (!kbhit()) {}
+			getch();
+			exit(1);
+		}
+}
+/*-------------------------------------------------------------------------*/
+void GraphLib_End() /* end graphics mode */
+{
+	closegraph(); /* just a function call in BGI */
+}
+/*-------------------------------------------------------------------------*/
+#ifndef __INC_GRAPHLIB_BGI
+#define __INC_GRAPHLIB_BGI
+/*-------------------------------------------------------------------------*/
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* functions for graphics library user */
+/* startup of graphics mode */
+void GraphLib_StartIBM8514LO(void); /* Start graphics in 640x480 */
+/* end graphics mode */
+void GraphLib_End(void); /* end graphics mode */
+
+#ifdef __cplusplus
+}
+#endif
+/*-------------------------------------------------------------------------*/
+#endif /*__INC_GRAPHLIB_BGI*/