xna-4.0

How to unset texture data in XNA 4.0

不羁的心 提交于 2019-12-08 01:28:24
问题 I need to communicate some constantly changing data to my pixel shader. I have a texture2d that I am passing to my pixel shader via a texture parameter. Before I call the shader I need to update the data in the texture. emittingPositions.SetData(emittingPositionsBuffer); //Set the data on the texture animationEffect.Parameters["emittersMap"].SetValue(emittingPositions); //Tell the shader about the texture data //go on to do the actual drawing calls to use the pixel shader The problem is that

How to get the full root directory of a ContentManager in XNA 4.0

纵然是瞬间 提交于 2019-12-06 15:27:41
I was wondering if anyone here knows how to find the complete path (from the drive letter onwards) of a ContentManager instance. using this I could create a string with the right number of "..\" to append to the file path when I want to load a file from anywhere else on the computer (eg. from a registry key). So basically I'm asking if there is a way. You may just want to use System.GetFolderPath with one of these locations , most likely Program Files. From there, you can navigate to your application's installation directory. You could also use .Load("\MyFolder\blah") which will load from the

How to unset texture data in XNA 4.0

穿精又带淫゛_ 提交于 2019-12-06 10:43:15
I need to communicate some constantly changing data to my pixel shader. I have a texture2d that I am passing to my pixel shader via a texture parameter. Before I call the shader I need to update the data in the texture. emittingPositions.SetData(emittingPositionsBuffer); //Set the data on the texture animationEffect.Parameters["emittersMap"].SetValue(emittingPositions); //Tell the shader about the texture data //go on to do the actual drawing calls to use the pixel shader The problem is that when I do this I get an exception: "You may not call SetData on a resource while it is actively set on

XNA game components

我的未来我决定 提交于 2019-12-06 06:50:42
I an confused about how to pass values of variables from 1 gamecomponent to another. I am using xna 4.0. I created two gamecomponents, the drawstring and the inputmanager. I want to read the keyboard input of the user and pass it onto drawstring where it will update the position. I cant add components on drawstring(drawablegamecomponent). I can do it on class but not on gamecomponent. Can you guys post some examples here. For beginners. Use GameComponent for something that you would want to have Update called on every frame, and use DrawableGameComponent for something that you would want to

Xna 4.0 3D Vertex example

感情迁移 提交于 2019-12-05 04:29:13
问题 I'm currently trying to make a simple square by combining two triangles, like in the tutorials by Riemer (Link to tutorial), but since a lot has changed from 3.x to 4.0, I find it difficult. I would also like to know how to texture this "square", so if anyone could help me by giving some example or whatsoever, I would appreciate it :) Thanks! Basic 回答1: Here is an example XNA 4.0 program that draws a simple textured square. It requires the Green-gel-x texture (from wiki-commons - link in code

Stencil testing in XNA 4

北城余情 提交于 2019-12-04 18:32:58
I was able to do this in XNA 3.1, however I see that we now use state objects in XNA 4, which is certainly an improvement, although I can't accomplish what I want so far :) I am trying to: Clear the stencil buffer to 0. Draw a texture to the stencil buffer, setting the stencil buffer to 1 where the texture is drawn. Draw another texture that will only appear where the stencil buffer is not 1. Here is what I have so far, which appears to have no effect on the drawing of texture 2: BlendState blend = new BlendState(); blend.ColorWriteChannels = ColorWriteChannels.None; _preSparkStencil = new

Create Rounded Rectangle Texture2D

China☆狼群 提交于 2019-12-04 13:00:47
I am building a game with dialog boxes, and I would like to be able to procedurally generate textures for the boxes, in a very similar style to that of the Final Fantasy Series (think like Final Fantasy VII ). Here is a code snippet of what I have so far: public class DialogBox { public Rectangle BoxArea { get; set; } public List<Color> BoxColors { get; set; } public List<Color> BorderColors { get; set; } public int BorderThickness { get; set; } public int BorderRadius { get; set; } private Texture2D texture; public void CreateBackdrop(ref GraphicsDevice graphics) { texture = new Texture2D

Scaling entire screen in XNA

爷,独闯天下 提交于 2019-12-03 17:34:52
问题 Using XNA, I'm trying to make an adventure game engine that lets you make games that look like they fell out of the early 90s, like Day of the Tentacle and Sam & Max Hit the Road . Thus, I want the game to actually run at 320x240 (I know, it should probably be 320x200, but shh), but it should scale up depending on user settings. It works kind of okay right now, but I'm running into some problems where I actually want it to look more pixellated that it currently does. Here's what I'm doing

How is L-systems for road networks modified?

不羁的心 提交于 2019-12-03 08:14:37
Greetings each and all! I'm currently looking into procedural generation of a road network and stumbled upon the L-system algorithm. From what I understand from various scientific papers on the subject, and further papers on the papers on the subject, the algorithm is changed to use "global goals and local constraints", in which the taken path is modified to fit input values such as terrain and population density. Now that part I understand, or atleast the overall concept, but how am I supposed to modify the algorithm? Right now I have a string which is modified over timesteps according to a

XNA game performance

假如想象 提交于 2019-12-03 03:45:26
问题 I am writing a game using C# 2010 and XNA 4.0. I want it to be a good game and not some "just another crap" and so one of my goals is good framerate. For this I would like to ask you for some advices, be it XNA related or C# related - what can I do to speed up my code and so improve FPS. Here is some stuff I found out: (c#) using array insted of list<> will improve performance a lot, in case you want to access huge amount of data (or even lots: having an array of 20000 items gave almost 180%