• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

vanattab

Members
  • Content count

    24
  • Joined

  • Last visited

Community Reputation

194 Neutral

About vanattab

  • Rank
    Member
  1. I really, really like RTS that have fewer more powerful units. Like in the best RTS of all time Company of Heroes the player typically has only a large handful of units 10-15 ish. Each infintry unit is really a squad of soldiers but they act as one unit. I don't like games were you just build a massive army of 40 units group them up and just click the center of the enemys base. CoH battles are all about micro-management and environmental interaction. If you have not tried it you can pick up all three games on steam pretty cheap. Also different races are a must IMO but it makes game balance hard and is a lot of extra work. Also having a couple of types of resources is ok but don't go overboard keep the game play focused on interesting and fun battle mechanics, not tedious base management. It’s not fun building a million harvesters and having to constantly keep an eye on them but it is fun to fight for control of the ore this is why CoH's capture of territories is so good.
  2. [quote name='kauna' timestamp='1350394324' post='4990706'] I think that he doesn't expect the values to be limited to 1/255 increments. They should have the same accuracy as a floating point value. That's the problem since the beginning. That's why I proposed to write a pixel shader to fill the buffer with a desired floating point value just to narrow down the problem. Cheers! [/quote] I tried writting a simple texture shader to fill the texture as you suggested but I got an odd error and I am not sure why? This was my shader code: [source lang="cpp"]sampler2D Tex0 : register(s0); float4 fill128( float2 coords : TEXCOORD0) : COLOR { return float4(1, 0.612549, 0.612549, 0.612549); }[/source] In my application code I then compile the shader as so: [source lang="vb"]psByteCode = ShaderBytecode.CompileFromFile("filePath", "fill128", "ps_2_b", ShaderFlags.None) shader = New TextureShader(psByteCode.Data) ... .... ..... ' '''''''' Then in my rendering code before I call device.BeginScene() I call TestTexture.Fill(shader) [/source] But I get the following error on the TestTexture.Fill(shader) call. SlimDX X9Exception with a msg of: [quote] Additional Infromation: E_FAIL: An undetermined error occurred. [/quote]
  3. [quote name='L. Spiro' timestamp='1350337740' post='4990540'] Then what is not behaving as expected? You have values that, when multiplied by 255.0f, result in whole numbers, 1.0f, 2.0f, 3.0f, etc. There is no fraction, so you are obviously going to get 0.0f every time. No mystery here. This is exactly what you should expect. If it is not what you desire, you should change it to be whatever exactly it is that you desire. L. Spiro [/quote] I believe you misunderstand what I am trying to do. I am working on a color vision test to test for color blindness and I would like to be able to display more colors then is possible on an 8bit / per channel display (i.e. 24bit/32bit depth). Say for example I want to display 10bits of color per channel (0-1024), this is equivalent to being able to display 0.25 increments of the 8bit (0-255) scale. For example say I want to render a large letter "A" with a floating point value of 0.503921... on a scale of 0-255 this is 128.50 the way I want to mimic this on an 8bit display is to render half the pixels as 128 and half the pixels as 129. When viewed at a reasonable distance the eye averages over the pixels and interprets the color of the letter as 128.5. Please see the picture below as a reference to want I am talking about. When looking at the image imagine that one of the colors of green is 128 and the other is 129 and that each box was only 1 pixel not 16. Your eye will interpret this as 128.5. Note in the below example it is perfectly uniform in my basic random chance model this is not necessarily true. [img]www.users.muohio.edu/vanattab/BasicDithering.png[/img] In order to implement this with SlimDX and DirectX 9 what I tried was creating a 128Bit surface (I also tried 64Bit for floating point format and regular) so that I can store color to a higher depth. A 64Bit surface should be able to store 2^16 = 65536 possible values (24/32Bit is 2^8=256). So when I render the "A" to a 64 bit surface the color data should be stored in increments of (1/65536) not (1/255). In my pixel shader I then want to get multiply that floating point number by 255 and should get a number like 128.5 if you take the above example. When I then take the frac(of that number) I should get .5 which corresponds to the % chance that I want scale the color value up to 129. But that is not happening for some reason even though I am drawing the text to a 64bit format the color seems to be quantized to 24/32bit format. Does that make sense now?
  4. The frac(oldColor * 255) call always returns 0. While the oldColor values are 0-1 floating point numbers they only are changed in increments of (1/255)
  5. Could you elaborate? I am using D3D9 via the SlimDX wrapper. Maybe SlimDX is taking a float color but converting it to 0-255 before passing it to DirectX?
  6. [b]From L. Spiro:[/b] [quote]After re-reading his original post I think that is what he expects too, but that is a fairly crazy way to get it. Just multiply by 255.0. Divisions are slow. [/quote] Yeah thats what I was oinganlly doing but in my quest to try and figure out what was going on I changed it to see if it made any diffrence. (not sure why I thought it would) [b]From L. Spiro:[/b] [quote]Why not return the unaltered texture values? return oldColor;See what happens. [/quote] Yes I have done that. And it seems to work but it would not give me any more infromation because when rasterized to the screen it would definatly be quantized to values of 0-255. Thanks for the tip to combine the three lines to one that is good to know. [b]From Adam_42:[/b] [quote]The way DrawString() works is that it uses a texture to hold an image of each character in the font. It's that texture which is almost certainly 8-bit and causing you problems. You want to draw something other than text - a triangle with a different colour at each vertex should do the trick. [/quote] This does not apper to be the problem. ...At least not the only problem. If create a surface like this: [source lang="vb"]Dim tex As Texture = New Texture(device, 100, 100, 1, Usage.RenderTarget, Format A32B32G32R32F, Pool.Defualt)[/source] And then do a device.ColorFill() as so: [source lang="vb"]device.ColorFill(tex.GetSurfaceLevel(0), New Color4(1, 0.53, 0.52, 0.52)[/source] I still get an all black output when you would expect an all 0.6 gray output. I have tried locking the surface and filling all the data with random bits using the Random.NextByte() method which seems to work fine because when I pass it through the Effect I get random colored pixels. (Note: not the same random pixels that get displayed when I don't pass it through the effect). Is there some kind of Format settings for the device object its self? Do I (can I even?) need to set the backbuffer to a 128bit surface? I am really at a loss here.
  7. Yes that is correct. I create at RenderToSurface object with a 128bit format so that I can render some text directly to a surface. I then I create a 128bit texture with one surface to act as the rendertarget. I am not sure if there is such a thing as diffrent bit formats for the Color class. I think if I create a color of 0.52 , 0.52, 0.52 it does not get converted until it get rendered onto the texture but I don't know. "Otherwise, can you confirm that your shader is outputting values correctly?" Yes If I manual but in 0.52 instead of oldColor.r (should be 0.52) I get the expected result.
  8. Note: Sorry I know I have been posting tons of newbie questions on here lately but I really don't understand this problem. I am trying to write an HLSL pixel shader for a project I am working on. Basically want I want to do is if a texture has a pixel with a float value of 0.52 (on scale of 0-255 is 132.6) I want to output 133 60% of the time and output 132 40% of the time. Write now I am just trying to output the fractional remainder of the RGB value (i.e. the chance to bump the pixel up) however I always get a value of zero) I think this is because the colors are getting quantized to a 0-255 scale before they reach the shader but I don't know why this would be because I am useing the A32B32G32R32f format which should be able to store plenty of information about the colors. Here is my very simple shader code. I am using SlimDX (DX9) if that matters. [source lang="cpp"]sampler2D Tex0 : register(s0); float4 DitherByChance(float2 coords : TEXCOORD0) : COLOR { float4 newColor = float4(0, 0, 0, 0); // The pixel color to return double4 oldColor = tex2D(Tex0, coords); double scale = 0.0039215686274509803921568627451; // 1 / 255 double rPercentChance = frac(oldColor.r / scale); //Chance to round red channel up double gPercentChance = frac(oldColor.g / scale); //Chance to round green channel up double bPercentChance = frac(oldColor.b / scale); //Chance to round blue channel up newColor.r = rPercentChance; newColor.g = gPercentChance; newColor.b = bPercentChance; newColor.a = 1; return newColor; } technique DitherViaChance { pass Pass1 { PixelShader = compile ps_2_0 DitherByChance(); } }[/source] Here is the relevant VB code [source lang="vb"] Public Overrides Sub RenderScene() 'ditherBC.Technique = ditherBC.GetTechnique("DitherViaChance") Me.device.BeginScene() spriteRender.Begin(SpriteFlags.None) ditherBC.Begin() ditherBC.BeginPass(0) 'NOTE tex IS CREATED WITH createCharacterTexture()' spriteRender.Draw(tex, New Rectangle(0, 0, 50, 50), New Color4(1, 1, 1)) spriteRender.End() ditherBC.EndPass() ditherBC.End() Me.device.EndScene() End Sub Public Function createCharacterTexture() As Texture Dim RtsHelper As RenderToSurface = New RenderToSurface(device, 100, 100, Format.A32B32G32R32F) Dim texture As Texture = New Texture(device, 100, 100, 1, Usage.RenderTarget, Format.A32B32G32R32F, Pool.Default) Dim sloanFont As Font = New Font(device, 98, 98, FontWeight.Normal, 1, False, CharacterSet.Default, Precision.Default, FontQuality.ClearTypeNatural, PitchAndFamily.Default, "Sloan") RtsHelper.BeginScene(texture.GetSurfaceLevel(0), New Viewport(0, 0, 100, 100)) sloanFont.DrawString(Nothing, "A", 1, 1, New SlimDX.Color4()) RtsHelper.EndScene(Filter.None) Font.Dispose() RtsHelper.Dispose() Return texture End Function [/source]
  9. I am trying to write an HLSL pixel shader for a project I am working on. Basically want I want to do is if a texture has a pixel with a float value of 0.52 (on scale of 0-255 is 132.6) I want to output 133 60% of the time and output 132 40% of the time. Write now I am just trying to output the fractional remainder of the RGB value (i.e. the chance to bump the pixel up) however I always get a value of zero) I think this is because the colors are getting quantized to a 0-255 scale before they reach the shader but I don't know why this would be because I am useing the A32B32G32R32f format which should be able to store plenty of information about the colors. Here is my very simple shader code. I am using SlimDX (DX9) if that matters. [CODE] sampler2D Tex0 : register(s0); float4 DitherByChance(float2 coords : TEXCOORD0) : COLOR { float4 newColor = float4(0, 0, 0, 0); // The pixel color to return double4 oldColor = tex2D(Tex0, coords); double scale = 0.0039215686274509803921568627451; // 1 / 255 double rPercentChance = frac(oldColor.r / scale); //Chance to round red channel up double gPercentChance = frac(oldColor.g / scale); //Chance to round green channel up double bPercentChance = frac(oldColor.b / scale); //Chance to round blue channel up newColor.r = rPercentChance; newColor.g = gPercentChance; newColor.b = bPercentChance; newColor.a = 1; return newColor; } technique DitherViaChance { pass Pass1 { PixelShader = compile ps_2_0 DitherByChance(); } } [/CODE] Here is my SlimDX code too if you want to look: [CODE] Public Class TextStimulusDisplay Inherits BaseStimulusDisplay Protected ditherByChanceEffect As PixelShader Protected psByteCode As ShaderBytecode Protected gStream As DataStream Protected ditherBC As Effect Protected tex As Texture Protected spriteRender As Sprite Public displaySettings As DisplaySettings Public charText As Texture Public randomText As Texture Protected rando As Random Public Sub New(ByVal displaysettings As DisplaySettings, Optional ByVal WindowedMode As Boolean = False) MyBase.New(New Size(displaysettings.xResolution, displaysettings.yResolution), WindowedMode) Me.displaySettings = displaysettings End Sub Public Overrides Sub CreateDeviceResources() MyBase.CreateDeviceResources() ditherBC = Effect.FromFile(device, Application.StartupPath & "\effects\DitherByChance.fx", ShaderFlags.Debug) rando = New Random() randomText = New Texture(device, 100, 100, 1, Usage.Dynamic, Format.A32B32G32R32F, Pool.Default) Dim data(80000) As Byte rando.NextBytes(data) Dim dataBox As DataRectangle = randomText.GetSurfaceLevel(0).LockRectangle(LockFlags.None) dataBox.Data.Seek(0, IO.SeekOrigin.Begin) dataBox.Data.Write(data, 0, data.Length) dataBox.Data.Close() randomText.GetSurfaceLevel(0).UnlockRectangle() device.SetTexture(1, randomText) 'psByteCode = ShaderBytecode.CompileFromFile(Application.StartupPath & "\effects\DitherByChance.fx", "DitherByChance", "ps_2_0", ShaderFlags.None) 'ditherByChanceEffect = New PixelShader(device, psByteCode) 'device.PixelShader = ditherByChanceEffect spriteRender = New Sprite(device) spriteRender.Transform = Matrix.Identity tex = createCharacterTexture() End Sub Public Overrides Sub ReleaseDeviceResources() MyBase.ReleaseDeviceResources() End Sub Public Overrides Sub RenderScene() 'ditherBC.Technique = ditherBC.GetTechnique("DitherViaChance") Me.device.BeginScene() spriteRender.Begin(SpriteFlags.None) ditherBC.Begin() ditherBC.BeginPass(0) spriteRender.Draw(tex, New Rectangle(0, 0, 50, 50), New Color4(1, 1, 1)) 'spriteRender.Draw(randomText, New Rectangle(0, 0, 1000, 1000), New Color4(1, 1, 1)) spriteRender.End() ditherBC.EndPass() ditherBC.End() Me.device.EndScene() End Sub Public Function createCharacterTexture() As Texture Dim RtsHelper As RenderToSurface = New RenderToSurface(device, 100, 100, Format.A32B32G32R32F) Dim texture As Texture = New Texture(device, 100, 100, 1, Usage.RenderTarget, Format.A32B32G32R32F, Pool.Default) Dim sloanFont As Font = New Font(device, 98, 98, FontWeight.Normal, 1, False, CharacterSet.Default, Precision.Default, FontQuality.ClearTypeNatural, PitchAndFamily.Default, "Sloan") RtsHelper.BeginScene(texture.GetSurfaceLevel(0), New Viewport(0, 0, 100, 100)) sloanFont.DrawString(Nothing, "A", 1, 1, New SlimDX.Color4()) RtsHelper.EndScene(Filter.None) Font.Dispose() RtsHelper.Dispose() Return texture End Function End Class [/CODE]
  10. I am trying get 3 new random floats into my pixel shader for each pixel. Based on what I have read here, here, and also here, I believe that I need to generate a large texture containing random RGB values and then during each draw call randomly generate a couple of texture coordinate offset values to produce a pseudo-random effect. Is the only way to do this through the LockRect and UnlockRect API? I hope not. Also when do the floating point color values get quantized. For example if I do a ColorFill on a texture and set it too a RGB of ( 0.52, 0.52, 0.52 ) which on a 0-255 scale is ( 132.6, 132.6, 132. 6 ) when I access that texture in my pixel shader will I get a value of 0.52 or 0.52156....i.e. (133).
  11. [quote name='MJP' timestamp='1349415858' post='4987021'] I'm not sure why you'd get an "illegal character" error. Perhaps the encoding of the file you saved is incorrect? I think fxc can only work with plain ANSI text files. Anyway I had to make a few changes to get your shader to compile. You need to declare a sampler2D named s0, since you try to use one. The random function needs to be declared before DitherByChance, since that function uses it. Also the random code you got was in GLSL, and had to be converted. Here's a new version: [code] sampler2D s0; // Input: It uses texture coords as the random number seed. // Output: Random number: [0,1), that is between 0.0 and 0.999999... inclusive. // Author: Michael Pohoreski // Copyright: Copyleft 2012 :-) float random( float2 p ) { // We need irrationals for pseudo randomness. // Most (all?) known transcendental numbers will (generally) work. const float2 r = float2( 23.1406926327792690, // e^pi (Gelfond's constant) 2.6651441426902251); // 2^sqrt(2) (Gelfond–Schneider constant) return frac( cos( fmod( 123456789., 1e-7 + 256. * dot(p,r) ) ) ); } float4 DitherByChance(float2 coords : TEXCOORD0) : COLOR { float3 newColor; // The pixel color to return float4 oldColor = tex2D(s0, coords); // Note I know that as the code stands now rCutOff = gCutOff = bCutOff I will sort a fix for this out later float rCutOff = random(coords); // A random float that determines if the red channel will be rounded up or down float gCutOff = random(coords); // A random float that determines if the green channel will be rounded up or down float bCutOff = random(coords); // A random float that determines if the blue channel will be rounded up or down float rPercentChance = frac(oldColor.r * 255); //Chance to round red channel up float gPercentChance = frac(oldColor.g * 255); //Chance to round green channel up float bPercentChance = frac(oldColor.b * 255); //Chance to round blue channel up //In the code below (1/255) is the floating point represntaion of an incress of one on the 0-255 RGB scale if (rCutOff <= rPercentChance) newColor.r = oldColor.r + ((1 - rPercentChance) / 255); //Bump up one r value else newColor.r = oldColor.r - rPercentChance * (1 / 255); //Bump down to ensure r is not rounded up if (gCutOff <= gPercentChance) newColor.g = oldColor.g + ((1 - gPercentChance) / 255); //Bump up one g value else newColor.b = oldColor.b - bPercentChance * (1 / 255); //Bump down to ensure g is not rounded up if (bCutOff <= bPercentChance) newColor.b = oldColor.b + ((1 - bPercentChance) / 255); //Bump up one b value else newColor.b = oldColor.b - bPercentChance * (1 / 255); //Bump down to ensure b is not rounded up return float4(newColor, 1.0f); } [/code] [/quote] Thank you so much! My file was indeed encoded in UTF-8 which does blow up fxc. Your conversion of the GLSL code fixed the rest of my problems. I am struggling right now with figuring out how to use my effect when rendering 2d textures with spritebatch but if I can't figure it out I will post my problems here again. Thanks you again for your help.
  12. I am writing I SlimDX application to test color contrast sensitivity thresholds of the human visual system. The subject is presented with a large letter that is at low contrast with with the background and asked to identify the letter. However I need the ability to display more colors then is available with a simple 8bit per channel color depth. (i.e. rgb values 0-255). The way I plan to due this is through a simple "dithering" algorithm implemented as an HLSL pixel shader. Basically if request slimDX to render the text to a surface with a color of Color4( 0.55f, 0.55f, 0.55f ) which corresponds to a rgb value of ( 140.25 , 140.25 , 140.25 ) I want each color channel of each pixel to have a 25% chance of being set to 141 and a 75% chance of getting set to 140. This should (in the limit of many pixels) lead to a letter that appears as a shade of gray one 1/4 of the way in-between 140 and 141. I am however getting errors in my prototype shader code when trying to compile with fxc. I am getting an Illegal character code when I compile and I don't know why. Also if you are a HLSL guru please look over my code and make any comments that strike you. Note I got the HLSL random function from an answer to this question. http://stackoverflow.com/questions/5149544/can-i-generate-a-random-number-inside-a-pixel-shader Below is my shader code. Please forgive me if there a many mistakes as its my first HLSL code: [CODE] float4 DitherByChance(float2 coords : TEXCOORD0) : COLOR { float4 newColor; // The pixel color to return float4 oldColor = tex2D(s0, coords); // Note I know that as the code stands now rCutOff = gCutOff = bCutOff I will sort a fix for this out later float rCutOff = random(coords); // A random float that determines if the red channel will be rounded up or down float gCutOff = random(coords); // A random float that determines if the green channel will be rounded up or down float bCutOff = random(coords); // A random float that determines if the blue channel will be rounded up or down float rPercentChance = frac(oldColor.r * 255); //Chance to round red channel up float gPercentChance = frac(oldColor.g * 255); //Chance to round green channel up float bPercentChance = frac(oldColor.b * 255); //Chance to round blue channel up //In the code below (1/255) is the floating point represntaion of an incress of one on the 0-255 RGB scale if (rCutOff <= rPercentChance) newColor.r = oldColor.r + ((1 - rPercentChance) / 255); //Bump up one r value else newColor.r = oldColor.r - rPercentChance * (1 / 255); //Bump down to ensure r is not rounded up if (gCutOff <= gPercentChance) newColor.g = oldColor.g + ((1 - gPercentChance) / 255); //Bump up one g value else newColor.b = oldColor.b - bPercentChance * (1 / 255); //Bump down to ensure g is not rounded up if (bCutOff <= bPercentChance) newColor.b = oldColor.b + ((1 - bPercentChance) / 255); //Bump up one b value else newColor.b = oldColor.b - bPercentChance * (1 / 255); //Bump down to ensure b is not rounded up return newColor; } // Input: It uses texture coords as the random number seed. // Output: Random number: [0,1), that is between 0.0 and 0.999999... inclusive. // Author: Michael Pohoreski // Copyright: Copyleft 2012 :-) float random( vec2 p ) { // We need irrationals for pseudo randomness. // Most (all?) known transcendental numbers will (generally) work. const vec2 r = vec2( 23.1406926327792690, // e^pi (Gelfond's constant) 2.6651441426902251); // 2^sqrt(2) (Gelfond–Schneider constant) return fract( cos( mod( 123456789., 1e-7 + 256. * dot(p,r) ) ) ); } [/CODE]
  13. I Basically what I am trying to do is be able to display a red (or green or blue) letter with more then 256 possible shades. For example normally if I have a blue letter 'A' with an rgb value of (0 , 0 , 100) the next blue level up would be an rgb (0, 0 , 101). I want to be to show an 'A' that "APPEARS" to have an rgb value of (0, 0, 100.25). Basically I want to do this by making 3/4th of the pixels in the "A" have (0,0,100) and 1/4th have a value of (0,0,101). I noticed that there is a dither filter in DX but from reading about it I don't think it is quite what I want but I am not sure. The reason I don't think I can use the built in dithering is because from what I have read here: [url="http://www.toymaker.info/Games/html/render_states.html#blends"]http://www.toymaker.info/Games/html/render_states.html#blends[/url] the built in dithering is legacy code that only works when rendering to a 16bit surface. I need a way to dither from a pixel format that is > 8bits per channel down to 8bits per channel. Does any one know of a way I could implement this dithering. I don't know anything about writing pixel shaders but do you think that might be the right approach? If I could figure out a way to determine which pixels made up the letter I would could try a simple dithering technique where I just go through each pixel and based on a 25% probability bump the color up one but this would be less then ideal. Does anyone have any experience with dithering in DirectX and know of any techniques that would make this possible. NOTE: I am using SlimDX (DX9) but could switch to DX10/11 if needed
  14. [quote name='Mike.Popoloski' timestamp='1348674766' post='4984004'] There's nothing inherently wrong with only rendering when you need to. The reason games do it is because there are typical objects animating and camera movement constantly, so the changes have to be rendered anyway. If you give more information on what was going wrong with device lost scenarios, it might be a better approach to try to fix those and continue going the way you were before. If you want to render continuously though, that's also viable. The idea is that you *replace* the Application.Run() method with MessagePump.Run(). You can run as many forms as you want on the same message loop. MessagePump.Run() internally hooks the application "Idle" event and constantly calls your provided callback whenever there are no window messages in the queue. You can put your rendering code inside that loop, and then you can add objects to be rendered to some shared list whenever you need to run one of your tests. [/quote] Thanks for the help Mike. I am working on rewritting some of the code now. I was haveing trouble trying to handle the DeviceLostExceptions when not rendering on demand. I tried to have some render code that looked something like: [source lang="vb"]Sub RenderScene() ...Some Code Try device.present() Catch e as devLostEx DevLost = true recover() RenderScene() End Try End Sub Sub recover() While DevLost Try device.testCoop Catch DevLostEx 'Do nothing Catch DevNotReset ...Dispose defult pool stuff device.reset() recreate defult pool stuff DevLost = false End Try End While End Sub[/source] That was with MDX9 not SlimDX. It just seemed to hang and never recover. I am not sure why. Anyway I have got a SlimDX basic class rendering contiually and handleing device lost exceptions fine. I am running it in its own thread and am just using synclock to protect data when I pass new objects to the display. I think the code would be a little slow if I need to render really fast because I synclock most of the SlimDX code but I don't think it will be a big issue for me. I am however running in to some trouble. I can't find a SlimDX replacment for the MDX9 Surface.FromImage() method. Also someone said that the DeviceEx class as some better features for passing data between threads so should I be using that class? Thanks for any help you can provide.
  15. Also I am getting a D3DXERR_INVALIDDATA exception when I call the Surface.FromFile( ) method. I know that the path to the file is correct. [source lang="vb"] Public Overridable Sub CreateDeviceResources() Dim str As String = Application.StartupPath & "\phoriaRing.bmp" test = Surface.CreateOffscreenPlain(device, 150, 150, Format.A8R8G8B8, Pool.Default) Surface.FromFile(test, str, Filter.Default, 8) End Sub[/source] I tried enabling the debug runtime but its not much help: [CODE] Direct3D9: (INFO) :======================= Hal HWVP device selected Direct3D9: (INFO) :HalDevice Driver Style b Direct3D9: :Subclassing window 000d04ba Direct3D9: :StartExclusiveMode Direct3D9: (INFO) :Using FF to VS converter Direct3D9: (INFO) :Using FF to PS converter Direct3D9: (INFO) :Enabling multi-processor optimizations Direct3D9: (INFO) :DDI threading started D3D9 Helper: Warning: Default value for D3DRS_POINTSIZE_MAX is 5.80233e-315f, not 5.51222e-315f. This is ok. A first chance exception of type 'SlimDX.Direct3D9.Direct3D9Exception' occurred in SlimDX.dll An unhandled exception of type 'SlimDX.Direct3D9.Direct3D9Exception' occurred in SlimDX.dll Additional information: D3DXERR_INVALIDDATA: Invalid data (-2005529767) [/CODE] Ok I managed to get the Surface.FromFileInStream() working but I have to know the Size of the image and everything in advance. What if I don't know the size of the image. I guess I could load the File in a Image object and then record the information and then do a FromFileInStream but that seems like poor efficiency. There has to be a better way.