New to Directx

Started by
5 comments, last by jayash 18 years, 7 months ago
Hi All I have expertise in VB but new to directx. i have downloaded lucky's tutorial. and drawn an image using directx. My question is if i want to display another surface shall i use another form of VB or on the same form i can display multiple surfaces?? Thanks in Advance Jayash
Advertisement
Hi there Jayash,
How are you doing buddy?

The Problem
Drawing another "surface" (triangle) with the same VB

The Solution
I hope I got the question right... by surface I am assuming you are refering to the "window" you are rendering/drawing onto.

Well let me cover all the aspects that I think you should know..

1) If you are refering to another surface as being another window. You will have to create antother device. When you create the device you give it a handle to the window/surface you are rendering too.

2) If you are refering to the surface as being in the same window. You can use the same vertex buffer to draw the same triangle. If you want to draw other objects from the vertex buffer you will have to make appropriate space in the vertex buffer for additional information if you want to draw let's say a Rectangle and Triangle.

3) If you just want to redraw the current triangle you may do so by just recalling the DrawPrimitive method.. You might want to set the location of the primitive otherwise you will draw the current primitive over the other and not see it.


I really hope this helps buddy. Sorry if it's a little messy. if you have any other questions, i'd be glad to answer them.
Hi Armadon,

Let me clearify the problem in detail.

Actually i have simply display a .bmp file under Form_Load event. When this file got display after a short while i wish to display another bitmap file.

For displaying first bmp i have declared a primary surface and back buffer. and no doubt i am displaying this bitmap on my Form (Call ths First Form).

Now for displaying another bitmap i wish to use another form of Visual Basic or i have to draw second bitmap on the same form(First form) using existing Primary Surface and Backbuffer.

(I am experimenting with DirectX8 right now and Visual Basic 6.0)

Jayash
I believe when you say "form" your talking about meshes, if so, the answer is yes. And what you're trying to do is called multitexturing.

I haven't got a clue on how you'd do it on VB.

If it is anything like c++ you'd have to change your FVF for your vertices to have more than one texture coordintes.

I'm sorry I can't help you more on this.
When he says form he means a Window (either in fullscreen or windowed). That is what they call it in VB.

If you want to use a new form, then I think you need to have a new rendering device too. Because if I am not wrong, you specify what window or controll to draw to during the initialization of DX.

I have never tried to have two devices at the same time, not sure if it is possible, but I guess some of the old gurus here can tell you that.


- BS -
You don't need a new form. In DirectX, windows or forms are basically just convenient ways of getting Direct3D rendering to play nice with other programs - instead of saying "It's in this rectangle on top of these programs, but underneath these programs," you just say, "Render as if you're this window." Once you've created your Direct3D device and associated it with the form, you pretty much never need to touch the form again until you're shutting down or unless you want to handle messages.

Just to be clear, are you displaying your first image using a Visual Basic picture control, or using a Direct3D texture mapped onto a rectangular mesh? If the former, you should just be able to hide the picture control and display another one (or even set the property on the control to change the image directly), but that's basically ignoring Direct3D. If the latter, then you will re-use the existing primary surface and backbuffer (collectively called the 'swap chain') and just load the second image into memory, and when drawing you'll reference the second image instead of the first one.

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

Thanks Bugslayer & Superpig.

Perhaps this will help me.

Jayash

This topic is closed to new replies.

Advertisement