You are here:

C++/screen resolution

Advertisement


Question
hello sir, i am very eager to know how can i set screen resolution for a c graphics program?

Answer
Hai Dear Sanish !

 You can do this job without any difficulties , you will be using initgraph() function to initialize the graphics system plz refer the prototype

#include <graphics.h>

void initgraph(int *graphdriver, int *graphmode, char *pathtodriver);

the first parameter *Graphdriver specifies the graphics driver
which may be any of the following
graphics_drivers constant       Numeric value
DETECT   0 (requests autodetect)
CGA   1
MCGA   2
EGA   3
EGA64   4
EGAMONO   5
IBM8514   6
HERCMONO 7
ATT400   8
VGA   9
PC3270   10  

and the second parameter GraphMode which specifies on which mode you should initialize out of the modes supported by the GraphicsDriver
following are the list of modes


Driver   graphics_mode      Value       x Rows   Palette      Pages
CGA   CGAC0   0   320 x 200   C0   1
  CGAC1    1    320 x 200    C1    1
  CGAC2    2    320 x 200    C2    1
  CGAC3    3    320 x 200    C3    1
  CGAHI    4    640 x 200    2 color    1

MCGA    MCGAC0    0    320 x 200    C0    1

  MCGAC1    1    320 x 200    C1    1
  MCGAC2    2    320 x 200    C2    1
  MCGAC3    3    320 x 200    C3    1
  MCGAMED    4    640 x 200    2 color    1
  MCGAHI    5    640 x 480    2 color    1

EGA    EGALO    0    640 x 200    16 color    4

  EGAHI    1    640 x 350    16 color    2


VGA    VGALO    0    640 x 200    16 color    2
  VGAMED    1    640 x 350    16 color    2
  VGAHI    2    640 x 480    16 color    1



using this parameters you can alter the screen resolution as per your wish

eg !

 suppose you wish to work with VGA driver and 640x200 mode you can initialize this just using the same function and the parameter options just like this


int GDriver = VGA;
int gMode = VGALO;

initgraph(&gDriver , &gMode , "");

this code will invoke you the expected screen resolution settings

in case of  issues revert me !
Thanks and Regards !
Prince M. Premnath  

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


Prince M. Premnath

Expertise

Years of research in C/C++ Will bring you all facts regarding , OOPS , SVGA , MOUSE , BIOS , IVT , Feel free to query me :-)

Experience

More than 5 years

Education/Credentials
MCA

©2016 About.com. All rights reserved.