• What do you need help with? Version 5
    5,752 replies, posted
[QUOTE=ThePuska;38304710]They're not. edit: The order is practically random, whatever thread happens to be in the scheduler's favour when the semaphore is released gets it[/QUOTE] that is what i thought. wasn't sure if it i was my code or it is was just like a first come first serve when a semaphore got unlocked
So [cpp]HRESULT D3DXCreateTextureFromFileInMemory( d3ddev, bytes[][], sizeof(bytes), square );[/cpp]
[QUOTE=Meatpuppet;38304839]So [cpp]HRESULT D3DXCreateTextureFromFileInMemory( _In_ LPDIRECT3DDEVICE9 pDevice, _In_ bytes[][], _In_ sizeof(bytes), _Out_ square ); [/cpp][/QUOTE] Look at your own LoadTexture method and how you use D3DXCreateTextureFromFileEx... now look at the [url=http://msdn.microsoft.com/en-us/library/windows/desktop/bb172802(v=vs.85).aspx]documentation for that method[/url], then back at the documentation for D3DXCreateTextureFromFileInMemoryEx... [editline]3rd November 2012[/editline] actually wait, that won't accept raw data, only files stored in memory. Go with this solution: [QUOTE=Philly c;38304714][URL="http://msdn.microsoft.com/en-gb/library/windows/desktop/bb174363(v=vs.85).aspx"]Create[/URL] [URL="http://msdn.microsoft.com/en-gb/library/windows/desktop/bb205913(v=vs.85).aspx"]lock[/URL] Copy texture data. [URL="http://msdn.microsoft.com/en-gb/library/windows/desktop/bb205914(v=vs.85).aspx"]unlock[/URL] Haven't used d3d9 myself but it is similar to d3d11 without being able to initialize a texture with the data.[/QUOTE]
-snip- [editline]3rd November 2012[/editline] [QUOTE=robmaister12;38304900] actually wait, that won't accept raw data, only files stored in memory. Go with this solution:[/QUOTE] I don't know how to use that method. Edit: You guys could actually help me instead of rating me dumb.
[QUOTE=Philly c;38304714][URL="http://msdn.microsoft.com/en-gb/library/windows/desktop/bb174363(v=vs.85).aspx"]Create[/URL] [URL="http://msdn.microsoft.com/en-gb/library/windows/desktop/bb205913(v=vs.85).aspx"]lock[/URL] Copy texture data. [URL="http://msdn.microsoft.com/en-gb/library/windows/desktop/bb205914(v=vs.85).aspx"]unlock[/URL] Haven't used d3d9 myself but it is similar to d3d11 without being able to initialize a texture with the data.[/QUOTE] I'm having trouble using this. [url]http://pastebin.com/YG0494je[/url] The problem is in the CreateTexture function, where it can't convert LPDIRECT3DTEXTURE9 to IDirect3DTexture9. That is the only error. [editline]4th November 2012[/editline] Disregard everything else, haha. [editline]4th November 2012[/editline] Well I fixed that (it's &square), but now it's breaking at the lockrect function. [cpp]Unhandled exception at 0x0046B788 in Terrain Generation.exe: 0xC0000005: Access violation reading location 0x00000000.[/cpp]
Anyone that could help me with this little Haskell problem. I've just started learning it, so I'm trying to get a hang of the basics [code]member :: Int -> [Int] -> Bool member y [] = False member y (x:xs) = if y == x then True else member y [xs][/code] When I try to interpret this I get this error message in ghci: [quote]Couldn't match expected type `Int' with actual type `[Int]' In the expression: xs In the second argument of `member', namely `[xs]' In the expression: member y [xs][/quote] I thought the x would refer to the head of the first cons, which should be an integer since that's what the list contains. [editline]4th November 2012[/editline] The function's task is to return True if the input y matches any of the elements of the list.
[QUOTE=kirderf;38307852]Anyone that could help me with this little Haskell problem. I've just started learning it, so I'm trying to get a hang of the basics [code]member :: Int -> [Int] -> Bool member y [] = False member y (x:xs) = if y == x then True else member y [xs][/code] When I try to interpret this I get this error message in ghci: I thought the x would refer to the head of the first cons, which should be an integer since that's what the list contains. [editline]4th November 2012[/editline] The function's task is to return True if the input y matches any of the elements of the list.[/QUOTE] You don't need the square brackets around xs on the last line, since it's already a list.
I'm having a bit of trouble with some c++ syntax. I have a class with a variable, and a subclass. This subclass cannot access the container's variable. [cpp]#define MAX_POLY 3 class Container { public: Container(void); ~Container(void); float time; class Vect { float P[MAX_POLY]; float iT; public: Vect(void); ~Vect(void); float GetVect(int); void SetVect(int,float); float Render(void); }X,Y,Z; }; Container::Container(void) { time = 0; } Container::~Container(void) { } Container::Vect::Vect(void) { for(int n=0;n<MAX_POLY;n++) P[n] = 0; iT = time;// } Container::Vect::~Vect(void) { } float Container::Vect::GetVect(int n) { return P[n]; } void Container::Vect::SetVect(int n,float f) { P[n] = f; iT = time;// } float Container::Vect::Render(void) { float t = time - iT;// float temp1,temp2 = 0,0; for(int n=0;n<MAX_POLY;n++) { temp1 = P[n]; for(int m=0;m<n;m++) temp1 *= t; temp2 += temp1; } return temp2; }[/cpp] My compiler gives me an error at every spot where I referenced time. I've marked them with comment lines. Is there any way to allow Vect to access Container's time without using either of these functions? I'd rather not use them because they both allow for more errors in my code. [cpp]void Container::Vect::SetVect(int n,float f,float* ptime); Container::Vect::Vect(float* ptime);[/cpp]
[QUOTE=Meatpuppet;38307436]I'm having trouble using this. [URL]http://pastebin.com/YG0494je[/URL] The problem is in the CreateTexture function, where it can't convert LPDIRECT3DTEXTURE9 to IDirect3DTexture9. That is the only error. [editline]4th November 2012[/editline] Disregard everything else, haha. [editline]4th November 2012[/editline] Well I fixed that (it's &square), but now it's breaking at the lockrect function. Unhandled exception at 0x0046B788 in Terrain Generation.exe: 0xC0000005: Access violation reading location 0x00000000.[/QUOTE] [quote]Textures created with D3DPOOL_DEFAULT are not lockable. Textures created in video memory are lockable when created with [URL="http://msdn.microsoft.com/en-gb/library/windows/desktop/bb172625%28v=vs.85%29.aspx"][B]USAGE_DYNAMIC[/B][/URL].[/quote] Although that makes me think that there is a different way to initialize a texture with the data rather than lock it afterwards. Maybe [url=http://msdn.microsoft.com/en-us/library/windows/desktop/bb205858%28v=vs.85%29.aspx]this[/url] can help as it copies from a system memory texture to a D3DPOOL_DEFAULT texture, but I am not sure.
Hey. I'm making a program that makes use of a char array, set out as follows : [code] const unsigned char x[12] = { 0x00, 0x01, 0x00, 0x01, 0x02, 0x00, 0x03, 0x00, 0x00, 0x0D, 0x00, 0x00 }; [/code] When I use sizeof(x), it returns 4. Is there any way to access each individual value of this?
[QUOTE=Philly c;38310668]Although that makes me think that there is a different way to initialize a texture with the data rather than lock it afterwards. Maybe [URL="http://msdn.microsoft.com/en-us/library/windows/desktop/bb205858(v=vs.85).aspx"]this[/URL] can help as it copies from a system memory texture to a D3DPOOL_DEFAULT texture, but I am not sure.[/QUOTE] I appreciate you guys trying to help me, but I've figured that I'll cross that bridge when I get to it and focus on making a function that returns an array that was filled in with perlin noise. My questions: -I think it's int* returnarray(), but how can you make a function return an array? Better to be safe than sorry. -How can I use perlin noise to generate a 2D array of height data? I'm using C++ and DirectX, and, I know I sound really stupid, but I'm just a beginner and have never even tried to make a function based off of general algorithms and pseudocode. If anyone can lead me in the right direction, that would be great. I just haven't got the 'lightbulb' that enables me to do such things. That's really all I ask.
Does anyone know how to add a new "new file..." template in monodevelop?
[QUOTE=James xX;38313068]Hey. I'm making a program that makes use of a char array, set out as follows : [code] const unsigned char x[12] = { 0x00, 0x01, 0x00, 0x01, 0x02, 0x00, 0x03, 0x00, 0x00, 0x0D, 0x00, 0x00 }; [/code] When I use sizeof(x), it returns 4. Is there any way to access each individual value of this?[/QUOTE] You don't need sizeof() if it's just a fixed length array, why not just x[0] to x[11].
[QUOTE=James xX;38313068]Hey. I'm making a program that makes use of a char array, set out as follows : [code] const unsigned char x[12] = { 0x00, 0x01, 0x00, 0x01, 0x02, 0x00, 0x03, 0x00, 0x00, 0x0D, 0x00, 0x00 }; [/code] When I use sizeof(x), it returns 4. Is there any way to access each individual value of this?[/QUOTE] An array is a pointer, and a pointer is as large as your processor's machine word (Usually). 4 means you're an a 32-bit operating system (4 bytes, 4*8 = 32). You could do sizeof(x[0]), to get the size of the first element, but why not do sizeof(char) since you already know what it holds? I think what you're trying to do is dynamically get the length of the array, since I suspect you're not going to change it's size, you could just do: [code] #define x_size 12; const unsigned char x[x_size] = { 0x00, 0x01, 0x00, 0x01, 0x02, 0x00, 0x03, 0x00, 0x00, 0x0D, 0x00, 0x00 }; [/code] And use x_size to get the length.
In C# im using openTK I have created a window as in the sample thing, however I have [csharp] using OpenTK; using OpenTK.Graphics; using OpenTK.Graphics.OpenGL; using OpenTK.Audio; using OpenTK.Audio.OpenAL; using OpenTK.Input; [/csharp] Now whenever I use a GL function ex. GL.ClearColor() I get Error CS0104: `GL' is an ambiguous reference between `OpenTK.Graphics.GL' and `OpenTK.Graphics.OpenGL.GL' (CS0104) Usually I just dont include using OpenTK.Graphics; howeer this means that when using things within the OpenTK.Graphics namespace I have to type it all out, is there any way of telling it not to use the OpenTK.graphics.gl stuff, and use the opengl.gl stuff instead?
[QUOTE=Eudoxia;38314621]An array is a pointer, and a pointer is as large as your processor's machine word (Usually). 4 means you're an a 32-bit operating system (4 bytes, 4*8 = 32). You could do sizeof(x[0]), to get the size of the first element, but why not do sizeof(char) since you already know what it holds? I think what you're trying to do is dynamically get the length of the array, since I suspect you're not going to change it's size, you could just do: [code] #define x_size 12; const unsigned char x[x_size] = { 0x00, 0x01, 0x00, 0x01, 0x02, 0x00, 0x03, 0x00, 0x00, 0x0D, 0x00, 0x00 }; [/code] And use x_size to get the length.[/QUOTE] I had some weird macro magic in C that accomplishes what he wants, though your way IS better. [cpp]unsigned char TEST_UTF7[] = { 0x54, 0x2b, 0x41, 0x4f, 0x6b, 0x2d, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x21, 0x20, 0x2b, 0x70, 0x6d, 0x51, 0x20, 0x20, 0x2b, 0x32, 0x44, 0x54, 0x66, 0x55, 0x51, 0x3a, 0xa }; #define TEST_DATA_LEN(code)\ (size_t)(sizeof(TEST_##code) / sizeof(unsigned char))[/cpp]
[QUOTE=Jookia;38315631]I had some weird macro magic in C that accomplishes what he wants, though your way IS better. [cpp]unsigned char TEST_UTF7[] = { 0x54, 0x2b, 0x41, 0x4f, 0x6b, 0x2d, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x21, 0x20, 0x2b, 0x70, 0x6d, 0x51, 0x20, 0x20, 0x2b, 0x32, 0x44, 0x54, 0x66, 0x55, 0x51, 0x3a, 0xa }; #define TEST_DATA_LEN(code)\ (size_t)(sizeof(TEST_##code) / sizeof(unsigned char))[/cpp][/QUOTE] It isn't a fixed size array, I just put the 12 there as an example. In the real code it's just [].
[QUOTE=James xX;38315874]It isn't a fixed size array, I just put the 12 there as an example. In the real code it's just [].[/QUOTE] It's still fixed size. The [] just means that the compiler will figure out the length based on the initializer list. You could use this macro to find out the length. [cpp] #define LENGTH(x)\ (size_t)(sizeof(x) / sizeof(x[0])) [/cpp]
Need some math help because I suck at math. I'm working on a rollercoaster simulation, I have a path of points so that means I have the tangents for each point. I'm calculating the binormals and normals as explained here: [url]http://www.cs.cmu.edu/afs/andrew/scs/cs/15-462/web/old/asst2camera.html[/url] The problem with that is the normals start to roll when going up and turning, so when the path comes back down, the normals aren't facing directly up like you'd expect. What I want to do is lock the rolling of the track so for example, if you tried to create a loop, the path would start to twist when getting near to the top so there's never any roll in the track. So I've found a paper that I think solves this but I'm having trouble understanding what they mean at the "roll snap" section. [url]https://dip.felk.cvut.cz/browse/pdfcache/hykovter_2010bach.pdf[/url] It first off starts by saying "Using a dot product, we calculate the angle between the vector pointing straight up ((0, 1, 0)?) and a vector being the up vector that we want to straighten." That itself confuses me because if i dot a normal of (0,1,0) and (0,1,0), that's going to give me a value of 1. That is not an angle i should be applying to the normal because in that situation the normal is correct and doesn't need to be corrected. Tried to explain as best I could. If not, here's an image that explains what I want to happen. [IMG]https://dl.dropbox.com/u/99765/fortblox/r34324.png[/IMG] If I have a track like this that has roll, I want to remove all roll by rotating the normal around the tangent. The reason why I need to do this is so the user can define the roll of each node instead of the track rolling on its own when creating the track.
[QUOTE=ArgvCompany;38315949]It's still fixed size. The [] just means that the compiler will figure out the length based on the initializer list. You could use this macro to find out the length. [cpp] #define LENGTH(x)\ (size_t)(sizeof(x) / sizeof(x[0])) [/cpp][/QUOTE] In this case it will be, But I could also load a similar thing from a text file, of an unknown length. I wouldn't be asking otherwise.
[QUOTE=Richy19;38315589]In C# im using openTK I have created a window as in the sample thing, however I have [csharp] using OpenTK; using OpenTK.Graphics; using OpenTK.Graphics.OpenGL; using OpenTK.Audio; using OpenTK.Audio.OpenAL; using OpenTK.Input; [/csharp] Now whenever I use a GL function ex. GL.ClearColor() I get Error CS0104: `GL' is an ambiguous reference between `OpenTK.Graphics.GL' and `OpenTK.Graphics.OpenGL.GL' (CS0104) Usually I just dont include using OpenTK.Graphics; howeer this means that when using things within the OpenTK.Graphics namespace I have to type it all out, is there any way of telling it not to use the OpenTK.graphics.gl stuff, and use the opengl.gl stuff instead?[/QUOTE] Use a [url="http://msdn.microsoft.com/en-us/library/c3ay4x3d(v=vs.80).aspx"]namespace alias[/url] [code] using OGL = OpenTK.Graphics.OpenGL; [/code]
Yet another Java question. Suppose I want to combine paint and Swing controls, like if I wanted to fillRect somewhere and change its color via JColorChooser after clicking a JButton next to it. Looking for guidance on this, how would this be done?
[QUOTE=James xX;38316173]In this case it will be, But I could also load a similar thing from a text file, of an unknown length. I wouldn't be asking otherwise.[/QUOTE] You're not going to use an array to load variable length content.
YES! I've figured out how to generate perlin noise. Now, I've got a function that writes an array of perlin noise to a text file, [cpp]void printnoisearray(int w, int h, double seed1, double seed2) { ofstream myfile; myfile.open ("noise.txt"); double array[40]; for(int y=0; y<h; y++) { for(int x=0; x<w; x++) { array[x] = noise(rand() % (int)seed1 + 1, rand() % (int)seed2 + 1); //myfile.open ("noise.txt"); myfile << array[x] << " "; } } myfile.close(); } [/cpp] How can I make the function so it returns an array[][] (a 2d array, I want to translate these values to heightmaps)?
[QUOTE=Meatpuppet;38316702]YES! I've figured out how to generate perlin noise. Now, I've got a function that writes an array of perlin noise to a text file, [cpp] void printnoisearray(int w, int h, double seed1, double seed2) { ofstream myfile; myfile.open ("noise.txt"); double array[40]; for(int y=0; y<h; y++) { for(int x=0; x<w; x++) { array[x] = noise(rand() % (int)seed1 + 1, rand() % (int)seed2 + 1); //myfile.open ("noise.txt"); myfile << array[x] << " "; } } myfile.close(); } [/cpp] How can I make the function so it returns an array[][] (a 2d array, I want to translate these values to heightmaps)?[/QUOTE] Well, you can't exactly return arrays in c/++. You can, however, return pointers, which can be used as arrays in a pinch. [cpp] float* noisearray(int w, double seed) { float* output = (float*)malloc(sizeof(double)*w); for(int i = 0; i<w; i++) { output[i] = noise(seed + i); } return output; } [/cpp] As an example.
[QUOTE=Richy19;38315589]In C# im using openTK I have created a window as in the sample thing, however I have [csharp] using OpenTK; using OpenTK.Graphics; using OpenTK.Graphics.OpenGL; using OpenTK.Audio; using OpenTK.Audio.OpenAL; using OpenTK.Input; [/csharp] Now whenever I use a GL function ex. GL.ClearColor() I get Error CS0104: `GL' is an ambiguous reference between `OpenTK.Graphics.GL' and `OpenTK.Graphics.OpenGL.GL' (CS0104) Usually I just dont include using OpenTK.Graphics; howeer this means that when using things within the OpenTK.Graphics namespace I have to type it all out, is there any way of telling it not to use the OpenTK.graphics.gl stuff, and use the opengl.gl stuff instead?[/QUOTE] IIRC this is an issue that comes up when you reference both OpenTK.dll and OpenTK.Compatibility.dll. Compatibility keeps OpenTK's really old API, where GL was in OpenTK.Graphics (that changed when they added GL|ES bindings and had to split them off to their own namespaces). If you need some specific functionality out of the Compatibility library, just grab it's source from SVN and include it in your project. It's MIT licensed, so it's totally fine to do.
[QUOTE=AyeGill;38316877]Well, you can't exactly return arrays in c/++. You can, however, return pointers, which can be used as arrays in a pinch. [cpp] float* noisearray(int w, double seed) { float* output = (float*)malloc(sizeof(double)*w); for(int i = 0; i<w; i++) { output[i] = noise(seed + i); } return output; } [/cpp] As an example.[/QUOTE] So can I get the values in the returned array like so? [cpp]noisearray(value, seed1, seed2)[n] [/cpp] ? [editline]4th November 2012[/editline] Also, how can I make that a 2D array?
[QUOTE=AyeGill;38316877]Well, you can't exactly return arrays in c/++. You can, however, return pointers, which can be used as arrays in a pinch. [cpp] float* noisearray(int w, double seed) { float* output = (float*)malloc(sizeof(double)*w); for(int i = 0; i<w; i++) { output[i] = noise(seed + i); } return output; } [/cpp] As an example.[/QUOTE] generally i pass in a pointer or a reference to an array and would noise it up in the function, otherwise you need the developer to realize they need to clean up the array afterwards... i guess it doesnt matter really, just sayin'
[QUOTE=amcfaggot;38317350]generally i pass in a pointer or a reference to an array and would noise it up in the function, otherwise you need the developer to realize they need to clean up the array afterwards... i guess it doesnt matter really, just sayin'[/QUOTE] I just need to figure out how to make that an array a 2D array. Also, do I get an item in an array like so? [cpp]noisearray(value, seed1, seed2)[n][/cpp]
[QUOTE=Meatpuppet;38317920]I just need to figure out how to make that an array a 2D array. Also, do I get an item in an array like so? [cpp]noisearray(value, seed1, seed2)[n][/cpp][/QUOTE] I am not sure how you mean with making an array to a 2D array. You could just do something like this maybe. [cpp] int array2D[columnsize][rowsize]; for(int i = 0; i < columnsize; i++) { for(int j = 0; j < rowsize; j++) { array2D[i][j] = array1d[(i * columnsize) + j]; } } [/cpp] You can also cast the array to an 2D array, but I have no idea how to do that. No, I think you have to do something like this: [cpp] noicedatatype* array; array = noisearray(value, seed1, seed2); dowhateveryouwant(noicedatatype[n]); [/cpp]
Sorry, you need to Log In to post a reply to this thread.