Skip to main content
gamedev.net
🔒 Locked

Rendering problem

Started by TheNewbie May 22, 2002 at 9:43 PM 3 replies 200+ views
Original Post
TheNewbie
TheNewbie
Hi guys, Have a look a this situation I have at the moment.. its probably blindingly objvious but I think I dont have my head screwed on today :D Currently i''m rendering my scene in full screen. What I want to do is render and produce exactly the same as I did in full screen to a smaller section of the screen area. ie. its currently rendering the scene to full screen at 1024*768... what I am trying to do is keep the screen resolution the same (1024*768) but render the same scene in a smaller portion of the screen (ie the same thing reduced to 640*480 and placed in the top corner of the screen... leaving a black area around it). How exactly is this achieved ? TheNewbie
MatthewEva
MatthewEva
You may find the function:

IDirect3DDevice8::SetViewport(..

handy to achieve this, you need to pass a D3DVIEWPORT8 pointer into it, e.g you could use

D3DVIEWPORT8 view;

D3DVIEWPORT8 old; // Store Current Viewport
m_pDevice->GetViewport(&old);

view.x = 0;
view.y = 0;
view.Width = 640;
view.Height = 480;
view.MinZ = 0.0f;
view.MaxZ = 1.0f;

m_pDevice->SetViewport(&view);

.. Do the presenting of the scene

m_pDevice->SetViewport(&old); // Regig View to old position





ifndef _DIRECTX PostQuitMessage(0);#endif
TheNewbie
TheNewbie
Hmmm... sounds like a good idea.. i''ll give it a try 8]

I think what im trying to do is have the rendered scene in say the bottom left corner of the screen, and having a sort of ''HUD'' around it (as opposed to layered over the top).

If my brain was plugged in yesterday I would have mentioned this. DOH! :D

Could the same effect be produced using your method ? or is there a better way for this scenario?

ta!

-TN
MatthewEva
MatthewEva
Well, for 2D graphics on a 3D scene, I normally use the D3DXSprite object, using the ->Draw function as it will place images ontop of your 3d display. Another good benefit of using this way is that you can also use the blending of alpha channels to make the HUD opaque, which normall gives a good effect.

E.g.

LPDIRECT3DTEXTURE8 pTex; // Valid Texture With Image Information
LPD3DXSPRITE pSprite; // Sprite Interface

Use :

D3DXCreateSprite(m_pDirect3DDevice,&pSprite);

to create the sprite object ( dont forget to release it in the dsestructor ore when you have finished using it)

1. Clear & begin buffer

2. Setup Viewport for 3D Display as defined in my previous post, and draw the 3d Objects.

3. Draw the scene

4. Reset Viewpoint for full screen

5. Use pSprite->Draw to draw the texture onto the display using screen coordinates, i.e.

pSprite->Draw(&tex,NULL,NULL,NULL,0,&D3DXVECTOR2(150.0f,150.0f),D3DCOLOR_RGBA(100,100,100,100));

this will draw the texture onto the screen at screen coordinates 150.0f horizontal by 150.0f vertical with an opacity of 100, where 255 is solid and 0 is opaque for reference.

6. End & Present Buffer





ifndef _DIRECTX PostQuitMessage(0);#endif
TheNewbie
TheNewbie
excellent... I''ll give that a try this afternoon I think 8D

Thanks for your time 8-)

-TN

Topic Locked

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

Sign in to reply to this topic.