Hi,
In general its not worth drawing a single pixel in D3D as immediate mode rendering just does not exist. To draw a simple point, you still need to create a vertex buffer and render a point list and is just too much work.
: So what you are saying is a point is just a line that begins and ends on the same point:)
:
: I get overwelmed by DX because I don't want to do 3D graphics. Perhaps DirectDraw is a nice subset to start with.
:
: I wrote a program that uses Chowning's FM algorithm to morph a sine wave into a square wave. I started the modulator at zero and increased the index in a for loop. Very primitive 2D animation. But it is interesting to see the effect of FM on a wave graphically.
:
: Showing a little pixel drawing code it the originally point of this thread, thank you.
:
: Could you also demonstrate how to draw a point with DirectDraw, please?
:
: Stephen
:
: PS. I am still thinking about how cool it would be to draw in a window with no menu, titlebar, or frame at the zero window z plane with exclusive keyboard focus until it is closed and no mouse focus instead of full screen for graphics. I am a little obsessed with controlling every aspect of my program, gradually recognizing that just drawing on the screen in windows would not cut it anyway.
:
:
: : You definitely have control how things get displayed in windows, you just don't have access to memory directly.
: :
: : Secondly other than having to setup a window its a 2 hour thing to get learn opengl and if you are fairly comfortable with C++,COM and 3D in general its probably 2-3 hours to get into directx as well.
: :
: : Thirdly algorithms used in these programs are tried and tested over the years so you save a lot of time testing these things again and again and they are efficient. Some of the guys who were/are part of the team which made these API's probably actually came up with the algorithms you are using for drawing lines etc.
: :
: : Yes you must rely on a driver you didn't write, same as you must rely on an OS you didn't write, and the various application you are using that you didn't write, the bgi interface that you didn't write etc, etc.
: :
: : Actually Opengl was never meant for games, it was meant for scientific applications and still probably is. You can still do abstract graphic displays using opengl. To put it simply - programs like Ansys, Autocad etc use Opengl.
: :
: : Lastly if you want to know how to write a pixel in Opengl. Here it is(removing the window setup and stuff - straight into the drawing) and assuming you have a 2d orthographic projection setup(use glut for windowing and you will save 1 hour wading through the window setup as well)
: :
: :
: : // write at location 0,0 (top left of the screen)
: : glBegin(GL_POINTS);
: : glVertex3f(0, 0);
: : glEnd();
: :
: : // to draw a line
: : glBegin(GL_LINE);
: : glVertex3f(0, 0);
: : glVertex3f(10, 0);
: : glEnd();
: :
: : etc.
: :
: :
: : This is simplet that doing it the dos way.
: :
: : What you want to do is ok for learning purposes but not at all ok if you are wanting to build an application. And by the way you need to download nothing to work with Opengl - gcc comes with the GL header files and so does MSVC 6.0 and above (not sure of the rest). They also come with directx files (not sure of the version though).
: :
: :
: : :
This message was edited by Baggins at 2005-9-17 23:52:46
: : : : one important thing: winxp does NOT allow you to set any svga mode nor will it allow you writing/reading to videomemory.however,most of your old code works fine since winxp EMULATES the dos-way so you it seems you have written your pixel directly into videomemory.it is also not possible to REALY switch svga-banks.
: : : :
: : : : there are 3 possible ways to do your setpixel-thing:
: : : :
: : : : 1.resume using dos-svga-programming and hope winxp will emulate evrything fine.a lot of those things only work in full-screen dos-boxes.
: : : :
: : : : 2.use the win-gdi,opengl or directx.those apis provide a interface to the graphics-hardware and you dont need to know too much about the internal hardware which improves portability between different systems
: : : :
: : : : 3.write a kernel-mode driver which deals with your hardware.when writing your code as a driver you are allowed to deal with the hardware directly,however this will affect the stability of the whole system.it is very difficult to write a piece of code which works fine with all the other threads and drivers running on a modern windows-system
: : : :
: : : Taking your statements in reverse order, I looked at the examples in the XP DDK and a kernel mode driver making an agp Memory Controller Hub driver might work. The Intel AGP845 and the INVIDIA graphics card use the same memory. I don't know if that makes them interchangeable as far as writing to video memory goes.
: : :
: : : As for the second point, if I don't write my own driver, then I must rely on a driver I did not write. The problem is those drivers work poorly when you want to use low level primitives like displaying a sound wave pixel by pixel. Also, I would like to play with graphics algorithms like comparing different ways to draw a line or different anti-aliasing methods. I would like to use some of the graphics programming wisdom that people worked hard to discover for Windows. Graphics libraries are geared for people who write games, not for more abstract graphical displays. Graphic libraries probably have the capabilies I am looking for, but it is hard wading through all the functionality I don't need and don't understand yet. Worst of all, graphic libraries are a moving target, they change, but the algorithms for drawing a line never will. I spent a lot of time learning Borland Graphics Interface (BGI), now I want a piece of code I understand thoroughly and can adapt myself.
: : :
: : : Finally, as far as DOS programming goes, you don't get a lot of control on how it gets displayed in Windows. Text mode can stay in a window, and Video modes jump to full screen, what if I want to display VGA graphic 640x480 in a window on my 1280x1024 screen or write an old style text-based video game like the Qbasic Nibbles?
: : :
: : : Basically there are so many choices and the learning curve for learning video libraries like DX or GL or some custom library someone wrote is too steep just to write a pixel to the screen.
: : :
: : : If someone would write a tutorial 'Video for Idiots' where they showed us how we can use DX to just draw lines and pixels in 16 color modes without having to download a 150 Megabyte SDK to do it, we would all forget about DOS and start learning the new way of doing things.
: : :
: : : Finally, as you can guess, DX makes too many assumptions in how it is set up and the choices it offers about what kinds of Video I want to display. I want to write a pixel as fast as possible, DX's strength is not in offering me flexible, general ways of writing video and leaving how the line is drawn to the memory block starting at 0xF4000000 up to me, but easy ways to do specific, advanced things. I did download a lot of fractal software that should help, but then I must wade through a lot of code to get to the drawing part.
: : :
: : : Anyway, the point is it is hard finding examples of just writing a pixel in today's example code for DX or GL or GDI or any other ready-made hardware driver or Video Library.
: : :
: : : Stephen
: : :
: : :
: : :
: : :
: : :
: :
: :
: