Jump to content
  • Advertisement

Hydrael

Member
  • Content Count

    200
  • Joined

  • Last visited

Community Reputation

205 Neutral

About Hydrael

  • Rank
    Member
  1. Hydrael

    SDL_net losing sent packets

    Ah, ok - then i "just" need to enhance my packet reconstruction factory a bit. This class already takes a binary stream and reconstructs a network packet from the first 4 bytes. It just needs to be able to create an array of packets from a single stream. Thanks a lot!
  2. Hello everyone, I'm currently using SDL_net for a little casual game which uses multiple clients, which is why I have to use socketsets. I now have the problem, that in cases where I send several packets quickly one after another from the client, the receiving server seems to be missing some packets. Here is my "receive code": void CGameServer::ListenTcpPackets() { TRACELOGGER.Enter("CGameServer::ListenTcpPackets"); try { cnt = SDLNet_CheckSockets(mSocketSetConnected, 5); if ( cnt > 0 ) { for ( ConnectedPlayersType::iterator it = mConnectedPlayers.begin(); it != mConnectedPlayers.end(); it++ ) { TCPsocket s = (*it).get()->tcpSocket; while ( SDLNet_SocketReady(s) ) this->ReceiveTCP(s); } } } catch(...) { TRACELOGGER.LeaveBad("CGameServer::ListenTcpPackets"); throw; } TRACELOGGER.LeaveGood("CGameServer::ListenTcpPackets"); } // ListenTcpPackets This is the ReceiveTCP() part: common::CNetworkPacket::ptrType CTcpReceiver::ReceiveTCP(const TCPsocket& socket, bool highPriority, bool autoPushBack) { TRACELOGGER.Enter("CTcpReceiver::ReceiveTCP"); // ENTER CRITICAL SECTION SDL_LockMutex(mTcpQueueMutex); mIsReceiving = true; common::CNetworkPacket::ptrType packet = networking::tcp::ReceivePacketTCP(socket, mTcpBuffer); if ( common::CNetworkPacket::ptrType() != packet ) { DEBUGLOGGER.Log("CTcpReceiver::ReceiveTCP: Received TCP packet"); if ( autoPushBack ) this->PushTCPQueue(S_QueueEntry(packet, socket), highPriority ); } mIsReceiving = false; SDL_UnlockMutex(mTcpQueueMutex); // LEAVE CRITICAL SECTION TRACELOGGER.LeaveGood("CTcpReceiver::ReceiveTCP"); return packet; } // ReceiveTCP And here is ReceivePacketTCP(): networking::common::CNetworkPacket::ptrType ReceivePacketTCP(const TCPsocket& socket, char* pBuffer) { TRACELOGGER.Enter("ReceivePacketTCP"); int recvLen = SDLNet_TCP_Recv(socket, pBuffer, TCP_PACKET_SIZE); if ( recvLen > 0 ) { networking::common::CNetworkPacket::ptrType packet = networking::common::CPacketDataFactory::Reconstruct((char*)pBuffer, recvLen); TRACELOGGER.LeaveGood("ReceivePacketTCP"); return packet; } TRACELOGGER.LeaveBad("ReceivePacketTCP (nothing received)"); return networking::common::CNetworkPacket::ptrType(); } To explain my problem again on this given code - following happens: The client tries to connect to the server. If the connection succeeds, the server responds with an "Connection accepted" packet. The client then sends a "RegisterPlayer" packet, and receives a packet with his assigned player id. Using that id the client can then join a game. The network packets within this joining a game process are sent back and forth pretty fast. Now in most cases the server does not receive the "join game" packet. It simply does not arrive, even though the client sent it. My question now is: What happens, when I sent packets faster, that I receive them? Does SDL_net somehow buffer the packets in some sort of fifo queue? Because that is what I would except. Thanks a lot for any help in advance! Greetings, Chris
  3. Ok, problem solved. Thanks to sirob over at the IRC ;) The memcpy was buggy...you shouldn't be indexing floats if you are measuring in bytes. Changed float *pV=(float*)pMessage->pVertices; to char *pV=(char*)pMessage->pVertices; and it worked. Now I better go grab my C++ for Dummies book again ;)
  4. Hey there, for my current project I want to use DirectX in combination with Newton Game Dynamics. One problem I now have really confuses me. I load a bunch of X meshes via D3DXLoadMeshFromX. From those meshes I need to create an exact collision model for Newton to use. That means, I need to access index and vertex buffers for each mesh and recreate the whole mesh in memory. That's where I encountered some...let's call it anomalies ;) For example: One of the X files I load consists of 160 faces based on 220 vertices. pMesh->GetNumFaces() gives me 160 faces, which is correct. pMesh->GetNumVertices() though gives me a result of 228, which is wrong. At first I thought, that DX maybe somehow rearranges a loaded mesh, but that is not the case, since trying to read vertex 221 gives me an access violation - that seems to me like index and vertexbuffer do not match. Here is my relevant code in a nutshell: Loading the mesh: HRESULT rc=D3DXLoadMeshFromX(pObj->ModelPath, D3DXMESH_VB_SYSTEMMEM, DX.GetD3DDevice(), NULL, &pObj->MeshData.MaterialBuffer, NULL, &pObj->MeshData.MaterialCount, &pObj->MeshData.Mesh); Locking the buffers: if(FAILED(pMesh->Mesh->GetVertexBuffer(&*pVB))) return false; if(FAILED(pMesh->Mesh->GetIndexBuffer(&*pIB))) return false; if(FAILED(pVB[0]->Lock(0,0,(VOID**)pVertices,D3DLOCK_READONLY ))) return false; if(FAILED(pIB[0]->Lock(0,0,(VOID**)pIndices,D3DLOCK_READONLY ))) { pVB[0]->Unlock(); return false; } Trying to read the buffers: DXVector Face[3]; float *pV=(float*)pMessage->pVertices; WORD *pI=(WORD*)pMessage->pIndices; DWORD vSize=pMessage->SizePerVertex; for(int i=0;i<pMessage->FaceCount;i++) { WORD ind0=pI[i*3]; WORD ind1=pI[i*3+1]; WORD ind2=pI[i*3+2]; memcpy(&Face[0],pV+(ind0*vSize),sizeof(float)*3); memcpy(&Face[1],pV+(ind1*vSize),sizeof(float)*3); memcpy(&Face[2],pV+(ind2*vSize),sizeof(float)*3); NewtonTreeCollisionAddFace(pCollision[0],3,(float*)Face,sizeof(float)*3,NULL); } The last piece of code will give me an access violation at iteration 11, since ind2 will be 221 with only 220 vertices being. When I look at the loaded X file the correct index at iteration 11 should be 80, and not 221. Can anyone help? Thanks in advance Greets Chris [Edited by - Hydrael on September 2, 2007 3:10:44 PM]
  5. Hydrael

    Lightmaps and Smooth Shadows

    Hey there, did you ever have a look at Gile[s]? If not, give it a try. It's a very nice program, that gives very good results - at least I'm sadisfied with it ;) Greets Chris
  6. Hydrael

    how to use the shader in the program?

    For GLSL: http://www.lighthouse3d.com/opengl/glsl/
  7. Hydrael

    Some coding problems on GL

    There actually is no "rule". GL_TEXTUREi just identifies the texture stage you wish to work with (GL_TEXTURE0 - GL_TEXTURE7).
  8. Hydrael

    Some coding problems on GL

    If you want to use multitexturing, glActiveTexture is one of the functions you will need. It tells, what texture stage (0-7) you want to use for enabling/disabling texturing, or binding textures. You could look at this neighbour thread for a practical example
  9. Hydrael

    mapping 2 textures to 1 object

    Yes, I figure Mars is right - bind your two textures like he posted, and it should work ;) There is another thing you should correct though: Between the rendering of your first (multitextured quad), and the second one, you have following calls: glActiveTextureARB (GL_TEXTURE0_ARB); glDisable(GL_TEXTURE_2D); glActiveTextureARB (GL_TEXTURE1_ARB); glDisable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texWood); Anyone please correct me, if I'm wrong, but from my understanding you still remain in texture stage 1 after disabling texturing for stage 1. It should look like this: glActiveTextureARB (GL_TEXTURE1_ARB); glDisable(GL_TEXTURE_2D); //Disable texturing for stage 1 - leave stage 0 enabled glActiveTextureARB (GL_TEXTURE0_ARB); //switch back to stage 0 glBindTexture(GL_TEXTURE_2D, texWood); //bind your next texture
  10. Hydrael

    mapping 2 textures to 1 object

    You need to use those brackets for sourcecodes: [] ;) I'll take a look at your code tomorrow.
  11. Hydrael

    mapping 2 textures to 1 object

    You need to enable GL_TEXTURE_2D for every multitexturing stage. i.e.: glActiveTextureARB (GL_TEXTURE0_ARB); glEnable(GL_TEXTURE_2D); glActiveTextureARB (GL_TEXTURE1_ARB); glEnable(GL_TEXTURE_2D); ... Render your stuff ... glActiveTextureARB (GL_TEXTURE0_ARB); glDisable(GL_TEXTURE_2D); glActiveTextureARB (GL_TEXTURE1_ARB); glDisable(GL_TEXTURE_2D);
  12. Hydrael

    mapping 2 textures to 1 object

    Oops, sorry - my fault. Those two function pointers of course need to be initialized, which works like this: glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC) wglGetProcAddress("glActiveTextureARB"); glMultiTexCoord2fARB = (PFNGLMULTITEXCOORD2FARBPROC) wglGetProcAddress("glMultiTexCoord2fARB");
  13. Hydrael

    mapping 2 textures to 1 object

    typedef void (APIENTRY * PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); typedef void (APIENTRY * PFNGLACTIVETEXTUREARBPROC) (GLenum target); PFNGLMULTITEXCOORD2FARBPROC glMultiTexCoord2fARB; PFNGLACTIVETEXTUREARBPROC glActiveTextureARB; Regarding "Load_GL_ARB_multitexture": That seems to be some kind of custom function
  14. Hydrael

    Color problem

    Try glColor3f(1.0f,1.0f,1.0f) before you render your quad
  15. Hydrael

    mapping 2 textures to 1 object

    You need the glext.h header file
  • 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!