I have a pretty simple task before me Having coded some games in the past (using DelphiX back then, nowadays I'm C# .Net programmer) I thought it was going to be easy. I'm utterly stunned by how impossible it seems to me right now, because nothing works... at all! I will break it down to an absolute basic level (the app itself is more complex, but this is the key part I cannot achieve):
I need to write a full screen application (C# .Net) that pereodically shows a string of text on screen. This string of text must be shown for exactly 1 frame (computers this would be used on will all have 60Hz LCD monitors, but we can also assume 2 frames for 120Hz monitors). No more, no less. One frame, or 16,(6) ms. So, at t=0, screen is white, at t=16,6ms, "TEXT" appears, at t=33,3ms, screen is white again.
This program must run on Windows XP, Windows Vista and Windows 7.
However, I've spent about week studying different technologies and it seems that this task is nigh unsolvable! That's why I'm asking for your help.
Here's what I tried:
1) Windows Forms.
I tried just making a full screen borderless form, and showing/hiding a label. On a 60Hz monitor (refresh each 16,(6)ms), even when showing a label for 20ms, I had times when it wouldn't show at all. I used precise timer (Stopwatch class), I'd show the label, then run a timer for 20ms, and hide it when it ticks. Label wouldn't even appear on the screen. Obviously, other times, it would show for 2 frames total, because it can appear just before first refresh, say, 1ms before it, then ~16ms passes (total 17ms still less than 20ms) and second refresh still displays it, and then it gets hidden at 20ms. So it was no good.
I assumed this is because I have no direct control when stuff is getting painted - in terms of getting my label to appear on the screen, there was just too much links in the chain - first I tell it to .Show(), then OS will draw it onto form, then DWI will draw form onto screen, and then monitor will get new frame from the screen.
This is where I thought that the way to solve this is to use double buffering + vsync, because that would guarantee exposure, because buffers will only be swapped after a frame went to the monitor. I decided to look at available options among direct graphics output.
I tried SDL.Net, and I had no success with it. From what I gathered, you cannot enforce Vsync, but if it is not disabled in your graphics card drivers, it should be automatically used if you create a hardware double-buffered surface with SDL. Turns out, NOPE. As described here http://gamedev.stackexchange.com/questions/65841/c-sdl-net-how-to-enable-vsync I made a double-buffered hardware surface and am still getting 90 fps, meaning vsync isn't working, even though it's enabled - I checked in my drivers (using official nVidia ones, my GPU is GeForce GTX 460). Noone seems to be able to help me on that matter. Therefore, had to give up on it.
I tried getting DirectX 9.0 SDK and it refused to install on my PC, saying I have to have an old OS (Windows 7 was not listed in the list of supported OS'es).
I installed SharpDX, I tried this tutorial http://katyscode.wordpress.com/2013/08/24/c-directx-api-face-off-slimdx-vs-sharpdx-which-should-you-choose/ but i crashes (I assume because it uses some 3D-2D operation only supported on Windows 8). I tried some other examples and they worked, but all of them are using DX11 or DX10 meaning my application won't run on XP! And I need that, because probably some of the users of my program will have computers that still have XP installed on them. Can't be sure, but for such a simple task, upgrade of a whole OS shouldn't be required - we're talking about outputting a string of text on the screen here! A simple string of simple text on a blank screen, dammit!
I tried to look around and everywhere I go examples are using DX11.
I tried to create OpenGL surface in SDL (supposedly you can set GL_swapcontrol and get vsync that way) but I just dont understand how do I output anything on that surface? There's no tutorials I found that explains it! I can swap buffers but that's all, I don't get how do I output any text there.
I tried SharpGL but there's not a single tutorial I found about a full screen application - it only uses windowed mode, and googling didn't provide anything useful. So once again, no idea what to do here.
I had past experience making small games in XNA so I know about the technology. I'd like to avoid XNA if possible because it requires installing a separate package on the user machine, and I'd like to avoid that if possible (I mean, for such a simple program, I'd like to keep it as simple as copying over an .exe and some .dll's). But I guess, if all else fails, and XNA works, I might have to go with it.
Well, this is it. I feel like a total moron, not being able to do the simpliest of tasks. I kept pesteting google, stack overflow and other sources for answers to no avail. I'd really appreciate if someone could just tell me how to do this very simple thing, or at least tell me where I am wrong and hint me how can I do it.
Thanks in advance!
Edited by Istrebitel, 15 November 2013 - 04:55 AM.