Fundamental Graphics.

Hello.

I'm aware this question likely comes up frequently, but I don't want the answer "Use DirectX". - That's not really what I'm looking for.

A friend of mine learned C++ using Borland's ancient Turbo C++ compiler - and it, of course, had a ton of specialised functions, like a gotoxy(x,y) for co-ordinate placement in the console window for text output, and things along those lines.

However, he learned graphics the hard way. Using things like the poly, pixel, line, & etc... functions, he made several small games, and learned about how graphics actually work.

I am interested in doing this before I get into D3D for graphics. I don't want the full package handed to me, I want to learn how it works by developing it myself in a rudimentary form - but I cannot seem to find anything, anywhere, that tells of a way to simply write a pixel of c colour to an x,y co-ordinate on the screen. (fullscreen console window ) If I could do that, just pixels, then I could create a Bresenham Run-Length Slice Line drawing Algorithm for line creation, I could create poly functions. I could make small animations - and I'd be able to really understand how these things work at higher levels, and appreciate it.

Is it at all possible I think it is worth it. Thank you for any help you can give - sorry to annoy.



Answer this question

Fundamental Graphics.

  • SureshP

    Of course it can be done, though nobody (well almost... http://www.radgametools.com/#Pixomatic) really does it that way any more since the 3d cards do all of the actual rendering.

    If you really want to learn about the low level stuff find yourself a used copy (or check your local library) of the abrash book http://www.amazon.com/gp/product/1576101746 or either of the LaMothe books  http://www.amazon.com/gp/product/0672323699  and http://www.amazon.com/gp/product/0672318350/ 

    What they teach is good theory and fascinating stuff, but not something that is used much today.

     

     



  • dold

    I .. really must not have got across what I'm trying to do.

    I in no way want to make this a thing about how brute force I can do graphics, or anything like that. I'm not trying to learn this stuff so I can do wicked awesome 3D.

    I was just hoping there was a way to do something other than text with C++ without the insane amount of learning I have to do just to initialise DirectX, that would still be useful.

    I'm really a beginner at this, and when the only tutorials I find are about older versions of DirectX, and the most basic beginner tutorial for how to get started is about 80 lines of code on initialisation, in high level C++ that I don't really understand yet, it's menacing.

    I know with the older specialised compilers, they'd have simple DOS graphics functions. I was just wondering if there was anything like that anymore, so that I could do something graphical and hone my skill a bit before I jump into D3D initialisation, brush configuration, surface creation and initialisation, and page flipping to .. make a box on the screen. But I guess there isn't, and I'll just have to deal with it.

    Thanks for your help anyway guys.


  • Joe the Owl

    See Ross's answer - GDI has a set pixel that you can use.

    Not sure if you are saying the C++ is hard for you ro read or the samples, if its C++ then consider managed directX. Same API - a little easier on the eyes and no pointer stuff to worry about.

    And you can start your learning using the SDK sample framework, it handles all the setup and initialisation of DirectX for you until you are comfortable doing that. All the samples in the SDK use it and there is an empty version of it called EmptyProject in the sample browser



  • SteveNash72

    If you really want to do things with an old-fashion style you can:

    a. Use the CRTL (but i think it’s a bad idea since you have to deal with a loooong documentation)

    b. Build a screen class so you can implement your own drawing functions, this is good if speed it's not a goal

    c. Use a pixel-base library like Allegro.



  • Toby Sharp

    I can understand where you're coming from, but I don't believe you'll learn much useful by creating your own 3D software renderer, compared to reading some articles on the subject. Projection, texturing, matrices and z-sorting aren't *that* complicated in their pure form, it's when hardware implementation and optimization enters the picture that things get really deep.

    But if you still want to do this, you can get good pixel pushing performance by locking a texture or GDI bitmap and directly manipulating the memory.


  • dbsize

     Viendin wrote:
    I don't want the full package handed to me, I want to learn how it works by developing it myself in a rudimentary form - but I cannot seem to find anything, anywhere, that tells of a way to simply write a pixel of c colour to an x,y co-ordinate on the screen.

    Writing a single pixel isn't graphics programming in its most rudimentary form.  Copying several pixels at once is the fundamental 2D graphics operation, while rasterising a triangle is the fundamental 3D operation.  If you just want to play around with writing single pixels then you can use GDI's SetPixel() function, but this isn't really isn't a good starting point to learn graphics programming. 


  • MShah

    You're not thinking about it properly.  Wanting to do pixel-pushing to learn 3d graphics is like saying you want to master bicycles before learning about cars, so that you will be a better driver.  They're only superficially related.
     
    On top of that, pushing things around at the pixel level (in the style you mention) actually goes against the colossal amount of hardware technology embedded in modern graphics cards.
     
    And please believe me when I tell you this: DirectX _is_ a graphics API in its most rudimentary form.  You get more helper-like functions in the D3DX libraries or the sample framework, but the main API is pretty straightforward.
     
    And if you REALLY insist on manly, chest-thumping graphics programming, look no further than writing your own shader code.  Just make sure you have your book on the fundamental theories of mathematics and light when you get started


  • Matthew Weyland

    So, it .. isn't possible, then

    I'm just looking for a means of writing pixels to my screen without using a preconstructed API. If that means I have to detect my video card, and utilize it specially, then I'll do just that.

    If it can't be done, I'll just get the DirectX SDK and feel a little sad that I'll never quite go down to the machine's level.


  • paolo_cc

    This is an old thread by now and you might not be reading this, but...

    I for one can absolutely understand what you want and why. I myself learned graphics first by using opengl and not really understanding why things were as they were and what the subtel difference was between this and that. I left it and through a few graphics courses at university I learned how to make nice and correct 3d graphics with a simple api whitch had only a setPixel function. Did transformations myself by implementing matrices. Did zbuffers and scanline converting of polygons. Lighting and varoius shading methods etc, and now I know what things are and only need to find out how directx or opengl does what I know i want done.

    That was a long nothing about myself.

    Using gdi setpixel is slow. Very very slow, but if you make all pixel writes and overwrites in 2D arrays and just present the result in the end, then it is fine.

    If that is too much api for you, then I suggest writing a "dos program" and talk directly with your card as a memory mapped pixelgrid. Look at code and tutorials for old graphics demos from before all this nice 3d api.

    I read nothing about your math level, but you need to understand vector and matrix mathmatics. Look those up on the net or books if you dont know it.

    After than you need to read into transformations and coordinatesystems and when you understand that you can do scanline conversion of polygons transformed into screenspace.

    It is however a vast subject all in all, so you need to be more specific actually.

    Where are you now and how detailed do you want to get


  • Fundamental Graphics.