Jump to content
  • Advertisement
Sign in to follow this  
Sandra-24

I'm back, and I need your help

This topic is 4826 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

You folks mentioned last time that I want to draw a large 2d backround image by splitting it into 512x512 textures and drawing them to rectangles made of two triangles (35 rects) and clipping rects that aren't in view. To scroll I can simply move the camera. I need your help to do it though, because I find this directx stuff more than a little baffling. Below are some questions I have, if you know the answer to one, please help me out. I'm using Managed DirectX with C#, but I'm experienced with VB and C++ so you can use any language your comfortable with if you want to give a few lines of code. 1) I need to draw textured triangles, so I should use TriangleStrip(s) with what type of vertices? 2) I'm creating a panel control (ie windowed mode) that does it's drawing through directx, can I sync the drawing operation to the vertical sync of the monitor? How? 3) Do I derive from Windows.Forms.Panel? do I do the render operation in the OnPaint method? Not entirely sure how to create a panel that does it's drawing through directx. 4) Last time I tried this camera stuff it didn't work so well. What type of camera do I use? I would really appreciate if you could help me with the couple lines of code required to set it up. 5) What happens to the triangles near the edge of the panel? Can one draw triangles that are partly (or mostly) outside the bounds of the control? That's it, thanks a lot guys, I couldn't do this without you. -Sandra I posted a few days ago about how when I scroll a panel which has a large background image, there is flickering and distortion, so I wanted to code the panel in directx. Someone on this forum suggested that shouldn't be happening and I should make sure I'm doing things properly. Well I removed the flickering by using double buffering, but I could not remove the distortion because it was due to blting during the monitor's redraw. There is no way to vertical sync the painting without either a custom kernel driver or directx, so I'm back again, going the directx route.

Share this post


Link to post
Share on other sites
Advertisement
Hi there Sandra-24,
How are you doing?

The Problem
Basically coding a game ;)

The Solution
Quote:

1) I need to draw textured triangles, so I should use TriangleStrip(s) with what type of vertices?

You can use CustomVertex.PositionTextured vertices and TriangleStrips and building the vertex data as follows.
Example:
[source lang = "C#"]
CustomVertex.PositionTextured[] triangle = new CustomVertex.PositionTextured[4];
quad[0] = new CustomVertex.PositionTextured(-1.0f, 0.0f, 0.0f, 0.0f, 1.0f);
quad[1] = new CustomVertex.PositionTextured(-1.0f, 2.0f, 0.0f, 0.0f, 0.0f);
quad[2] = new CustomVertex.PositionTextured( 1.0f, 0.0f, 0.0f, 1.0f, 1.0f);
quad[3] = new CustomVertex.PositionTextured( 1.0f, 2.0f, 0.0f, 1.0f, 0.0f);



Quote:

2) I'm creating a panel control (ie windowed mode) that does it's drawing through directx, can I sync the drawing operation to the vertical sync of the monitor? How?

afaik, when you create the device in windowed mode, the rendering is waiting for the vsync.
Take a look at this link for PresentInterval

Quote:

3) Do I derive from Windows.Forms.Panel? do I do the render operation in the OnPaint method? Not entirely sure how to create a panel that does it's drawing through directx

All the device needs to be able to render to a control is the handle. This means that when creating the device you need to pass it that handle to the control you want the device to render too.

Quote:

4) Last time I tried this camera stuff it didn't work so well. What type of camera do I use? I would really appreciate if you could help me with the couple lines of code required to set it up


Camera's are a tricky subject but what you want to accomplish might be a simple panning camera.
You can do this in one of a number of ways.
Static camera : meaning the camera stays in one place the whole time and you just scroll the textured quads.
Camera following the player : meaning that the camera will keep the player in it's view and the player moving. Your keys will control the player.
Panning camera : You keep the player in the same place but you pan the camera.

I don't have code handy with me but best practise is look at real life. Think of yourself as the camera. take a piece of paper and pan it infront of your face. what happens? You are standing still (the camera) but the paper is moving.


I hope this helps a bit buddy. Take care.

Share this post


Link to post
Share on other sites
Thank you for your help, I'll start working on it and post back here when I get stuck on something. I really appreciate the time you took to respond. Thanks.

-Sandra

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!