• What do you need help with? Version 5
    5,752 replies, posted
[QUOTE=ThePuska;38301662]I'm testing out Visual Studio 2012, for C# specifically. Can someone tell me if it's possible to have some references and other files in the project dependent on your solution platform? I need to reference different DLLs on x86 and x64, and copy different DLLs to the output folder depending on the platform. It'd be nice to automate this.[/QUOTE] You can edit the .csproj file and throw the Condition attribute on pretty much any tag: [code]Condition=" '$(Platform)' == 'x86' "[/code]
Hi, I just wonderd, is function prototyping a bad habit? I keep thinking it is bad, because I noticed it slows down the code a bit.
It's not a bad practice. What language are you using? I don't think it'd have a noticeable effect in any language, much less a negative effect!
I'm fairly sure modern compliers will optimize it so it won't make a difference if you prototype or not.
With the same problem :(
Need some help with sine waves. Here is my drawing function so far: [cpp](x and y were initialized to 0) for(int n=0; n<75; n++) { y = (sin(x) * 10) + 715; D3DXVECTOR3 pos(x, y, 0); spriteobj->Draw(square, NULL, NULL, &pos, D3DCOLOR_XRGB(255, 255, 255)); x += 16; }[/cpp] Now, that gets me this: [IMG]http://i.imgur.com/UdFsI.png[/IMG] I know that sin(16) gives a negative value, so that's why every other square is acting weird. I tried to abs() the sin function, so it wouldn't give negative values, but... [IMG]http://i.imgur.com/Q1pkV.png[/IMG] That doesn't look quite right... if I'm just seeing things and this is right, just tell me. Can someone tell me how to draw the cubes in a regular sine function, no oddities?
[QUOTE=Number-41;38299835]And is there some comprehensive tutorial that explains each of these components? [URL="http://www.cprogramming.com/tutorial/opengl_first_windows_app.html"]This one[/URL] is a bit brief...[/QUOTE] [url]http://www.winprog.org/tutorial/[/url]
[QUOTE=Meatpuppet;38303335]Can someone tell me how to draw the cubes in a regular sine function, no oddities?[/QUOTE] sin takes an angle in radians, 16 radians is ~916 degrees.
Instead of drawing large squares on the screen, try creating a texture where every pixel is (sin(x) * cos(y)) or something like that, then test it by drawing that texture as a fullscreen quad. Just make the texture a float[][] and start filling it in..
[QUOTE=robmaister12;38303577]Instead of drawing large squares on the screen, try creating a texture where every pixel is (sin(x) * cos(y)) or something like that, then test it by drawing that texture as a fullscreen quad. Just make the texture a float[][] and start filling it in..[/QUOTE] I'm not quite sure what you mean. [editline]3rd November 2012[/editline] [QUOTE=MakeR;38303553]sin takes an angle in radians, 16 radians is ~916 degrees.[/QUOTE] So I need to convert sin(x) to rads? [editline]3rd November 2012[/editline] Woo, converting it to radians worked! :D Thanks! If anyone wants to know: [cpp] for(int n=0; n<75; n++) { y = ((sin(x*2) * (3.14159 / 180)) * 500) + 715; D3DXVECTOR3 pos(x, y, 0); spriteobj->Draw(square, NULL, NULL, &pos, D3DCOLOR_XRGB(255, 255, 255)); x += 16; }[/cpp] [img]http://i.imgur.com/AxUTq.png[/img]
[QUOTE=Meatpuppet;38303642]So I need to convert sin(x) to rads?[/QUOTE] I'm assuming you don't want each square to be 916 degrees ahead of the last, so you should convert x to radians then sin it.
-snip-
[QUOTE=Meatpuppet;38303642]Woo, converting it to radians worked! :D Thanks![/QUOTE] That isn't actually correct, although it is displaying a sine wave. You should convert x to radians before you sine it.
[QUOTE=MakeR;38303723]That isn't actually correct, although it is displaying a sine wave. You should convert x to radians before you sine it.[/QUOTE] Ok, I'll do that. [editline]3rd November 2012[/editline] It's only drawing one square. [cpp] for(int n=0; n<75; n++) { x *= 3.14159/180; y = (sin(x) * 10) + 715; D3DXVECTOR3 pos(x, y, 0); spriteobj->Draw(square, NULL, NULL, &pos, D3DCOLOR_XRGB(255, 255, 255)); x += 16; }[/cpp] [editline]3rd November 2012[/editline] Also, I need some help. I don't know how to I don't know how to[quote]- Use perlin noise to generate a 2D array of height data (2D array = image). If you looked at this image, it'd be a top-down map of terrain height. Lower values mean low terrain. Higher values mean high terrain. (of course, you could flip this).[/quote] I don't understand how to make an array like that. I'm looking at [url=http://webstaff.itn.liu.se/~stegu/TNM022-2005/perlinnoiselinks/perlin-noise-math-faq.html#toc-algorithm]this[/url], but I'm really dumb and don't know how to make all of that into a function in C++.
[QUOTE=Meatpuppet;38303642]I'm not quite sure what you mean.[/QUOTE] I'm talking about where you should go next. Generate an image outside of DirectX and use it as a texture: [code] float[][] terrain = new float[512][512]; for (int i = 0; i < 512; i++) { for (int j = 0; j < 512; j++) { terrain[i][j] = sin(i) * cos(j); } } //import as directX texture //draw fullscreen quad with texture to test [/code]
How do you import an array as a texture?
[QUOTE=Meatpuppet;38303782]It's only drawing one square. [cpp] for(int n=0; n<75; n++) { x *= 3.14159/180; y = (sin(x) * 10) + 715; D3DXVECTOR3 pos(x, y, 0); spriteobj->Draw(square, NULL, NULL, &pos, D3DCOLOR_XRGB(255, 255, 255)); x += 16; }[/cpp][/QUOTE] Don't change the x variable, just convert it in the call to sin. [cpp]y = 10*sin(x*3.14159/180) + 715;[/cpp]
Oh, duh, haha. Thanks!
[QUOTE=Meatpuppet;38303902]How do you import an array as a texture?[/QUOTE] How do you regularly import textures? I only know OpenGL and glTexImage2D takes an array of values as pixels. So essentially you take the float[][] and pass it into the equivalent DirectX method, you may have to convert it to a byte[][] first, depending on what it can accept. Just look it up, it's fairly standard stuff...
[QUOTE=robmaister12;38304114]How do you regularly import textures? I only know OpenGL and glTexImage2D takes an array of values as pixels. So essentially you take the float[][] and pass it into the equivalent DirectX method, you may have to convert it to a byte[][] first, depending on what it can accept. Just look it up, it's fairly standard stuff...[/QUOTE] This is how I define textures in DirectX: [cpp] LPDIRECT3DTEXTURE9 square = NULL;[/cpp] Then in Game_Init:[cpp] square = LoadTexture("square.bmp"); if(!square) return false;[/cpp] So, you're saying to do this?[cpp] float[][] terrain = new float[512][512]; for (int i = 0; i < 512; i++) { for (int j = 0; j < 512; j++) { terrain[i][j] = sin(i) * cos(j); } } LPD3DTEXURE9[][] terrain[/cpp] [editline]3rd November 2012[/editline] Fucking facepunch.
[QUOTE=Meatpuppet;38304158]This is how I define textures in DirectX: [cpp] LPDIRECT3DTEXTURE9 square = NULL;[/cpp] Then in Game_Init:[cpp] square = LoadTexture("square.bmp"); if(!square) return false;[/cpp] So, you're saying to do this?[cpp] float[][] terrain = new float[512][512]; for (int i = 0; i < 512; i++) { for (int j = 0; j < 512; j++) { terrain[i][j] = sin(i) * cos(j); } } LPD3DTEXURE9[][] terrain[/cpp] [editline]3rd November 2012[/editline] Fucking facepunch.[/QUOTE] What's the contents of LoadTexture()? Instead of passing the path to a file, you should also accept a byte[][] of pixels, since it's just reading out a byte[][] from the .bmp file. You want to generate a single primitive that has a texture of size 512x512, not 262,144 primitives.
anyone know if the semaphores in semaphore.h are FIFO or not?
[QUOTE=robmaister12;38304278]What's the contents of LoadTexture()? Instead of passing the path to a file, you should also accept a byte[][] of pixels, since it's just reading out a byte[][] from the .bmp file. You want to generate a single primitive that has a texture of size 512x512, not 262,144 primitives.[/QUOTE] Here is loadtexture() [cpp]LPDIRECT3DTEXTURE9 LoadTexture(std::string filename, D3DCOLOR transcolor) { LPDIRECT3DTEXTURE9 texture = NULL; //get width and height from bitmap file D3DXIMAGE_INFO info; HRESULT result = D3DXGetImageInfoFromFile(filename.c_str(), &info); if (result != D3D_OK) return NULL; //create the new texture by loading a bitmap image file D3DXCreateTextureFromFileEx( d3ddev, //Direct3D device object filename.c_str(), //bitmap filename info.Width, //bitmap image width info.Height, //bitmap image height 1, //mip-map levels (1 for no chain) D3DPOOL_DEFAULT, //the type of surface (standard) D3DFMT_UNKNOWN, //surface format (default) D3DPOOL_DEFAULT, //memory class for the texture D3DX_DEFAULT, //image filter D3DX_DEFAULT, //mip filter transcolor, //color key for transparency &info, //bitmap file info (from loaded file) NULL, //color palette &texture ); //destination texture //make sure the bitmap textre was loaded correctly if (result != D3D_OK) return NULL; return texture; } [/cpp] I can't figure out a way for it to accept a byte[][], because the function I'm using is just based off of a filename. I can't find a DX function for reading out a byte[][].
[QUOTE=thrawn2787;38304490]anyone know if the semaphores in semaphore.h are FIFO or not?[/QUOTE] 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
[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.
I'm using d3d9
After like 2 minutes of googling: [url]http://msdn.microsoft.com/en-us/library/windows/desktop/bb172804(v=vs.85).aspx[/url] [editline]3rd November 2012[/editline] dayum, you guys are fast!
Also, how does that enable me to input an array of bytes to get a texture? [editline]3rd November 2012[/editline] I googled "Creating a texture from a byte array" and nothing came up.
[QUOTE=Meatpuppet;38304759]Also, how does that enable me to input an array of bytes to get a texture? [editline]3rd November 2012[/editline] I googled "Creating a texture from a byte array" and nothing came up.[/QUOTE] Textures are just arrays of color values, most commonly 3 or 4 bytes per pixel, RGB or RGBA, but you can specify other formats. The pSrcData parameter is basically just a void*, meaning you can pass in any sort of pointer or array as long as you specify the size in pSrcDataSize.
Can I have an example of the function being used?
Sorry, you need to Log In to post a reply to this thread.