Jump to content

  • Log In with Google      Sign In   
  • Create Account

nagromo

Member Since 27 Jan 2003
Offline Last Active Aug 12 2012 08:23 PM

Topics I've Started

HLSL shaders with XNA - convert float to double

11 August 2012 - 08:36 AM

I'm writing a fractal explorer using XNA and HLSL (w/ Pixel Shader 3.0).

It's working great using 32-bit floats, but I'm running into resolution issues, so I want to move to 64-bit doubles.

My card (Radeon 4850) does support 64-bit doubles, and I can define doubles that are initialized to a constant value and do math using them. The problem comes when I want to mix floats with doubles.

The inputs to my shader are the texture coordinates in float2 and some float and float2 constants from the application. These inputs are combined to produce the coordinate in fractal space; I need to do this calculation in double precision.

Here's the original version (single-precision) that's part of the working shader:
[source lang="plain"]float2 c = (texCoord - 0.5) * Zoom * float2(1, Aspect) - pan;[/source]
texCoord and pan are float2, and Zoom and Aspect are float.

I'm having trouble converting this over to use double-precision; even these basic tests to draw the fractal region from (0,0) to (1,1) don't work:

[source lang="plain"]double2 c = texCoord;double2 c = (double2)texCoord;double2 c = double2((double)texCoord.x,(double)texCoord.y);[/source]
All three of these lines give the same error: "internal error: 64-bit arg ??? component 1 not aligned" where ??? is any number from 138 to 922.

Any advice on how to resolve this? Alternatively, if the vertex shader inputs could be double and the values from the application could also be double, that would remove the need for conversion, but I don't know of any way to force the input to my vertex shader to be passed as a double. (If I re-define texCoord to double, I get the same error with different numbers.)

[.net] System.Media.SoundPlayer.Play in console?

05 January 2007 - 09:00 AM

Hi, I'm having issues using System.Media.SoundPlayer.Play in a console-based app. It works fine in a WinForms app, and PlaySync works fine. Here's how I'm doing it: What I want:
static void Main(string[] args)
{
    System.Media.SoundPlayer sp = new System.Media.SoundPlayer();
    sp.SoundLocation = System.AppDomain.CurrentDomain.BaseDirectory + "\\hum.wav";
    sp.Load();
    sp.Play();
    Console.WriteLine("Done");
}
This code immediately prints out Done, without ever playing any sound. If I change sp.Play() to sp.PlaySync() without changing anything else, the sound plays properly, but it halts program execution until the sound finishes. (Obviously; that's the point of the synchronous function, and that's not what I want.) This works just fine (as part of a WinForms app):
public Form1()
{
    InitializeComponent();
    sp = new System.Media.SoundPlayer();
    sp.SoundLocation = AppDomain.CurrentDomain.BaseDirectory + "\\hum.wav";
    sp.Load();
    sp.Play();
}
I think the issue might be differences in threading between Windows apps and Console apps, but I don't know how to set it up properly. I could write a function to create a new thread for each sound and use the synchronous function in that new thread, but it seems like I shouldn't need to, and I don't know how I'd pause or stop playback if I did it that way.

Java crashing my computer

06 February 2006 - 02:03 PM

Hi. Recently I've been having a problem with Java: Every time I try to use something that uses Java, my laptop's screen goes black, except for the mouse. I can't see anything until I restart, but the mouse cursor reacts to stuff and I can click random stuff, causing HDD activity. I'm using Windows XP Pro with Java 1.5. Java's uninstaller also turned the screen black, but when I rebooted Java was gone. I tried re-installing it, but the problem's still there. Does anyone have any ideas?

installer.exe

04 November 2005 - 04:22 PM

I just went to the lounge, and a window popped up asking me where to save 'installer.exe', my popup blocker blocked a popup, and my antivirus came up saying it had blocked something. When it first came up, my HDD and CPU usage peaked and I freaked out, but it was just my antivirus starting a scan. [grin] I messed around a little and I found that it only comes up when there's this ad at the top of the page: link to: http://adserv.valuead.com/reference;gid=17,pid=661,bid=181,rid=1591455694 image: http://banners.valuead.com/adnetwork/64/181.gif I only had google and frapper.com up at the time. It appears when I click back to view the cached lounge through my cache, but not when there's other banners on the page.

[.net] Equivalent to C++ references, using safe code? (renamed)

07 April 2005 - 02:56 AM

I have an ImageManager class that manages my textures, which contains a System.Collections.Hashtable of all the texture info. I defined a ImageData class, with one instance for each texture:
struct ImageData
{
	public int Width, Height;
	public byte[] Pixels;
	public uint ID;
	public bool IsLocked;
}
This is invisible to the users; they access the textures through a string that is the key to the hashtable. I want to allow image modification through access to the color array, though. To do this, I use the IsLocked variable. To modify the texture, one would lock it by ImageManager.Lock(name). The code then modifies the texture array and unlocks the texture, when the new image data is passed to OpenGL. I also have this:
struct Rgba
{
	public byte r, g, b, a;
}
Is it possible to allow outside code to access an array inside of a struct inside of a hashtable as an array of a different type (no conversion of data, it's the same bytes) without making a copy of the array? Would it be more efficient to just give the client code a copy of the array to let them mess around with and pass back? I like the first solution better, but the second is much easier to implement. [Edited by - nagromo on April 7, 2005 2:31:31 PM]

PARTNERS