Skip to main content
GameDev.net gamedev.net
🔒 Locked

DirectX Space....

Started by sathenzar Jan 19, 2005 at 4:59 PM 10 replies 2.2k views
Original Post
sathenzar
sathenzar
Hey, I'm programming in C++/DirectX on a Win32 project and I was wondering how I could make it look like space in the background. I just don't know how to slow the stars down enough to make it look like space. For now I just use a for loop of 250 and use the SetPixel command to plot pixels that are white. When I ran the test, they flash so quickly on screen (I put them in the render function of DirectX I made) you can't tekk what they are and it looks like crap. Does anyoner have any idea on a better way?

void render(void)
{
	if(pd3dDevice == NULL)
		return;

	pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0), 1.0f, NULL);

	for(int i=0; i<250; i++)
	{
		SetPixel(hdc, rand()%640,rand()%480,RGB(255,255,255));
	}

	pd3dDevice->Present(NULL, NULL, NULL, NULL);
}
jacksaccountongamedev
jacksaccountongamedev
A sky box is a large box (or sphere) that is always centred on the player’s position (it moves with the player). If you texture the interior surfaces with a space texture you can create quite a convincing illusion of outer space. You may want to assign different textures to each surface for greater variation.

Jackson Allan
bit64
bit64
I found this tool to be very helpful in my space shooter. There is a stand-alone executable and a plugin for photoshop. The program is shareware, but you can purchase it for only 25 dollars.
Check it out.
Don't be afraid to be yourself. Nobody else ever will be.
Khaosifix
Khaosifix
There are several galaxy renderining algorithms that you might ought to use, thought I might warn you, some of those algorithms may be too complicated to initially grasp. I too suggest the usage of a skybox or a large textured quad[and then translation the texture matrix to create a scrolling effect].
---http://www.michaelbolton.comI constantly dream about Michael Bolton.
MasterWorks
MasterWorks
Yup a skybox does wonders for a space game. Rotate it (or the camera) around somehow for maximum effect. Consider using billboards, etc. for suns/planets/other non-star objects. Finding a good resolution for the stars texture can be tricky and depends primarily on the camera FOV. Remember to disable ZBuffer/AlphaBlend before drawing the skybox and you don't need a d3ddevice.clear anymore.
bit64
bit64
Not that exciting I know, but this uses a skybox that was textured with textures from the app I mentioned above and a billboarded 'sun' .

dpspace4.png
dpspace1.png
dpspace3.png
dpspace2.png

Edited by Coder: You inlined 4 images, ~180Kb each. That'd kill a guy with a dialup [grin]. A link would do

[Edited by - Coder on January 21, 2005 5:07:15 AM]
Don't be afraid to be yourself. Nobody else ever will be.
turnpast
turnpast
Quote:
Original post by MasterWorks
Remember to disable ZBuffer/AlphaBlend before drawing the skybox and you don't need a d3ddevice.clear anymore.


If you use the z buffer for other objects in the scene you will still have to clear it with the D3DCLEAR_ZBUFFER flag.
sathenzar
sathenzar
well I'm using a 2D view though. So mainly you're looking at the top of the action. So all I need is a white dot placed randomly around the screen that slowly scroll vertically
bit64
bit64
You would get much better performance by drawing a quad the size of the screen and texturing it with little white dots. Then just transform the texture vertically.
Don't be afraid to be yourself. Nobody else ever will be.
paulecoyote
paulecoyote
I think Frontier used a miniture particle system just outside the ship to show movement through space. There are tons of examples of those kinds of particle systems around.

[google] provides:
http://www.cs.ucf.edu/~hastings/index.php?id=opengl
http://www.yov408.com/html/projects.php?page=3

I'm sure if you looked you could find different more DX friendly examples, including some in the SDK that could be adapted to your needs.
Anything posted is personal opinion which does not in anyway reflect or represent my employer. Any code and opinion is expressed “as is” and used at your own risk – it does not constitute a legal relationship of any kind.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.