Graphics programming in C Language is discussed rarely. Today I will discuss some important functions of graphics.h in C programming Language and in the next coming article I will make a simple program to demonstrate the use of graphics functions. This is the part one of the article which discuses the important graphics function to create and destroy the graphics environment. In part two I will show you different graphics functions to draw shapes. And in last part I will add a sample program to demonstrate the use of graphics.h library. So let’s start with the description of important functions and their use.
Below are the important functions and their description mostly used in graphics applications in C Language.
Function initgraph()
This function is used to load the graphics drivers and initialize the graphics system. For every function, that uses graphics mode, graphics mode must be initialized before using that function.
1 | void initgraph(int far *driver, int far *mode, char far *path) |
Path determines that path to the specified graphics driver.
Function detectgraph()
Detectgraph function determines the graphics hardware in the system, if the function finds a graphics adapter then it returns the highest graphics mode that the adapter supports.
1 | void detectgraph(int far *driver, int far *mode) |
Function cleardevice()
This function clears the graphics screen contents and return the control to the location (0,0).
1 | void cleardevice(void) |
Function closegraph()
This function shutdown the graphics mode and returns to the position it was before the initgraph() function was called. The closegraph() function releases all the resources occupied by the graphics system like memry, fonts, drivers etc…
1 | void closegraph(void) |
Graphics Library (graphics.h) Reference (part 2) →
Here’s Must-Read List of C programming books for beginners
C Programming Language, 2nd Edition
With over 600 5-star reviews on Amazon, readers agree that C Programming Language, 2nd Edition by Brian Kernighan and Dennis Ritchie is the best C Programming book for Beginners. The authors present the complete guide to ANSI standard C language programming. Written by the developers of C, this new version helps readers keep up with the finalized ANSI standard for C while showing how to take advantage of C’s rich set of operators, economy of expression, improved control flow, and data structures.
21st Century C: C Tips from the New School
Throw out your old ideas about C and get to know a programming language that’s substantially outgrown its origins. With this revised edition of 21st Century C, you’ll discover up-to-date techniques missing from other C tutorials, whether you’re new to the language or just getting reacquainted.
C Programming Absolute Beginner’s Guide
Greg Perry is the author of over 75 computer books and known for bringing programming topics down to the beginner’s level. His book C Programming Absolute Beginner’s Guide, is today’s best beginner’s guide to writing C programs–and to learning skills to use with practically any language. Its simple, practical instructions will help you start creating useful, reliable C code, from games to mobile apps. Plus, it’s fully updated for the new C11 standard and today’s free, open source tools!
C Programming: A Modern Approach, 2nd Edition
KN King tackles on some C standard library specifics header by header in his C Programming: A Modern Approach book. The second edition maintains all the book’s popular features and brings it up to date with coverage of the C99 standard. The new edition also adds a significant number of exercises and longer programming projects, and includes extensive revisions and updates.
Programming Arduino: Getting Started with Sketches
Simon Monk, a Ph.D. in software engineering, writes this great little book for learning to program the arduino using C language. This bestselling guide explains how to write well-crafted sketches using Arduino’s modified C language. You will learn how to configure hardware and software, develop your own sketches, work with built-in and custom Arduino libraries, and explore the Internet of Things—all with no prior programming experience required!