Jump to content
  • Advertisement

pindrought

Member
  • Content Count

    18
  • Joined

  • Last visited

Community Reputation

112 Neutral

About pindrought

  • Rank
    Member

Personal Information

  • Interests
    Programming

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. pindrought

    Point light question

    One thing to note... output.normal = mul(input.normal, matWorld); Be careful about this. You want to exclude the translation component of your matWorld matrix. You can do this by converting it to a matrix that omits the translation component, or alternatively, you can cast the normal as a float4 with a 0 for the w component. Ex. output.normal = mul(float4(input.normal,0.0f), matWorld);
  2. pindrought

    Draw just to get stencil buffer updated

    Thanks all of you! Amazing suggestions! I did not even consider either of these options.
  3. Is there an easy way to draw to just update the stencil buffer, but not actually draw the object? I was thinking I could make a blend state that allows transparency and pass the object through a pixel shader that returns pixels with alphas of 0, but I was wondering if there was a better/more efficient approach. For reference, I'm trying to make a silhouette effect where i'll draw the shaded smaller area first, and then the larger visible area after and using the stencil buffer to clip out all of the pixels inside the silhouette. Thanks
  4. pindrought

    Issues with RakNet and public IP

    From my experience, when I was testing using a port checker, it would say CLOSED unless I had my server running and actively listening for new connections. When my server was not running, it would show CLOSED. When my server was running, it would show OPEN. I hope this helps.
  5. pindrought

    Issues with RakNet and public IP

    Did you open your port in your router settings? ETA: I've never used RakNet just a suggestion.
  6. Recently I purchased a set of audio files to use in a project of mine. They follow a license described as the "Pro License" at gamedevmarket. If I choose to use these tracks in my game, am I allowed to just ship the files in a normal sound format in a data folder, or am I required to have them in some encrypted format to make it more difficult to extract the audio contents from the game files? Thanks!
  7. Thank you so much! What you've said makes a lot of sense. I've written basic servers using nonblocking sockets over select before, but getting into IOCP is a big jump for me. I'm going to apply your advice and I think I have a good idea of what direction to take now.
  8. Hey everybody. I have been having some issues learning IOCP and I was hoping someone here might understand it well enough to help me out. I'm currently trying to learn the basics of utilizing IOCP from this code sample. Note: This sample is not using AcceptEx but will look into that later. https://github.com/Microsoft/Windows-classic-samples/tree/master/Samples/Win7Samples/netds/winsock/iocp/server This is an echo iocp server from Microsoft. There are a couple things I am confused about. When a new connection is accepted, a WSARecv is called and the overlapped structure is passed in. From what I gathered, for this particular code, in one of the worker thread's, the Worker Thread Function will be able to then receive the data from this WSARecv call via the call to GetQueuedCompletionStatus. From the Worker Thread Function, it looks like this server follows the following pattern per connection: 1. Check if there is a pending io operation for some connection 2. If pending io operation is a read operation, store the size/buffer in the overlapped context and queue up a WSASend call as a write operation using the overlapped structure. 3. If pending io operation is write operation, check if the # of bytes matched the total bytes. If all bytes were sent, update the overlapped structure and queue up WSARecv for next read operation. If not all bytes sent, queue up another WSASend to attempt to send the remaining bytes. So it seems like the pattern is this server attempts to read data, then will echo that data back and once that data is echo'ed back, the server will read data again. Here is where I am confused. How would I handle the following situations: In this situation, I want the server to continue performing as an echo server. On top of its current functionality, I want it to also dispatch a 4 byte message every X seconds. In this situation, I want the server to echo all of the client's messages to the other clients as well. So if client #1 sends 'AABB', the server will send 'AABB' to client #1 and the server will send 'AABB' to client #2. Let me explain why I am stuck on these situations. For situation #1, The server is not guaranteed to send the full packet when echo'ing data back to the client. How would I guarantee that the server will echo back the full packet before dispatching the 4 byte message? I considered having a queue or something tied to the socket context, but I am also wondering about how would I send the 4 byte data if the client never sent anything to be echo'd? Will it be an issue if I have queued up a WSARecv on the socket, no data has been received, and I queue up a WSASend at the same time? Also, the call to WSASend to dispatch this 4 byte data will cause an extra call to WSARecv after the data is sent. How should this be avoided since there will already be an outstanding WSARecv from the server listening for packets to echo. For situation #2, my confusion again comes across verifying that the packets will be sent in the correct order and not split up in case of partial sends and a similar confusion about if this new call to WSASend will cause an extra call to WSARecv after the data is sent. Sorry the post is so long. I tried to include hyperlinks to the code in question to clarify what I am asking. Thank you so much for any input.
  9. I wanted to get some opinions on how to go about serializing floats. Some people i've talked to have said to just assume that everyone is using the IEEE754 standard and just memcpy to bytes, but I didn't know how safe this was to just assume that the byte layout is the same especially between different operating systems such as Linux->Windows. I had read this post https://stackoverflow.com/questions/3418319/serialize-double-and-float-with-c and I saw a lot of different suggestions on how to go about serializing floats. Do you all have any suggestions on the best route to go about serializing floats? Also, while we are on the topic, I am wondering the same about serializing doubles. Note: I realize I could just convert them to strings already, but i'm specifically asking for methods that are not just converting everything to strings and sending it over.
  10. I had assumed you were using Windows. If you're not using windows, i'm not sure what the approach would be. If you are using windows, and you create a 800x600 window for example, the window will be 800x600 INCLUDING THE BORDER. Your actual content of the window will be less though. This is what the AdjustWindowRect function is for - to adjust the window so that the actual rendering area matches the dimensions due to the borders or other window styles throwing it off. If you are not using windows, I am not sure what the solution may be.
  11. Suliman, can you post the code you're using to create your window? It sounds like you are forgetting to call AdjustWindowRect on your window rect with the appropriate create flags before creating the window.
  12. I'd also like to suggest using a template for your constant buffers as you'll end up having multiple cbuffers whether due to multiple shaders, different update intervals, etc. Note: The following code is for DirectX 11. I don't remember where I had found this resource from, but I use something like this #ifndef ConstantBuffer_h__ #define ConstantBuffer_h__ #include <d3d11.h> #include <wrl/client.h> template<class T> class ConstantBuffer { private: ConstantBuffer(const ConstantBuffer<T>& rhs); private: Microsoft::WRL::ComPtr<ID3D11Buffer> buffer; bool mInitialized; public: ConstantBuffer() {} T Data; ID3D11Buffer* Buffer()const { return buffer.Get(); } HRESULT Initialize(Microsoft::WRL::ComPtr<ID3D11Device> &device) { HRESULT hr = S_OK; D3D11_BUFFER_DESC desc; desc.Usage = D3D11_USAGE_DYNAMIC; desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; desc.MiscFlags = 0; desc.ByteWidth = static_cast<UINT>(sizeof(T) + (16 - (sizeof(T) % 16))); desc.StructureByteStride = 0; hr = device->CreateBuffer(&desc, 0, buffer.GetAddressOf()); mInitialized = true; return hr; } void ApplyChanges(Microsoft::WRL::ComPtr<ID3D11DeviceContext> &dc) { D3D11_MAPPED_SUBRESOURCE mappedResource; HRESULT hr = dc->Map(buffer.Get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource); CopyMemory(mappedResource.pData, &Data, sizeof(T)); dc->Unmap(buffer.Get(), 0); } }; #endif // ConstantBuffer_h__ Then I could define a structure for my cbuffer layout like this (In this example this is a constant buffer for my vertex shader for my 2d UI elements struct CB_VS_UI { XMFLOAT4 position; }; In my graphics class, I am declaring the constant buffer of this type with ConstantBuffer<CB_VS_UI> cb_vs_ui; To initialize this constant buffer, I am doing //create constant buffer for ui elements HRESULT hr = this->cb_vs_ui.Initialize(this->d3d11Device); //<--Pass in the ComPtr<ID3D11Device> if (hr != S_OK) { LogError("Failed Initialize Constant Buffer for UI Elements Vertex Shader. Error Code: " + std::to_string(hr)); return false; } Then, before the Draw call, I am updating the constant buffer with this (note d3d11DeviceContext is type ComPtr<ID3D11DeviceContext> ) //constant buffer for ui vertex shader this->cb_vs_ui.Data.position.x = xPosition; this->cb_vs_ui.Data.position.y = yPosition; this->cb_vs_ui.Data.position.z = 0; this->cb_vs_ui.Data.position.w = 0; auto vsbuffer = this->cb_vs_ui.Buffer(); this->d3d11DeviceContext->VSSetConstantBuffers(0, 1, &vsbuffer); //set the constant buffer for the vertex shader this->cb_vs_ui.ApplyChanges(this->d3d11DeviceContext); For reference, here is the basic vertex shader I am using for this example. cbuffer cbPerUI : register(b0) { float4 uipos; }; struct UI_VS_OUTPUT //output structure for skymap vertex shader { float4 Pos : SV_POSITION; float2 texCoord : TEXCOORD; }; UI_VS_OUTPUT main(float4 inPos : POSITION, float2 inTexCoord : TEXCOORD) { UI_VS_OUTPUT output; output.Pos = inPos.xyzz + uipos; output.texCoord = inTexCoord; return output; } Sorry for wall of text, just trying to put some info out there that might be helpful. Hopefully I didn't forget to include anything.
  13. Thank you everybody for your responses. It looks like it may have had something to do with the tip of the grass tris being past the far z plane. I increased the far z plane from 1000 to 2000 and I did not see the issue anymore. Thanks everybody for your help!
  14. I'm not sure what the correct terminology is to describe what is happening. In the following video, you will see that the grass quad has one of the tris glitching out towards the end in the far distance. YOUTUBE VIDEO DEMO Anyone know what might be causing this? Here is a link to the github if it helps. The actual drawing is done in the Graphics.cpp RenderFrame function GITHUB LINK (set project to x86 to run or go into the libs folder and extract the x64 archives to run as x64) Edited to Add: To move camera use WASD / Space / Z
  15. Thank you so much! This is exactly what I needed. I didn't even think about all of the states being modified by the Spritebatch.
  • 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!