Setting Graphics Mode

This is a discussion on Setting Graphics Mode within the Game Programming forums, part of the General Programming Boards category; Hello. I'm new to the C++ programing game. But i'm slowly learning last week i whent over the basics now ...

  1. #1
    Unregistered
    Guest

    Question Setting Graphics Mode

    Hello. I'm new to the C++ programing game. But i'm slowly learning last week i whent over the basics now im moveing to visual. For some reason, anytime i try to compile a vga screen or a code that carrys lines the compiler wont reconize them no matter how I define them. I'm also looking for a demo script for changeing the screen to 320x200x256 so I can learn Pixels. If you have one feel free to post away. (Also anytime i try to switch to the screen the compiler wont let me)

  2. #2
    Registered User VBprogrammer's Avatar
    Join Date
    Mar 2002
    Posts
    175
    What compiler are u using - Microsoft VC++ and some others only work under windows and so dont allow changing the screen to 13h (I think thats right) mode.
    VC++ 6

  3. #3
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    In MSVC you must use DirectX for graphics.

    In others this will change the screen

    union REGS regs;
    regs.x.ax=0x13;
    int86(0x10,& regs,& regs);

    or

    mov ax,013h
    int 10h


    For pixels you must get a pointer to video memory.

    unsigned char *ptrScreen=(unsigned char *)MK_FP(0xa000,0);

    paletteindex is a palette entry from 0 to 255 which corresponds to certain RGB values.
    ptrScreen[y*320+x]=paletteindex;

    For more information go to www.brackeen.com.

  4. #4
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Originally posted by Bubba
    ptrScreen[y*320+x]=paletteindex;
    To speed things up, you can use bitshifting. (y<<8) + (y<<6) is the same as y*(2^8) + y*(2^6) which is y*256 + y*64 which is y*(256+64) which is Y*320.

    Doing this instead of the normal multiply 64000 times per frame (320*200=64000) will increase the update speed dramatically .
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  5. #5
    Registered User VBprogrammer's Avatar
    Join Date
    Mar 2002
    Posts
    175
    I wouldn't say you have to use directX, you can use the windows api for small games i.e. my snake game.
    VC++ 6

  6. #6
    Unregistered
    Guest

    Thumbs down Again I Note:

    Well thats all and well but with borland command line compiler it wont compile. it calls regs undefined along with .h.g ive looked it up and tryed that method.

  7. #7
    Unregistered
    Guest

    Question Methods

    Ive tried a few methods includeing:

    #define GRAPHICS_MODE13 0x13
    #define TEXT_MODE 0x03
    #include <iostream>
    #include <string>
    #include <conio>
    #include <stdlib>
    #include <stdio>
    using namespace std;
    void Set_Graphics_Mode(int mode)
    {
    union REGS inregs,outregs;

    inregs.h.ah = 0;
    inregs.h.al = (unsigned char)mode;

    _int86(0x10, &inregs, &outregs);
    }
    void main()
    {
    cout<<"Press any key to move to graphics mode..."endl;
    getch();
    Set_Graphics_Mode(GRAPHICS_MODE13);
    }

  8. #8
    Unregistered
    Guest

    Compiler

    And if you ask me borland compiler sucks because it will only do the most basic functions, if i try to compile anything found on this site it calls errors and wont compile. also i forgot the left shift in the ex above.

  9. #9
    Unregistered
    Guest

    later

    im going to work if you have any ideas on what may be going wroung email me at johnnyxeno@hotmail.com thats also my msn name.

  10. #10
    Fingerstyle Guitarist taylorguitarman's Avatar
    Join Date
    Aug 2001
    Posts
    564
    Look into SDL (www.libsdl.org). Other members might suggest Allegro. Both are APIs that take care of a great deal of the work for you so you can get started much quicker. If you're only going to do Windows programming then go with DirectX, but keep in mind it's more work to get started.
    If a tree falls in the forest, and no one is around to see it, do the other trees make fun of it?

  11. #11
    Registered User
    Join Date
    Aug 2001
    Posts
    380
    Is SDL compilable with the Borland command line compiler?

  12. #12
    Unregistered
    Guest
    You must include <dos.h> to get int86(), int86x(), and geninterrupt().

    Also the bit shifts should be in the final asm as most compilers should catch this and convert it to bit shifts. However, if you do no wish to rely on compiler optimizations then you can hard code the bit shifts in your code.

  13. #13
    Fingerstyle Guitarist taylorguitarman's Avatar
    Join Date
    Aug 2001
    Posts
    564
    Yes, it is. There is a little tweaking involved to make the libraries work but all the resources are available so it's not difficult. Basically you'd need to run Borland's implib to create the appropiate libraries from the MSVC ones. An example can be found at the SDL website on how to do it.
    If a tree falls in the forest, and no one is around to see it, do the other trees make fun of it?

  14. #14
    Registered User
    Join Date
    Mar 2002
    Posts
    31

    Lightbulb Try OpenGL then

    I will say try a third party choice such as the OpenGL api and that will help you out tremendously besides Direc 3D is hard
    - Read to Learn, and Learn to Read -

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. using gotoxy() in graphics mode
    By sureshkumarct in forum C Programming
    Replies: 1
    Last Post: 01-08-2007, 12:18 PM
  2. Handling mouse in graphics mode in Turbo C/DOS
    By sureshkumarct in forum C Programming
    Replies: 2
    Last Post: 12-24-2006, 08:36 AM
  3. Replies: 1
    Last Post: 07-28-2003, 12:56 PM
  4. text input in graphics mode
    By jamie in forum C++ Programming
    Replies: 1
    Last Post: 03-17-2003, 09:33 PM
  5. Input a string in graphics mode?
    By Vegettų in forum C++ Programming
    Replies: 3
    Last Post: 03-08-2002, 05:34 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21