Skip to main content
gamedev.net
🔒 Locked

BeginScene()

Started by marvelfan Aug 21, 2006 at 6:38 PM 12 replies 2.1k views
Original Post
marvelfan
marvelfan
I am making sprite and DX class handlers so that I can start 2d game programming. My test application runs but for some reason BeginScene() is not working it is returning false i am checking it like: if(d3dDev->BeginScene()) { begin rendering } else { MessageBox(NULL,"Unable to begin scene","error",MB_OK); return(0); } why would it be returning false? [Edited by - marvelfan on August 21, 2006 7:16:30 PM]
marvelfan
marvelfan
Is there something I have to call before BeginScene() in order for it work?
marvelfan
marvelfan
I changed it to this

if(SUCCEEDED(d3dDev->BeginScene()))

but for some reason it is rendering a black window
marvelfan
marvelfan
Why would it be rendering black? I am not clearing it to that color.
mdias
mdias
If you're calling Present() then perhaps black is what's on your backbuffer... why don't you clear it before BeginScene() so it has the color you want?

If you're NOT calling Prsente() then I suppose you are using a black brush on your window class creation, so it automatically paints the window in black whenever the window needs to be painted.
marvelfan
marvelfan
Quote:
Original post by Kamikaze15
If you're calling Present() then perhaps black is what's on your backbuffer... why don't you clear it before BeginScene() so it has the color you want?

If you're NOT calling Prsente() then I suppose you are using a black brush on your window class creation, so it automatically paints the window in black whenever the window needs to be painted.



yes I am calling present.

here is what the game loop looks like:
Quote:
			//make sure the Direct3D device is valid			if (d3dDev == NULL)				return 0;			// Clear the backbuffer to a red color			d3dDev->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,225), 1.0f, 0 );			// begin scene			if(SUCCEEDED(d3dDev->BeginScene()))			{				// begin rendering the next scene				dxMgr->beginRender("", 1);				// update the scene				// update each sprite				for (int i=0; i < MAX_SPRITES; i++)				{					x = sprites.getX();					y = sprites.getY();					vx = sprites.getvelocityX();					vy = sprites.getvelocityY();										if(x > 620){sprites.setvelocityX((vx *= -1));}					if(y > 460){sprites.setvelocityY((vy *= -1));}					if(x < 0){sprites.setvelocityX((vx *= -1));}					if(y < 0){sprites.setvelocityY((vy *= -1));}										// collision detection					for (int j=0; j < MAX_SPRITES; j++)					{						if(j != i)						{							if(sprites.collision(sprites[j])){								sprites.setvelocityX((vx *= -1));								sprites.setvelocityY((vy *= -1));								sprites[j].setvelocityX((vx *= -1));								sprites[j].setvelocityY((vy *= -1));}						}					}									// update each sprites position					sprites.update();										// render the sprite					dxMgr->renderSprites(sprites);				}				//stop rendering				dxMgr->endRender();				// end scene				d3dDev->EndScene();
marvelfan
marvelfan
what is the code for making the scrolling code blocks?
marvelfan
marvelfan
Quote:
Original post by idloco
do you have the lightning on?


what is that?
Evil Steve
Evil Steve
I agree with the AP (To a certain extent...). You should really take a look at some of the SDK tutorials and samples. If you don't know what ligthing is, then things will jsut go downhill from here.

As an aside, the reason BeginScrene() returned false, is that it's supposed to return D3D_OK (And it can return other things) on success, which has the value of 0, which evaluates to false. That's why you should use the SUCCEEDED() and FAILED() macros.

Topic Locked

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

Sign in to reply to this topic.