simple output setup for software rendering
category: code [glöplog]
I've got a small-ish problem. I'd like to do some software rendering but don't know how to output my images properly. Making a texture and rendering with OpenGL felt stupid and wasn't that fast, SDL didn't do the trick either and is way too big.
So I'd like just to have a buffer that gets directly drawn to the screen. How should I go about it?
So I'd like just to have a buffer that gets directly drawn to the screen. How should I go about it?
http://code.google.com/p/pixeltoaster/
all you need.
all you need.
What OS(es)?
Windows. Wouldn't hurt to have more platforms, but I think this kind of stuff is quite OS dependant.
Thanks Gargaj, I'll look into that o/
Why didn't SDL do the trick? What is "way too big"?
I always use this:
Code:
#define XRES 800
#define YRES 600
#include <windows.h>
static BITMAPINFO bmi = { { sizeof(BITMAPINFOHEADER), XRES, -YRES, 1, 32, BI_RGB,
0, 0, 0, 0, 0 }, { 0, 0, 0, 0 } };
static DEVMODE screenSettings = { {0}, 0,0,156,0,0x001c0000, {0}, 0,0,0,0,0, {0},
0,32,XRES,YRES, {0}, 0, 0,0,0,0,0,0, 0,0 };
static long buffer[XRES*YRES];
void intro_init( int xres, int yres );
void intro_render( long *buffer );
// viod main( void )
void entrypoint( void )
{
// set fullscreen
if( ChangeDisplaySettings(&screenSettings,CDS_FULLSCREEN) ) return;
ShowCursor( 0 );
// create window
HDC hDC = GetDC( CreateWindowEx( WS_EX_TOPMOST, "static", 0,
WS_VISIBLE|WS_POPUP|WS_CLIPSIBLINGS|WS_CLIPCHILDREN, 0, 0,
XRES, YRES, 0, 0, 0, 0 ) );
// initialize demo
intro_init( XRES, YRES );
do
{
// render a frame
intro_render( buffer );
// copy to the screen
StretchDIBits(hDC,0,0,XRES,YRES,0,0,XRES,YRES,buffer,&bmi,DIB_RGB_COLORS,SRCCOPY);
// loop until ESC
}while( !GetAsyncKeyState(VK_ESCAPE));
}
before pixeltoaster that is several c++ classes and is made to support floating point framebuffers, gaffer wrote tinyPTC.
It's may be more old, but you might like it.
C, minimal api(init, close, blit. thats all).
Uses directdraw Some mmx conversion routines (need to setup nasm into visual studio if you need recompile).
Was intensively used by demos and intros quite a few years ago.
quote :
It's may be more old, but you might like it.
C, minimal api(init, close, blit. thats all).
Uses directdraw Some mmx conversion routines (need to setup nasm into visual studio if you need recompile).
Was intensively used by demos and intros quite a few years ago.
quote :
Quote:
You say it has a C++ API, are there C bindings as well? My architecture does not have a working C++ standard library, nor do I feel like porting one.
Gaffer
sorry, no c bindings at this time — it is a library written in c++
if you prefer c, then use TinyPTC instead. you can get it from sourceforge.
Entropia
Can PixelToaser be used to create tiny programs like TinyPTC? I really wouldn’t want to be using a 20k-DLL for a 64k intro…
Gaffer
nope. keep using TinyPTC for 64k intros – PixelToaster is not meant for that
what iq said.
although you can make it look a bit nicer at the price of a few bytes, probably ;p
although you can make it look a bit nicer at the price of a few bytes, probably ;p
iq, seems very nice ; I like minimal stuff.
What, no message pump! :)
Also, I always wondered if gdi was slower than ddraw or dx8/9+blit to surface...
I always heard gdi was veeery slow to blit but maybe it depends on the version of windows and maybe new windows librairies are either mmx or sse or even somehow hardware accelerated, i dont know...some gdi blits seemed fast, that puzzled me.
In my experience when you blit into vram, windows memcpy is not optimal, i've read articles about how there are huge improvement (maybe 10 times, dont remember) by using simd, align, prefetch, etc.
But then again maybe newer windowses have all that modernized.
Btw again, i wonder if there can be a difference between the memcpy in static libs in visual studio(user32.lib maybe, dunno) and dynamic libs...
One can imagine that when you install windows, since it knows on which processor it runs, it chooses to use some dll with sse if available, etc, depending on the things available on the architecture, but then you wouldnt be able to boot with another processor (unless theres some boot check)...So does it mean everything in older windows is not optimal code...Oh well.
If anyone wants to share some thoughts/info :)
What, no message pump! :)
Also, I always wondered if gdi was slower than ddraw or dx8/9+blit to surface...
I always heard gdi was veeery slow to blit but maybe it depends on the version of windows and maybe new windows librairies are either mmx or sse or even somehow hardware accelerated, i dont know...some gdi blits seemed fast, that puzzled me.
In my experience when you blit into vram, windows memcpy is not optimal, i've read articles about how there are huge improvement (maybe 10 times, dont remember) by using simd, align, prefetch, etc.
But then again maybe newer windowses have all that modernized.
Btw again, i wonder if there can be a difference between the memcpy in static libs in visual studio(user32.lib maybe, dunno) and dynamic libs...
One can imagine that when you install windows, since it knows on which processor it runs, it chooses to use some dll with sse if available, etc, depending on the things available on the architecture, but then you wouldnt be able to boot with another processor (unless theres some boot check)...So does it mean everything in older windows is not optimal code...Oh well.
If anyone wants to share some thoughts/info :)
oh, yes, its not my topic.
Yeah, that minimal stuff is awesome. Specially when you end up with a black window that doesn't move out of the screen, and you have to reboot or suspend to get rid of it.
Oh iq, will you ever stop being so awesome :)
What iq said..
xernobyl : wat? :)
it locks?
it locks?
Try to compile that and run it and see what happens.
Aaah! I know why.
iq wrote "viod" instead of "void" on line 13!
boooh!
Praise my debugging skills.
iq wrote "viod" instead of "void" on line 13!
boooh!
Praise my debugging skills.
No, I was talking about having bugs on that kind of "simplified" code.
ExitProcess(0); in the end has always solved it for me.