glVertex3f
Crap Cracker
I know alot of you did your chip8 emulators with directX. My question is what is a good way to draw the "pixels" for a Chip8 emulator.
The way I tried was extremely slow and I figure that something this simple, I dont need to use the camera stuff.
Hers how I was doing it
Here is DrawSquare
where DxVertex is like so
I am very new to directX and cant seem to find the right answers anywhere.
The way I tried was extremely slow and I figure that something this simple, I dont need to use the camera stuff.
Hers how I was doing it
Code:
void C8video::RenderScreen ()
{
gD3D->Begin ();
gD3D->ClearColor ( 0xFF000000 );
for ( float x = 0; x < max_width; x++ ) {
for ( float y = 0; y < max_height; y++ ) {
if ( Display [ static_cast <int> ( x ) + ( static_cast <int> ( y ) *
static_cast <int> ( max_width ) ) ] != 0 ) {
gD3D->DrawSquare ( x, y, pixel_width, pixel_height, 0xFFFFFFFF );
}
else
gD3D->DrawSquare ( x, y, pixel_width, pixel_height, 0xFF000000 );
}
}
gD3D->End ();
}
Here is DrawSquare
Code:
void D3Dclass::DrawSquare ( float posx, float posy, float width, float height, DWORD color )
{
DxVertex temp_square [] = {
{ posx * width , posy * height , 1.0f, 1.0f, color },
{ ( posx * width ) + width, posy * height , 1.0f, 1.0f, color },
{ posx * width , ( posy * height ) + height, 1.0f, 1.0f, color },
{ ( posx * width ) + width, ( posy * height ) + height, 1.0f, 1.0f, color },
};
Render ( temp_square, 4 );
}
where DxVertex is like so
Code:
struct DxVertex
{
float x, y, z, w;
DWORD color;
};
I am very new to directX and cant seem to find the right answers anywhere.
Last edited: