Click here to Skip to main content
15,920,636 members
Home / Discussions / C#
   

C#

 
AnswerRe: Combobox question Pin
Draders2323-Feb-06 8:20
Draders2323-Feb-06 8:20 
GeneralRe: Combobox question Pin
VPMahank23-Feb-06 12:03
VPMahank23-Feb-06 12:03 
Questiondisplay calendar in: days, weeks, month and year Pin
Andre da Silva Carrilho23-Feb-06 6:53
Andre da Silva Carrilho23-Feb-06 6:53 
QuestionIndexOutOfRangeException during OnPaint Pin
Pseudo Quasi23-Feb-06 6:32
Pseudo Quasi23-Feb-06 6:32 
AnswerRe: IndexOutOfRangeException during OnPaint Pin
Nicholas Butler23-Feb-06 8:05
sitebuilderNicholas Butler23-Feb-06 8:05 
QuestionDataSet to CSV file Pin
zaboboa23-Feb-06 6:12
zaboboa23-Feb-06 6:12 
AnswerRe: DataSet to CSV file Pin
Colin Angus Mackay23-Feb-06 12:20
Colin Angus Mackay23-Feb-06 12:20 
Questioncan't get Texture to draw in DirectX Pin
melanieab23-Feb-06 5:22
melanieab23-Feb-06 5:22 
Hi,
I'm just starting out with DirectX and am running into some trouble (I've been piecing parts of examples together). I have a couple rectangles that yaw, roll, and pitch as they zoom in. When they come back to face the front (so it only looks 2d), I stop the movement and add a couple triangles. Up to here it works just fine. Now I'd like to add a bitmap under the rectangles but run into trouble. I have:
private override OnPaint()<br />
{

some twirling of boxes for a few seconds that become still with this line:
DrawBox(0.0f, 0.0f, 0.0f, -0.45f, 0.8f, 9.5f); (code for DrawBox below)
then I add a couple triangles...
CustomVertex.TransformedColored[] vert = new CustomVertex.TransformedColored[3];
... describe the vert ...
device.VertexFormat = CustomVertex.TransformedColored.Format;<br />
device.DrawUserPrimitives(PrimitiveType.TriangleList, 1, vert);

Things work fine up to here. At this point I'd like to add my bitmap (Texture tex). I change the VertexFormat and call DrawBitmapBox (this is how one example added a texture to a box):
device.VertexFormat = CustomVertex.PositionTextured.Format;<br />
device.SetStreamSource(0, vb, 0);
vb is the VertexBuffer - also below
DrawBitmapBox(0.0f, 0.0f, 0.0f, 2.0f, 2.0f, 9.5f, tex); (code also below)
}
Instead of drawing the bitmap image, the original rectangles themselves kind of blink (not at any contant rate), while the triangles just sit there like everything's ok. I know I'm probably making some obvious mistake(s), but any help in getting this bitmap up would be great!!! Smile | :)
Mel

DrawBox
private void DrawBox(float yaw, float pitch, float roll, float x, float y, float z)<br />
		{<br />
			angle += 0.01f;<br />
			device.Transform.World = Matrix.RotationYawPitchRoll(yaw, pitch, roll) * Matrix.Translation(x, y, z);<br />
			Material boxMaterial = new Material();<br />
			device.Lights[0].Type = LightType.Directional;<br />
			device.Lights[0].Diffuse = Color.Red;<br />
			device.Lights[0].Direction = new Vector3(0,-1,-1);<br />
			device.Lights[0].Commit();<br />
			device.Lights[0].Enabled = true;<br />
			boxMaterial.Diffuse = Color.White;<br />
			device.Material = boxMaterial;<br />
			mesh.DrawSubset(0);<br />
		}

DrawBitmapBox
<br />
		private void DrawBitmapBox(float yaw, float pitch, float roll, float x, float y, float z, Texture t)<br />
		{<br />
			angle += 0.00f;<br />
			device.Transform.World = Matrix.RotationYawPitchRoll(yaw, pitch, roll) * Matrix.Translation(x, y, z);<br />
			device.SetTexture(0, t);<br />
			device.DrawPrimitives(PrimitiveType.TriangleList, 0, 6);<br />
		}

VertexBuffer stuff
under InitializeGraphics:
vb = new VertexBuffer(typeof(CustomVertex.PositionTextured), 6, device, Usage.Dynamic | Usage.WriteOnly, CustomVertex.PositionTextured.Format, Pool.Default);<br />
			vb.Created += new EventHandler(this.OnVertexBufferCreate);<br />
			OnVertexBufferCreate(vb, null);

OnVertexBufferCreate:
private void OnVertexBufferCreate(object sender, EventArgs e)<br />
		{<br />
			VertexBuffer buffer = (VertexBuffer)sender;<br />
<br />
			CustomVertex.PositionTextured[] v = new CustomVertex.PositionTextured[6];<br />
			v[i] = ...<br />
			buffer.SetData(v, 0, LockFlags.None);<br />
		}

AnswerRe: can't get Texture to draw in DirectX Pin
Andy Moore23-Feb-06 6:09
Andy Moore23-Feb-06 6:09 
QuestionClosing a form and enable another one! Pin
alee15.10.8823-Feb-06 4:52
alee15.10.8823-Feb-06 4:52 
AnswerRe: Closing a form and enable another one! Pin
Nicholas Butler23-Feb-06 5:18
sitebuilderNicholas Butler23-Feb-06 5:18 
GeneralRe: Closing a form and enable another one! Pin
alee15.10.8823-Feb-06 20:43
alee15.10.8823-Feb-06 20:43 
QuestionReading and writing to text file simultaneously Pin
liqnit23-Feb-06 3:39
liqnit23-Feb-06 3:39 
AnswerRe: Reading and writing to text file simultaneously Pin
yoaz23-Feb-06 10:00
yoaz23-Feb-06 10:00 
QuestionConvert an Image Pointer Into a Bitmap Pin
redfish3423-Feb-06 3:22
redfish3423-Feb-06 3:22 
AnswerRe: Convert an Image Pointer Into a Bitmap Pin
Nicholas Butler23-Feb-06 3:40
sitebuilderNicholas Butler23-Feb-06 3:40 
GeneralRe: Convert an Image Pointer Into a Bitmap Pin
redfish3425-Feb-06 3:24
redfish3425-Feb-06 3:24 
QuestionWMI Exceptions/Updating List View Pin
autekre23-Feb-06 3:20
autekre23-Feb-06 3:20 
AnswerRe: WMI Exceptions/Updating List View Pin
Praveen Nayak23-Feb-06 19:00
Praveen Nayak23-Feb-06 19:00 
Questionpublic variables Pin
ddpn4223-Feb-06 3:08
ddpn4223-Feb-06 3:08 
AnswerRe: public variables Pin
Le centriste23-Feb-06 3:25
Le centriste23-Feb-06 3:25 
GeneralRe: public variables Pin
ddpn4223-Feb-06 14:22
ddpn4223-Feb-06 14:22 
GeneralRe: public variables Pin
Praveen Nayak23-Feb-06 19:09
Praveen Nayak23-Feb-06 19:09 
GeneralRe: public variables Pin
Le centriste24-Feb-06 1:54
Le centriste24-Feb-06 1:54 
AnswerRe: public variables Pin
StyleGuide23-Feb-06 3:33
StyleGuide23-Feb-06 3:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.