Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

187 Neutral

About TheResolute

  • Rank
  1. TheResolute

    Constant buffer not working

    Thank you for your help, I realized that I never called PSSetConstantBuffers(), so I fixed that and now everything is fine
  2. I am using a constant buffer to transfer data to my pixel shader The problem is that the buffer contains 0s in the shader during runtime for x, y, z, and w of the float4 member, regardless of what data is updated to the buffer Structure definitions are as follows:   // (C++) struct Buffer {     XMMATRIX mvp_;     XMFLOAT4 rgba_;     int usemvp_; }; // HLSL cbuffer Buffer : register( b0 ) {     matrix mvp_;     float4 rgba_;     int usemvp_; };      Any help is much appreciated
  3. Thank you for these clarifications so far, and I would like to note that I asked this exact question on Stack Overflow and watched it be mocked and closed within minutes. Kudos to the GameDev.net community!
  4. I see a lot of comments about how writing code in something like C# is faster than C++, and I fail to understand why. This has nothing to do with performance of applications; simply the difference in taking say 3 weeks to develop in a certain language and 6 in another. Also, I am really just concerned with mainstream languages such as C#, C++, VB, Java, Lua, Python, etc. Is it just about compile time, which seems to be the reason that developing in a scripting language is faster than a compiled one? Does it have to do with memory management and garbage collection, because it just takes forever to remember to delete your pointers? Possibly it involves inherent access to libraries or functions such as the printf("") in Python as compared to cout << "" in C++, is that the case? Basically, I am trying to understand why the general consensus seems to be that writing code in C# (for example) is better than writing code in C++ (for example), but the performance of that running code is worse.
  5. TheResolute

    Enemy shooting

    You must have misread the code or I made a mistake, but it is not accessing the array using the random number as an index, it is iterating through the array and every time an enemy is alive, it decrements its counter and if the counter is zero, meaning that this enemy is the nth living one, it will then have it shoot
  6. TheResolute

    Enemy shooting

    EngineProgrammer provided a nice solution Something far more simple would be to: keep track of how many enemies are alive (variable initialized with number of enemies and decremented each time one dies); using the same process he described to do this at certain intervals: generate a random number using the number of living enemies as your cap, and iterate through your enemies array, skipping dead ones, while decrementing the random number, and have the enemy shoot when your random number is 0 Hope that makes sense Some pseudo code could help: int totalEnemies = 30; int livingEnemies = totalEnemies; Enemy[30] enemies; // in code region dealing with enemy death livingEnemies--; // // on iterval for enemy to shoot if(livingEnemies > 0) { int randNum = Math.Rand(0, livingEnemies); // generates a random integer between bounds, lower exclusive, upper inclusive for(int i = 0; i < totalEnemies; i++) { if(enemies.isAlive) { randNum--; if(randNum == 0) { // Enemy shoots } } } } //
  7. TheResolute

    XNA Frame animation problem

    Please include some more detail about your problem to be clear However, I will attempt to help at this point based on what I think is happening If your sprite normally moves around by player input or AI or something like that, all you would have to do is: add a isPlayingAnimation variable to your code an relate it to your sprite somehow; add a statement to the code that begins an animation to set that variable to true; and include a condition in its movement code that checks whether it is playing an animation, and doesn't execute movement if it is Another thing that occurred to me is that your is constantly on an animation loop, and you want to stop it during a certain part of that animation; in that case, you would add a counter to its movement code that increments every frame, is reset when the animation restarts, and then a condition to the code that prevents movement when the counter is in a certain range Hopefully you will find at least some of that helpful
  8. TheResolute

    What do you make of it?

    It really depends on what level of "computer gaming creation" you are interested in Being able to make your ideas a reality can be fairly straightforward, depending on how complex they are, here are a few options: Downloading a copy of GameMaker (you will probably want the Lite version, it's free) and tinkering with that. It will produce 2D games only and has a graphical user interface, as well some scripting capacity, which you can but likely will not need to take advantage of. This is the best option in, in my opinion, to create games quickly and easily Acquiring a more powerful engine like Unity you mentioned. This would allow you to create 3D games but requires more time and energy to learn and use Learning a programming language like Python and finding some sort of graphics library to use with it (I believe Python has one built in or at least readily available). This will require a significant amount of effort to do a limited amount of creating. Although it will give you the most power and control over your games, and you may prefer if you don't like dealing with the user interfaces of the graphical environments However; if you want a career in the industry, then you have a much more complicated process ahead of you that will probably involve some college In that case, you should acquaint yourself with programming by learning a simpler language like Python, and then learn C++ probably followed by DirectX or OpenGL For this point, I am not really certain about my suggestions so you should consult other sources
  9. TheResolute

    Texture replaced when rendered to

    [color=#000000][font=Arial,] Turns out, and you'll notice this with those code samples, that I (in my infinite incompetence) do not set the correct vertex shader or buffer for drawing the entire texture2d to the back buffer[/font][color=#000000][font=Arial,] So, it used the last set vertex buffer (the one used to to draw the last thing rendered to the texture XD ) when it rendered the texture to the back buffer. This created the effect that I believed to be the texture2d being replaced by whatever was rendered to it[/font][color=#000000][font=Arial,] There you have it, just some silly little semantic error[/font][color=#000000][font=Arial,] Thank you all for trying to help[/font]
  10. TheResolute

    Texture replaced when rendered to

    That PIX piece is an excellent suggestion I'll have to figure that out and it might just be awesome so thank you
  11. TheResolute

    Texture replaced when rendered to

    Here's the setup: // Lighting ZeroMemory( &blendDesc, sizeof( blendDesc ) ); blendDesc.RenderTarget[0].BlendEnable = TRUE; blendDesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD; blendDesc.RenderTarget[0].SrcBlend = D3D11_BLEND_DEST_COLOR; blendDesc.RenderTarget[0].DestBlend = D3D11_BLEND_ZERO; blendDesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD; blendDesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE; blendDesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO; blendDesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; d3dDevice_->CreateBlendState( &blendDesc, &lightingBlendState_ ); float blendFactor[4] = { 0.0f, 0.0f, 0.0f, 0.0f }; // Light map and render target view DXGI_SAMPLE_DESC sampleDesc = { 1, 0 }; D3D11_TEXTURE2D_DESC texDesc = { 1024, 768, 1, 1, DXGI_FORMAT_R32G32B32A32_FLOAT, sampleDesc, D3D11_USAGE_DEFAULT, D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE, NULL, NULL }; d3dDevice_->CreateTexture2D( &texDesc, NULL, ( ID3D11Texture2D** )&lightMap_ ); D3D11_RENDER_TARGET_VIEW_DESC renderDesc = { DXGI_FORMAT_R32G32B32A32_FLOAT, D3D11_RTV_DIMENSION_TEXTURE2D, { 0 }, }; d3dDevice_->CreateRenderTargetView( lightMap_, &renderDesc, &lightMapTarget_ ); D3D11_SHADER_RESOURCE_VIEW_DESC resourceDesc = { DXGI_FORMAT_R32G32B32A32_FLOAT, D3D11_SRV_DIMENSION_TEXTURE2D, 0, 1 }; d3dDevice_->CreateShaderResourceView( lightMap_, &resourceDesc, &lightMapResource_ ); And here's the render: d3dContext_->OMSetRenderTargets( 1, &lightMapTarget_, NULL ); colorMap = dxiSprites_[kBlackSprite].GetShaderResourceView( ); d3dContext_->PSSetShaderResources( 0, 1, &colorMap ); spritePtr = 0; HRESULT d3dResult = d3dContext_->Map( vertexBufferText_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapResource ); spritePtr = ( VertexPos* )mapResource.pData; spritePtr[0].pos = XMFLOAT3( 1, -1, 0 ); spritePtr[1].pos = XMFLOAT3( -1, -1, 0 ); spritePtr[2].pos = XMFLOAT3( -1, 1, 0 ); spritePtr[3].pos = XMFLOAT3( -1, 1, 0 ); spritePtr[4].pos = XMFLOAT3( 1, 1, 0 ); spritePtr[5].pos = XMFLOAT3( 1, -1, 0 ); spritePtr[0].tex0 = XMFLOAT2( 1, 0 ); spritePtr[1].tex0 = XMFLOAT2( 0, 0 ); spritePtr[2].tex0 = XMFLOAT2( 0, 1 ); spritePtr[3].tex0 = XMFLOAT2( 0, 1 ); spritePtr[4].tex0 = XMFLOAT2( 1, 1 ); spritePtr[5].tex0 = XMFLOAT2( 1, 0 ); d3dContext_->Unmap( vertexBufferText_, 0 ); d3dContext_->Draw( 6, 0 ); stride = sizeof( VertexPos ); offset = 0; d3dContext_->IASetInputLayout( inputLayout_ ); d3dContext_->IASetPrimitiveTopology( D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST ); d3dContext_->VSSetShader( solidColorVS_, 0, 0 ); d3dContext_->PSSetShader( solidColorPS_, 0, 0 ); d3dContext_->PSSetSamplers( 0, 1, &colorMapSampler_ ); for( int i = kNumberOfSprites; i < kNumberOfLights + kNumberOfSprites; i++ ) { ID3D11Buffer* vertexBuffer = dxiSprites_.GetVertexBuffer( ); ID3D11ShaderResourceView* colorMap = dxiSprites_.GetShaderResourceView( ); d3dContext_->IASetVertexBuffers( 0, 1, &vertexBuffer, &stride, &offset ); d3dContext_->PSSetShaderResources( 0, 1, &colorMap ); if( i == kDarknessLight ) { XMFLOAT2 pos = XMFLOAT2( 0.0f, 0.0f ); XMMATRIX world = dxiSprites_.CreateAWorldMatrix( pos, ( 360.0f - 0 ) * 0.0174532925f, XMFLOAT2( 1, 1 ) ); XMMATRIX mvp = XMMatrixMultiply( world, vpMatrix_ ); mvp = XMMatrixMultiply( mvp, XMMatrixTranslation( 512 / ( kWindowWidth / 2 ), 384 / ( kWindowHeight / 2 ), 0.0f ) ); mvp = XMMatrixTranspose( mvp ); d3dContext_->UpdateSubresource( mvpCB_, 0, 0, &mvp, 0, 0 ); d3dContext_->VSSetConstantBuffers( 0, 1, &mvpCB_ ); d3dContext_->Draw( 6, 0 ); } for( int j = 0; j < drawData->spriteDataLength; j++ ) { if( drawData->spriteData[j].index == kFlagshipSprite ) { XMFLOAT2 pos = XMFLOAT2( 0.0f, 0.0f ); XMMATRIX world = dxiSprites_.CreateAWorldMatrix( pos, ( 360.0f - drawData->spriteData[j].rotation ) * 0.0174532925f, drawData->spriteData[j].scale ); XMMATRIX mvp = XMMatrixMultiply( world, vpMatrix_ ); mvp = XMMatrixMultiply( mvp, XMMatrixTranslation( drawData->spriteData[j].position.x / ( kWindowWidth / 2 ), drawData->spriteData[j].position.y / ( kWindowHeight / 2 ), 0.0f ) ); mvp = XMMatrixTranspose( mvp ); d3dContext_->UpdateSubresource( mvpCB_, 0, 0, &mvp, 0, 0 ); d3dContext_->VSSetConstantBuffers( 0, 1, &mvpCB_ ); d3dContext_->Draw( 6, 0 ); } } } d3dContext_->OMSetRenderTargets( 1, &backBufferTarget_, NULL ); d3dContext_->OMSetBlendState( lightingBlendState_, blendfactor, 0xFFFFFFFF ); d3dContext_->PSSetShaderResources( 0, 1, &lightMapResource_ ); d3dContext_->Draw( 6, 0 ); The first chunk of that fills the texture with darkness (black) Then the second bit draws all the lighting sprites (usually white circles), and a darkness sprite Darkness is drawn twice for debugging reasons, indicating that regardless of what's in the texture, it's replaced when a new Draw call is made And the last piece draws the texture to the existing rendered frame with the correct blend state Thanks in advance for any help
  12. TheResolute

    Texture replaced when rendered to

    Any help at all would be greatly appreciated
  13. TheResolute

    Alternative Controls

    You would need to have some type of hardware device capable of that in the first place, which is by far the most challenging aspect of your design If you are unable to find such a device you might be able to substitute a microphone, which has been done to detect the player blowing on something It would probably be supported by DirectX if it did exist, in which case you could check out the documentation as to how to collect input from it The process is not terribly complicated, as you can see here: http://msdn.microsoft.com/en-us/library/windows/desktop/ee416842(v=vs.85).aspx
  14. Hello there, I have a 2D lighting engine that renders the game scene to the back buffer, renders the lighting map to a texture, and then renders the texture to the back buffer with a blend state The issue I'm encountering is that every time I make a Draw call when rendering a light to be added to the light map, it completely replaces all data in the texture including its width and height For example, let's say I make Draw call that will fill the entire light map texture with black, when I make another Draw call to render a light sprite to the texture, the entire texture is replaced by that single sprite and it also resizes as well There is the possibly that this is not actually what is occurring, but all evidence from a fair amount of testing indicates this What I'd like to do is render my lighting sprites to my light map texture just like I would render my object sprites to the back buffer, in that each successive Draw call only adds the new sprite on top of whatever else was there and only replaces certain pixels I do not believe this is a blend state issue because I use the same one for rendering to the back buffer and the light map, and the back buffer rendering works just fine Please provide an explanation as to what is going on and how to make this process function as I've described Thanks
  15. TheResolute

    2D lighting through blend states

    Microsoft did not document certain aspects of DirectX very well, apparently this was one of them That is an absolutely brilliant explanation, it made a world of difference And no one else offered it, not the DX documentation or even a Google search for "D3D11 blend state" I am good to go now, knowing that tiny piece that the blend state multiplies those things by their corresponding assignments I was under the impression that those BlendSrc and BlendDest values were the data themselves XD Thank you so much for you help, I really appreciate it
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!