Graphic programming

This is a discussion on Graphic programming within the C++ Programming forums, part of the General Programming Boards category; Ive been trying the graphic programming tutorials on the site, but Im having problem with the assembly code stuff, my ...

  1. #1
    C++ n00bie :D
    Join Date
    Jul 2004
    Posts
    63

    Graphic programming

    Ive been trying the graphic programming tutorials on the site, but Im having problem with the assembly code stuff, my compiler just keeps saying its undeclared, and I know nothing about assembly so I dont know how I could fix it Is there a header I have to include?

  2. #2
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    If you are using Dev-C++ you're gonna have a hard time trying to use inline assembly. Here is a little example I found (I haven't tested it myself).
    Dev-C++ uses AT&T syntax, although there is a way to make it use intel: add -masm=intel to the compiler options (I think it sometimes causes linker errors though)

    When I tried to use assembly before, however, I had to use a weird syntax for declaring variables. I dug this up:
    Code:
    static USHORT* video_buffer __asm__("asm_buf") = (USHORT *)ddsd.lpSurface;
    
    // draw the gradient
    for (int index_y=0; index_y < SCREEN_HEIGHT; index_y++)
         {
         // build color word up
         static DWORD color __asm__("asmcolor") = _RGB16BIT565(0,(index_y >> 3),0);
         // replicate color in upper and lower 16 bits of 32-bit word 
         color = (color) | (color << 16);
    
         // now color has two pixel in it in 16.16 or RGB.RGB format, use a DWORD
         // or 32-bit copy to move the bytes into the next video line, we'll need
         // inline assembly though...
    
         // draw next line, use a little inline asm baby!
         __asm__
             (
             "cld;"
             "les edi, [asm_buf];"
             "mov eax, [asmcolor];"
             "mov ecx, 640;"
             "shr ecx, 1;"
             "rep stosd;"
             );
    
             
         // now advance video_buffer to next line
         video_buffer += (ddsd.lPitch >> 1);
         
         } // end for index_y
    With the intel syntax option, and I think that one compiled for me. Anyways if you aren't using Dev-C++ then I just wasted my time...darn...
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  3. #3
    C++ n00bie :D
    Join Date
    Jul 2004
    Posts
    63
    Ya, I use Dev-C++. And I dont understand the funny syntax for the AT&T one Whats a good free compiler that would compile the stuff I find in that tutorial?

  4. #4
    C++ n00bie :D
    Join Date
    Jul 2004
    Posts
    63
    Here Ill post what Im trying in one(decided to use dev, didnt feel like changing)

    Code:
    void SetMCGA() {
        __asm("mov %ax, 0x0013");
        __asm("geninterrupt, 0x10"); //error line
    }
    Note sure if the first line is right, but it accepts it. The second one was supposed to be the geninterrupt, but I dont know how to do it.

    Oh and, if you dotn mind, can anyone describe the basic assembler commands for this? Im guessing(guessing... lol) that mov is kinda like a 'set' command, but I dont know what any of it does. And if you do mind it, mind saying where I can find a tutorial?

  5. #5
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    The tutorial you are looking at is rather old. The techniques offered are unlikely to work with a modern Windows compiler as they are targeted at DOS.
    I offer these tutorials more as a relic of programming lore than a serious study in how to program graphics in todays environment; nonetheless, if you are searching for C++ DOS graphics, these tutorials may be helpful. They are written by Grant Smith, aka Denthor of Asphyxia.
    If you want to perform graphics in Windows you have several choices:
    • GDI
    • OpenGL
    • DirectX (as used in JaWiB's post)
    • SDL
    • Other third party libraries

    If you want to continue with the tutorial you will probably need a DOS compiler.

  6. #6
    Registered User
    Join Date
    Apr 2004
    Posts
    5
    I would advise nehe.gamedev.net if you intend to learn opengl. Thats the best site for beginners IMO.

    Regards,
    Psirus

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 01-05-2009, 07:56 AM
  2. Pen-based application using graphic tablet ( c++)
    By aznimah in forum C++ Programming
    Replies: 1
    Last Post: 01-03-2009, 07:20 AM
  3. Graphic problems with Dual Core processors
    By BrownB in forum Tech Board
    Replies: 3
    Last Post: 11-07-2006, 05:10 AM
  4. Someone take my graphic.
    By Cheeze-It in forum Game Programming
    Replies: 0
    Last Post: 03-15-2003, 05:43 AM
  5. graphic library creation
    By bob5845 in forum C++ Programming
    Replies: 1
    Last Post: 04-05-2002, 12:30 AM

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