Header file:
graphics.h
Synopsis:
int getgraphmode (void);
Description:
getgraphmode() returns the current graphic mode number.
getgraphmode function in c graphics
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int main(void) {
/* request auto detection */
int gd = DETECT, gmode, err;
int midx, midy, mode;
char str[64];
/* initialize graphics and local variables */
initgraph(&gd, &gmode, "C:/TURBOC3/BGI");
/* read result of initialization */
err = graphresult();
/* an error occurred */
if (err != grOk) {
printf("Graphics error: %s\n", grapherrormsg(err));
getch();
return 0;
}
/* mid positions in x and y axis */
midx = getmaxx() / 2;
midy = getmaxy() / 2;
/* get mode number and name strings */
mode = getgraphmode();
sprintf(str, "Current graphic mode number: %d", mode);
/* display the information */
settextjustify(CENTER_TEXT, CENTER_TEXT);
outtextxy(midx, midy, str);
midy = midy + textheight("H") + 2;
sprintf(str, "Current graphic mode name:%s", getmodename(mode));
outtextxy(midx, midy, str);
/* clean up */
getch();
closegraph();
return 0;
}
Output: (getgraphmode built-in function in c graphics.h)
No comments:
Post a Comment