Jump to content
Xtreme .Net Talk

Grand Nagus

Members
  • Posts

    12
  • Joined

  • Last visited

Everything posted by Grand Nagus

  1. Thanks for the response, Iceplug. Actually, I played around with my wav editing program and found an option to get my 10mb wav musicfile down to 2mb (wow!) using an 'ADPCM' option. The finished result doesn't sound much different from an mp3 file, either! Pretty cool stuff! Thanks again! Well, back to work... Let's see how bad I can crash my computer (again) using C++ today! :D
  2. Cool, I'll try the midi thing. I have a Yamaha XG midi box sitting in the attic; guess I'll climb up there and dust it off (I'm a better coder than I am a musical composer, and I'm not a very good coder, so I guess that doesn't say much about my musical abilities...). Thanks for the help, guys! Hey Iceplug, how do you get DirectX to play a MP3? I have plenty of software and wav editing tools to create a good-sounding MP3, but when I load an MP3 file with this code: g_pLoader->LoadObjectFromFile(CLSID_DirectMusicSegment, IID_IDirectMusicSegment8, MusicFile.SoundName, (LPVOID*) &MusicFile.g_pSegment ) after initializing DirectMusic thru this function: g_pPerformance->InitAudio( NULL, NULL, NULL, DMUS_APATH_DYNAMIC_STEREO, DMUS_APATH_SHARED_STEREOPLUSREVERB, 64, DMUS_AUDIOF_ALL, NULL ) I get an error... But if I load a .wav file, it loads and plays it just fine. How do I get the above code to load an MP3 file? Or is there something else I should be doing to play MP3's in my games? If you could help me out on this, I would REALLY appreciate it. :) Thanks in advance for the help!
  3. Hey guys. I know this is a touchy topic on some forums ('Aah! Freak! Wants us to help him find warez and mp3z!? Get the pitchforks and torches!'), but this is actually a legit and 'legally OK' question. :D I've been looking all over the web for royalty-free music that's free to download. What I haven't been looking for is 'illegal music' (I may want to freely distribute this game someday with NO LEGAL FRIGGIN REPERCUSSIONS), so I don't want to hear 'Did you try Kazaa? Did you try Napster?'. I've found a lot of 'pay $100 for a year membership and download all you want' sites, but couldn't find any sites that offered royalty-free music that's free for the taking... I don't want to pay $100 and find out that the site is all 'elevator music' :p . I've found loads o' sites with sound effects, so now when I shoot my weapons I hear aural feedback. But my game's lacking in the background music department. Can anybody help me with finding music for my 'Life Force'-esque space shoot-em-up game? The help would be much appreciated! :) PS: Sorry about my somewhat brutally specific request... I've asked this same sort of question when modding and actually got the response of 'Did you try <insert favorite piracy app here>'... Guess they don't realise that you can't distribute your piece of work with PIRATED elements in it (music, textures, etc). Sheesh!
  4. I need to post more often! It seems that whenever I post, I figure out my problem almost right after I post. Heh! Anyways, it had to do with setting up my sound effects segment with the 'DMUS_SEGF_SECONDARY' flag. After I did that, Voila! It worked! OK, for those of you who want to do what I'm doing: Play primary (music) sound: g_pPerformance->PlaySegmentEx(g_pSegment, NULL, NULL, 0, 0, NULL, NULL, NULL); Play secondary (sound effects) sound: g_pPerformance->PlaySegmentEx(g_pSegment, NULL, NULL, DMUS_SEGF_SECONDARY, 0, NULL, NULL, NULL); Purdy neat! Now my game has music AND sound effects! Plus, I don't have to get my program to jump through flaming hoops to keep sounds from getting interrupted when a new one is played. Yippee! Granted, what I'm doing is prolly pretty 'old hat' compared to what most of you are doing, but I've only been coding with DirectX for only a few months. It's still new to me, so I still get pretty excited to see a game slowly flesh out of pages of DirectX and C++ code! Well, back to work. Have a good weekend! :)
  5. Hey guys. Coding for Direct3D is fun, but how much fun is a game without sound? :) Anyways, I've created a simple DirectMusic performance object... if (FAILED(MyGame->g_pPerformance->InitAudio( NULL, // IDirectMusic interface not needed. NULL, // IDirectSound interface not needed. NULL, // Window handle. DMUS_APATH_SHARED_STEREOPLUSREVERB, // Default audiopath type. 64, // Number of performance channels. DMUS_AUDIOF_ALL, // Features on synthesizer. NULL // Audio parameters; use defaults. ))) loaded it up with data... if (FAILED(MyGame->g_pLoader->LoadObjectFromFile( CLSID_DirectMusicSegment, // Class identifier. IID_IDirectMusicSegment8, // ID of desired interface. MyGame->MusicFiles[i].SoundName, // wstrFileName, // Filename. (LPVOID*) &MyGame->MusicFiles[i].g_pSegment // Pointer that receives interface. ))) and loaded the music segments into my performance object... if ( FAILED(MyGame->MusicFiles[i].g_pSegment->Download(MyGame->g_pPerformance)) ) and can play sound effects using this... MyGame->g_pPerformance->PlaySegment(MyGame->MusicFiles[soundFX].g_pSegment, (DMUS_SEGF_NOINVALIDATE), NULL, NULL); ...and it all works pretty well. I can get sound effects to play whenever I want, and they don't interrupt each other when the playing sound effects get numerous. But what I'm having a problem with is 'looping' a sound; more specifically, a music track. Here's what I'm doing to try to loop the song stored in array 6: MyGame->MusicFiles[6].g_pSegment->SetRepeats(DMUS_SEG_REPEAT_INFINITE); MyGame->g_pPerformance->PlaySegmentEx(MyGame->MusicFiles[6].g_pSegment, NULL, NULL, 0, 0, NULL, NULL, NULL); When the song plays, it plays once and stops. I thought that the flag 'DMUS_SEG_REPEAT_INFINITE' was to make it repeat over and over, but it only plays once. How do I get it to play indefinitely? :confused: Thanks in advance for the help!
  6. Got it fixed! Well, wouldn't ya know it... Waste 3 days, post for help, and then figure it out within a couple of hours. Sheesh! Turns out that '.color' value really DOES have an alpha value... Somebody told me that it was an 'opacity' value, but he was prolly thinking of a paint program as opposed to DirectX. Plus, it's an 'argb' value, NOT an 'rgba' value! (I was playing with the last value instead of the first value, which is why the alphafade never happened... D'OH! ) Anyways, it goes like this: < color is a dword: 0x00(alpha) 00(red) 00(green) 00(blue) > Here's how I got my texture to render progressively more or less transparent: In your 'alphachange' function, set your new alpha value for this quad: newColor = oldColor + 0x01000000; // <argb> In your 'render' function, set your render states like so: <enable alpha blending> SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE ); <texturestate> SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); <alphastate> SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE ); SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTOP_SELECTARG1 ); and set your blendfuncs for this quad to this: SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA ); SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); Hope this info helps somebody else, 'cause it gave me hassles for way too long! I found out how to do this completely by 'trial and error', so if there's a better way to do this please post it! I'd hate to be mis-informing anybody like I almost did with my botched 'color' information... :( Well, back to work! :)
  7. Hey guys. I knew I'd be back! :) Maybe I have a more challenging question than my last one... I'm working on a 2d tile-rendering engine based on Direct3D and quads, and so far it's pretty impressive! (I'm a noob to DirectX, so it doesn't take much to impress me. ;) ) It has a particle system that works (something blows up and it throws sparks - REALLY cool effect!), and you can assign a blendfunc to each individual tile instead of the whole shebang so it renders how you want it to look. WOW! ...Sorry, I didn't mean to carry on like that, I'm just excited about getting something to actually work! Programming my own game from the ground-up beats the heck out of modding somebody else's work (Quake3, Elite Force)! I can see why you guys have so much fun in what you're doing. :) Anyways, here's my question... I'm trying to make the texture on a quad 'fade' out using alpha blending. First, here's some stuff that I'm gonna reference later in my explanation of my problem: // this is my customvertex struct... struct CUSTOMVERTEX2 { float x, y, z, rhw; // The transformed position for the vertex DWORD color; // The vertex color float tu, tv; // The texture coordinates }; ... // LOTS of stuff to create an array of quads ... // this is a pointer to my struct... CUSTOMVERTEX2 *pVertices; ... // locked this vert buffer and actually changing and re-assigning the new color value... oldColor = pVertices[0].color; newColor = oldColor + 0x00000001; if (newColor > 0xFFFFFFFF) newColor = 0xFFFFFF00; pVertices[0].color = newColor; pVertices[1].color = newColor; pVertices[2].color = newColor; pVertices[3].color = newColor; ... You can see from that last part that I'm gradually adding the last value in 'color' from 0x00 (transparent) to 0xFF (opaque) in an effort to 'fade in' this quad. But after several days of research and tinkering, I found out that the last value isn't 'alpha' at all; it's OPACITY! So all I'm doing is affecting the 'opacity' of the texture, not the alpha channel... D'oh! < color is a dword: 0x00(red) 00(green) 00(blue) 00(opacity) > When the program with the above code is executed, a pic of a little ghost appears over a background, where it fades from 'black' to 'ghost texture' and repeats... But I want it to fade from totally transparent to totally opaque. :( What the above code does (from opaque to... black?): http://www.nagusmaps.com/hotlinx/d3d_probs/start.jpg http://www.nagusmaps.com/hotlinx/d3d_probs/color_1.jpg http://www.nagusmaps.com/hotlinx/d3d_probs/color_3.jpg What I want (done in PaintShop Pro)(from opaque to transparent): http://www.nagusmaps.com/hotlinx/d3d_probs/start.jpg http://www.nagusmaps.com/hotlinx/d3d_probs/fade_1.jpg http://www.nagusmaps.com/hotlinx/d3d_probs/finish.jpg I tried to find what I could to change the texture's alpha opacity but had absolutely no luck... I think my above function would work if I knew where to find and change the alpha info, 'cause I'd just replace the above 'color fade' stuff to 'alpha fade'. Do any of you know where the 'alpha opacity' info is stored? I'm sure it's really simple, but I'm still quite the newbie so I'm not sure where to find it. Thanks in advance for the help! :)
  8. Yippee, I got it to work! It had to do with the order of which I had the vertices... Direct3D is picky, picky, picky. Thanks for the help! Maybe I'll have a slightly more challenging question another time. ;)
  9. Thanks for the response, PlausiblyDamp. I gave your idea a shot and it compiled fine, but I still only get a blue Direct3d screen (no quad). Gads, I wish I could figure this thing out. It's frustratin'! Here's a link to the code (zipped 91k), if you want to d/l it and see why it's doing what it is (or isn't). It's the Vertices tut that Microsoft provides with the DirectX sdk, and it already has my edits in it. Just download it and extract it into its own folder, then startup 'Vertices.vcproj' in VisualC++.net: Quad don't work Thanks again!
  10. Oh boy! An active DirectX forum! :D Hello, all. I'm a seriously newbie DirectX coder (using Visual C++ .net), and I'm probably going to ask some ridiculously simple questions every now and then (ya can pick on me, but please don't bash me for not knowing anything). Here's my dilemma: First off, I don't know much of anything about DirectX programming. So far, I can kickstart DirectX in windowed and fullscreen at a set resolution and color mode (oooooh, impressive). I've played around with Microsoft's tutorials to see how to do the basics, and it seemed easy enough. But I've spent a couple of days trying to modify this tutorial to get it to render a 'quad' (square) instead of a 'triangle'. Here's what I've done to it, but it doesn't work: I changed this: // Initialize three vertices for rendering a triangle CUSTOMVERTEX vertices[] = { { 150.0f, 50.0f, 0.5f, 1.0f, 0xffff0000, }, // x, y, z, rhw, color { 250.0f, 250.0f, 0.5f, 1.0f, 0xff00ff00, }, { 50.0f, 250.0f, 0.5f, 1.0f, 0xff00ffff, }, }; to this (added an extra vertex, arranged coords to reflect a square instead of a triangle): // Initialize three vertices for rendering a triangle CUSTOMVERTEX vertices[] = { { 50.0f, 50.0f, 0.5f, 1.0f, 0xffff0000, }, // x, y, z, rhw, color { 50.0f, 250.0f, 0.5f, 1.0f, 0xff00ff00, }, { 250.0f, 50.0f, 0.5f, 1.0f, 0xff00ffff, }, { 250.0f, 250.0f, 0.5f, 1.0f, 0xff00ffff, }, }; Then, I changed this: if( FAILED( g_pd3dDevice->CreateVertexBuffer( 3*sizeof(CUSTOMVERTEX), 0, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &g_pVB, NULL ) ) ) to this (increased buffer size to take into account the extra vertex): if( FAILED( g_pd3dDevice->CreateVertexBuffer( 2*3*sizeof(CUSTOMVERTEX), 0, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &g_pVB, NULL ) ) ) Finally, I changed this: g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, 1 ); to this (make a triangle strip instead of a triangle list, and make two polys): g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 ); That shoulda defined 4 vertices, put 'em into the vertex buffer, and then rendered 'em as a 'triangle strip' instead of a 'triangle list'. But when the program's run, it only shows a blue screen (the initialized DirectX screen's background color). When I look at the code it looks like it should work, so I can't figure out where the problem's at... I'm sure it's something really simple, but what am I doing wrong or omitting that's keeping this code from rendering a quad? :confused: Thanks in advance for the help!
×
×
  • Create New...