Jump to content
  • Advertisement

slideside12

Member
  • Content Count

    14
  • Joined

  • Last visited

Community Reputation

195 Neutral

About slideside12

  • Rank
    Member
  1. slideside12

    SDL2 shader usage

      I know SDL2 itself does not have shader abstraction. Like I said I don't have a problem learning openGL to implement shader but I would just prefer to learn it only to the extent of getting the shaders implemented but that probably won't be possible from what I've seen. Also I'd prefer to stay low level so I might just have to learn openGL after all in order to get what I want done. Not sure if there is maybe a library I could use. Anyways thanks for your help. Might look at SFML as I've seen it a couple of times.
  2. slideside12

    SDL2 shader usage

    Thanks for the fast reply.   And I get what you're saying. Honestly I want to use shaders mainly for effects and I could just premake the effects in a graphics program and just animate it but Im under the impression that this will decrease performance and lag the game. For example if I wanted a glow effect I could easily just create a "glow" sprite which would just be like a transparent brightly lit sprite and resize over the game sprite. However if I wanted to do this to lets say 100 sprites that would definitely cause lag. I really don't have a problem learning openGL but I would like to limit it to essentially where I could call a texture->applyShader("shader.frag") function but everywhere I've looked the tutorials and guides go over creating contexts and matrixes and such which is beyond the scope of what I am trying  to do.    As for the creating textures on the CPU from what I know that would disable the application of the shader effects and such correct? Like I said I want to use shaders for effects.  Thanks in advance
  3. Hey quick question. I've done a lot of searching and can't seem to find an answer so here is my problem:   I want to use SDL2 to handle all the entirety of my 2d game. This not only includes window creation, input, and audio but also rendering. The problem is I have little to no knowledge or experience with openGL. The thing is I do not want to learn openGL (especially since its a 2D game) only to learn how to integrate shaders with SDL. With the SDL hardware accelerated textures I don't see the need to learn openGL for just a 2D game. I wanted to know if there is some example code/walkthrough that can explain how to apply a shader to a SDL texture (or surface even since you can access pixel data there) essentially. Ive done a lot of searching and the basic suggestion is to learn openGL, handle rendering with openGL and then apply the shader through that. Just want to know if there a a simpler solution. Thanks in advance!   Edit: Second question: Would there really be any benefit in using openGL to render as opposed to SDL? Especially since I don't have any experience with openGL so if I were try it probably wouldn't be anything that advanced/optimized. 
  4. slideside12

    Cloud Architecture/Port problem

    Yes! Your previous quesiton was this: Your later example uses a different port per game instance.     Oh one final question. How would I go about including command line arguments when launching a game instance/process from within the main lobby?  Edit: Nevermind I figured it out. Your help is really appreciated. 
  5. slideside12

    Cloud Architecture/Port problem

      Great!     Oh ok I think there was some confusion. When I said all communication being to one port I meant for each separate match. I know if all the matches themselves are to one port the game id would be used to identify each match "in" the lobby.   Thank you very much for your help! 
  6. slideside12

    Cloud Architecture/Port problem

      Because UDP doesn't require an active connection lets say one user's ip changes while in a match. Now when he tries to send a packet to the game instance server it checks if the packets "game ID" matches it own. Is that what you're saying?     This im not quite understanding. So I can make the lobby the main manager/coordinator process. When a match has been "created" the lobby launches a new game instance server on a new port number and returns that port number to the clients. Each client creates a socket to the dns name (same for the lobby and the match server) with that port. Is the game ID idea used as a verification to allow the game instance server to verify that only those who were matched when the lobby created it will be the only ones allowed in the match? Because you said I can "match up incoming packets from players to the right game session". The only matching I would see needed would be done at the lobby. But once the lobby creates a game it shouldn't be involved again. Communication would only be between the game process and the clients at its port. 
  7. slideside12

    Cloud Architecture/Port problem

    It's not a good idea in my experience to write a process that "spawns a copy of itself when needed" -- managing when and how processes are spawned becomes hard (how do you tell all the copies to stop spawning?) Having a coordinator of some sort that spawns a new process would be simpler IMO. That might be as simple as "ssh $hostname /usr/local/bin/myserver -port 1234" run from the main management process. Using one process is fine, assuming your code doesn't use any globals. However, using one process with many sockets (and many ports) adds the complexity of managing multiple ports, without the benefit of having each match/socket be somewhat insulated from the failure of another, so it doesn't strike me as a particularly great trade-off. You may find different. I'd just have a single port/socket for a single process. Including a game instance ID in each packet, and/or deriving the intended game instance ID from the remote address you got the packet from, seems better to me.       Ahh I see. Didn't think about the fact that if I use one process and it crashes all the matches end. One port and socket for each process seems like a much better idea. The game instance ID however; why would that be necessary if both the process/server and all the clients know which port to use? I see how it would work in one big process to identify each match but if all communication is to one port then why use a Game ID? I'm not familiar with the ssh solution you suggested so I might just run a small process that can act as a main management process using C++. However I've only come across ssh a couple of times but if this can be done with a python script on the VM I may do that instead. But I would have to read up on ssh and its uses. I have a much better understanding of everything. 
  8. slideside12

    Cloud Architecture/Port problem

    A "match" is the game match. It requires that all players in the match get told about all other players in the match. A "network interface" is an abstraction of a physical network card (may be multiple cards for redundancy) and typically has one network address (may have more for various reasons.) A "process" is an operating system concept that runs an executable, and a context within which a single unit like a file descriptor or socket makes sense (may be inherited across sub-prcesses based on OS.) A match runs within a process. A process can run more than one match, if it has a way of distinguishing which match incoming packets are intended for. More than one process CAN bind sockets to the same UDP port, but this is generally a bad idea. For UDP traffic, when a packet comes in to a network interface for a particular port, any ONE of the sockets that are bound to that port will get that packet. This means that, if you have multiple processes binding to the same port through different sockets, you have no control over which process gets the data, and because matches are within a process, you can't route the apporpriate packet to the appropriate match. The solution is typically one of: 1) Use a single process, and single socket receiving on the port, but run many matches within the same process, and use data in the packet to identify the match that a particular incoming packet is meant for. 2) Use multiple processes, but bind each process to a different UDP port. Tell the match players which port to send data to to route it to the right match. In addition, option 1) probably also want to use multiple threads, to make it scale across CPU cores. Option 2) typically doesn't need that, because each process can be scheduled on a different core.       Also why can't I just use one process? Each match would be a socket with a different port. So if I had 10 matches going on there would be one process, 10 sockets and each with its own port.
  9. slideside12

    Cloud Architecture/Port problem

    A "match" is the game match. It requires that all players in the match get told about all other players in the match. A "network interface" is an abstraction of a physical network card (may be multiple cards for redundancy) and typically has one network address (may have more for various reasons.) A "process" is an operating system concept that runs an executable, and a context within which a single unit like a file descriptor or socket makes sense (may be inherited across sub-prcesses based on OS.) A match runs within a process. A process can run more than one match, if it has a way of distinguishing which match incoming packets are intended for. More than one process CAN bind sockets to the same UDP port, but this is generally a bad idea. For UDP traffic, when a packet comes in to a network interface for a particular port, any ONE of the sockets that are bound to that port will get that packet. This means that, if you have multiple processes binding to the same port through different sockets, you have no control over which process gets the data, and because matches are within a process, you can't route the apporpriate packet to the appropriate match. The solution is typically one of: 1) Use a single process, and single socket receiving on the port, but run many matches within the same process, and use data in the packet to identify the match that a particular incoming packet is meant for. 2) Use multiple processes, but bind each process to a different UDP port. Tell the match players which port to send data to to route it to the right match. In addition, option 1) probably also want to use multiple threads, to make it scale across CPU cores. Option 2) typically doesn't need that, because each process can be scheduled on a different core.     Ok thanks for the full explanation. If I am to distribute my matches between multiple processes would I have to write a program that acts as an initializer for these processes? So basically that initializer program would be running 24/7 instead of the multiple processes. It handles the initial connection packets and every time a match is full it starts a new process on a new port. However I was also thinking this could be done from within each process itself where after 10 people are in one match the process just launches another instance of itself. Closing the process of course could be done by the process itself when the match is over. 
  10. slideside12

    Cloud Architecture/Port problem

      Gotcha. So if I use the "user as a host" model, through nat punchthrough, I would set up communication between the users through the master servers public ip (dns name now that I understand). Then send the "hosts" public ip (stored on the master server) to each client. I know theres more with having the host send a packet to each client first to establish a connection and such but im already aware of how to implement that. I would just use this NAT punchthrough system for every match then because I can't tell who is behind a firewall or who has a nat router.     Ok thanks I finally understand it now.      Oh ok like computer processes. Well then in your opinion what would be the most reliable/fastest way between the two choices? I would assume the one port per process implementation especially since each process would have its own memory space which is less likely to crash than trying to use one process for thousands/millions of socket connections. But this would of course have to be automatic. So I could write a program which would be ran on each VM. This program would act like an orchestrator. When one myserver.exe has had enough players for that match and a new match is being created the orchestrator program would launch a new process. The quiting code I could have inside the myserver.exe for when there are no players in a match. So the actual "process" that would be running 24/7 on each instance would be this orchestrator.exe file.   Thank you very much. Your responses are very helpful and so is this forum.
  11. slideside12

    Cloud Architecture/Port problem

      So I can instead hardcode the dns into the executable? How is this different if they both point to the same thing?      Oh yeah because of NAT. I guess I can include a nat punch through system if I go with the host/client model.     The random id and such I am familiar with. Its like authentication when working with web services/HTTP requests. But the terminology you used for the first part was a bit confusing. When you say "multiple matches on the same network interface but in different processes" what do you mean?     Most games i've seen don't go by state though. Thats pretty specific. Its usually by regions of continents/countries depending on part of the world. But yes I see what you are saying. However it seems the general notion here is that most people's games wont get far. Guess we'll have to wait and see then. 
  12. slideside12

    Cloud Architecture/Port problem

    "What could possibly go wrong?" :-) The six stages of a project: 1. Irrational Enthusiasm 2. Disillusionment 3. Panic 4. Search for the guilty 5. Puninshing of the innocent 6. Praise for the non-participants You are in stage 1.       1. You didn't respond at all to number 1 so I'll assume everything I said there is correct as far as implementation goes.   2. As for the non-cheating upsell idea that is good and having users play on the server I host myself to prevent cheating is why I was still asking about that. Ive seen VAC and Steamworks a couple of times and they do seem like a possible options but I have to look more into it. Is VAC essentially a library/sdk that you install into your game and sent parameters for it to detect? I assume this would have to be used with Steamworks for it to properly work.   4. For the EC2 ip/port issue after reading I know how I could do it manually but I was just saying in the case the ip address changes or something the server is getting the address itself but from what you've said it seems you cannot get the public ip address from a VM running on an instance. But elastic ip addresses seem to allow for an ip address that won't change so I guess if anything ever goes wrong I can just update the ip address manually and update the server file in the instance. This is strange though because when running locally you can get the public ip address so why not on a VM?   5. Yes I understand the virtual server model but what I am asking here is in relation to multiple matches on each server. I know for large scale MMORPG games one server holds all the player so I guess they all use the same port. Even if I were to reach a large amount of users it would still just be matches so I wouldn't have that open world type multiplayer. Now obviously each match would have a set of sockets that the server sends packets to. But what I want to know is that when I create a new match do I make bind the sockets with one port for that match. Then add a new port for every new match. Or does every socket connect to the same port and then I just send it accordingly?   6. So for your load balancing you're basically saying there would still be one server running for every region but it would have the resource of multiple machines. Each machine having the same ip address. But wouldn't that mean each machine running the server themselves? Don't really see the advantage of randomly selecting IP addresses based on one DNS name. If I had multiple servers I would rather have it based on region. Each ip address would just be for one server and each server would run on only one machine. This assures enough power for one server and eliminates the possibility of the "not on the same hardware but same IP" problem. For the more power situation I could just start new instances with more power. Also would the not seeing each other problem apply for both the "server based server/client" model and the "host based server/client" model? Could you tell me the advantage to what you suggested because I don't really see it.   Thanks a lot once again. Also I would say i'm more around stage 2 
  13. slideside12

    Cloud Architecture/Port problem

      Large Edit: Thanks for your fast response.   Initially I had a long response with a lot of questions. I sort of answered some of them myself after searching for a while but I still want to clear everything up so I have condensed them into the following questions:   1. I thought your suggestion was a peer to peer model but i've realized it is actually client/server model. So in this model I would program two servers and a client. One server (master server - used for matchmaking) I deploy to an actual online hosting service and one (host server - used to act as the server for multiple clients) is included inside the game code. Client functionality is also included in the game code. It is just what ip address to connect the socket to and how to send/receive packets to/from that ip address. So for an example situation. Once I have 10 players (for c++ = strings stored in a vector with each id attached to its ip address) I would just have the host launch the "host server" on his machine. This server would start listening for connections to his ip address. Then on each of the clients machines the master server would send them the ip address of this host. Each client would connects through a socket to the host's ip address. After that I just handle the gameplay. Every time a client moves for example I would send a packet to the host. The host would then update that client's movement on his own machine and send a packet to all the other clients. Then the clients would update. This seems like a very powerful and useful model. I think I've come across it before but now I finally understand it after your breakdown why its useful and how it can cut down costs for example. I believe this is how most online FPS work.   2. In your host/clients model how would you deal with something like cheating? Because technically the host can send false data about his movements to the other clients as well as manipulate the packets he receives before sending them to the clients.    3. If I wanted to implement things like leaderboards and user accounts I know how to implement this myself on the database/storage side. But would relaying this information be as simple as sending the final game data (just account ids w/ scores) to a backend with a https request once the game is done? Or would it be better to create a socket connection and send the data? If the host disconnects though I assume the match would be lost.   4. Ok so I have a better understanding of services like Amazon EC2. So if I choose them for example I really wouldn't need the multiple ports as I was saying earlier. Just one instance and its ip address basically. I would install the exe of the master server on it and run it 24/7. Since each instance is like a physical running machine I guess I could use the "get local ip address" function in whatever library I choose and start listening for connections to that ip address? If I wanted to launch multiple instances for various regions how would the game/player know which instance to connect to? I don't want to create an instance whose only job is just to send the ip address of the correct master server for the player to connect to (seems like a waste of resources).   5. In the case I want to still use the server/client model where I the actual cloud server acts as the server what would be the best way to do this with EC2 or Google Compute Engine? I guess I could have an instance/server for various regions but clearly not for every small match. So now in this case would I use a different port for each match on thats on the same server?    6. Exactly what maintenance would be needed in these situations? The only thing I could think of is when you see an instance being overworked for example just create another one. But then that would mean I would have to update the game that is on the clients computer I'm assuming. I don't really understand how patches work with already created executables but this probably isn't the section for asking this. Same question for security. The only thing I could see as a possible risk is a DDOS attack. Every other security related issue would be handled by the cloud provider.    P.S. You mentioned Raknet and I had said I looked into it. There are pricing models on the website but Im sure you are aware Oculus purchased it and it was made open source. Wouldn't this make it free no matter how many platforms its deployed to or its price.   Thank you in advance. Everything is coming together now and I feel confident in implementing this.
  14. Hey, my first post here. I want to ask for help in understanding something. So lets say you are working on a simple 2D desktop application. A space shooter. The application is written in C++ or C#. No framework or game engine is being used. I want to implement a system where the user can select multiplayer from a menu and after loading they will be put into a match with about 9 other players. These players would obviously be other players who were searching for a game at the time. Once all the players are connected to the match, they will play a simple multiplayer game match on a tilemap. After 3-4 rounds the person who won the most rounds wins. Very simple.    Now I understand the basics of getting this done. Create a local server in C++ and use packets to send information from one player to the others. This information would include the players position, his rotation and when he shoots (a spacehip game for this example). Apply this for each player on each frame (this is a real time game). Ive read a lot so I understand the basics of UDP/TCP and the structure of packets. However I do not understand everything fully.   1. Having alot of experience with Google App Engine and Python I wanted to know how I could use their channel api to accomplish this. Ive seen games such as Realm of the Mad God accomplish this and its been cited that it uses app engine. Many people have said their Channel API is not a good fit for real time multiplayer games due to latency. Now not only is this game real time but it allows for 85 players for a single battle and is browser based. Now if I am trying to accomplish 8-10 players, desktop based and no mmorpg functionality (open world, transitioning between worlds, online world state persistence, inventory, etc.) I don't see why I couldn't accomplish this using their api. Another problem I have is that their api says messages are sent between the backend and a javascript client. How would I accomplish this since I am programming for the desktop? 2. I have heard of node.js and socket.io as being nice solutions to my problem but once again they are browser based. How would I implement something like that for desktop? 3. Smartfox seems like a good solution but I don't really understand how it full works. Honestly though this looks like the best solution for what I want to achieve if I understood it more. Not understood how to use it but what it does/what role it plays. Do you use it to write a server/client, upload to a hosting service and then run it on there? 4. In the event I use a service like Amazon EC2 and write a simple c++ server and upload it I don't quite understand how the local implementation translates to working on the web. I know for the local server/client model I can just use a local ip and the same port. But lets say I have 1000 players and each match can contain 10 players. Would I just create a new port for each match? I haven't looked much into EC2 but I am assuming you would get an IP address for a server and then each port could act as a match. So the first match would be on ip_to_server:0000 then the next on ip_to_server:0001 and so on and so on. 5. What would be the security concerns for using something like a simple c++ server/client uploaded to a cloud hosting service? I know from my HTTP experience that the main security is in encrypting/hashing the data sent through HTTP requests. Now obviously I cannot do that with packets as that would cause latency and lag due to the increased size of the messages. And also the information being sent isn't private so I don't really see where security comes into play here. Would the security be the cloud service I use? 6. If a service like EC2 is used where do the costs come from? Is it based on the amount of messages sent between the sockets?     I guess the best case scenario I am looking at is using the channels api and just sending messages from the desktop application to a backend that acts as a a server and worst case I would write a simple c++ server, upload it to a service like EC2 and use a port for each match? Once again this is very simple.   Thank you in advance.
  • 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!