Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Everything posted by Gl2eenDl2agon

  1. Gl2eenDl2agon

    when to use concurrency in video games

        That's now how it works. All memory is available to all threads in a process. This means that any code you write can read and write to any part of memory at the same time. The volatile keyword is really just a hint that may cause what you write into that memory location to be flushed to ram from the CPU cache (heavy emphasis on may, volatile is poorly supported).   To share memory between two threads you need to protect it with a mutex (mutual exclusion). A mutex is basically a varable that you use library functions on to lock it and unlock it. You have to be sure to lock it before you mess with your other variable. This means when your second thread tries to lock it to also mess with that variable it will block until the first thread unlocks that mutex. This is a big bottleneck so make sure you share the bare minimum amount of memory to accomplish the task and don't share very often. This is usually accomplished by having separate working copies of data and syncing them when other tasks are done as well as other ways.   One programming pattern that I like to use enforces the locking and unlocking of the mutex. You create the main object and make everything protected. Then you have a "lock" method that creates a locked version of that object (another object that contains a reference to the first object and has all of the same methods made public and they simply wrap the methods of the first object). When the locked version is deleted it calls the method on the first object that unlocks the mutex.
  2.   This is kind of annoying. I pretty much do everything here in one swift batch with multiple tabs and then I might not be back for hours. This site is one of the places I go during my quick breaks between productivity outbursts.
  3. Would it be feasible to implement a rudimentary weather sim in game and have it interactive?   By interactive I mean that the wind  and rain affects gameplay. You can fly up and through the clouds. You can be randomly struck by lightning. Or maybe in a sandbox type or RTS game, player actions such as industry or heavy resource harvesting could affect weather.   Sounds like a good idea or perhaps just a gimmick?
  4. Gl2eenDl2agon

    Multiple server architecture

    I would favor having the client connect to the chat server and the game server rather than have the game server redirect to the chat server. You want to cut down on the total number of sockets that will be open on the servers at all times (use only bare minimum # of open connections to achieve desired result). You can even have game servers, and then have zone servers that belong to the game server but handle things like hit detection, combat, etc at the local level where the game server just keeps up with what zone you are in and your inventory, etc. The client could simply just open a connection to all necessary servers. The login server would tell the client which game server to connect to. The game server would tell the client which zone server to connect to based upon stored player position data.
  5.   I would probably refrain from passing text. Its a novice mistake to see the function declaration for send() and see char *buffer and assume that you must pass in a string.   You could just pass opcodes and have a switch statement which will execute faster.  Your network message would be like unsigned short opcode (uint16_t) (there could be an opcode for moving, or other actions etc) signed int x, y, z (or float) relative movement   You allocate a buffer, copy the bytes into it. Then send() will take the pointer to the buffer and its size. When you recv you check the opcode. If its the move position opcode, then you read the rest of the buffer as you wrote to it.
  6.   However, where do we draw the line? For example, I find the quoted statement both racist and sexist. Its like you are suggesting that white men are worth less than other demographics to the industry. I strongly disagree that the white male demographic should be discriminated against to meet some quota. A person should be treated equally regardless of race or gender.     You remind me of the challenges I had growing up as a extremely poor white male. For example, there was this one time during my undergraduate where an error caused by government red tape withheld my GI bill funds. I couldn't get a scholarship when I graduated high school so I had to wait until I was 24 basically. I had joined the army to earn my GI bill. I went to the financial aid office and asked for assistance. The lady there was a black woman. She refused to help me. She at one point became so angry that she threw here pen at the wall and yelled "A little white boy like you doesn't need financial aid! Why don't you have your parents pay for it!" (yes, she actually said that) By then I have been back and forth with the veterans office and the financial aid office probably 6 times. I left the room reduced to tears. My parents are so poor that they couldn't even afford to drive to my graduation. When I graduated (a few times), there was nobody there to take pictures with. Yet at the same time students with affirmative action scholarships had parents show up in brand new Mercedes. There were even times when I had to send what money I had back to my parents so they could not have their electricity shut off. I have been fighting an uphill battle against racial and sexual discrimination my entire adult life. Am I less of a human being because I have a penis? ..because my skin is white? Are my skills and abilities not important to you?       I strongly disagree with censorship, especially when its being used to uphold the political ideology of the staff. Moderation only works when its neutral. When you use moderation as a form of political censorship, that's when you have become unprofessional. In order to ban threads that disagree with affirmative action, you would also have to ban thread that describe gender inequality and a need for affirmative action.      
  7. Gl2eenDl2agon

    How to start on game programming properly

    Can you make pong?   If yes, then move onto 2D platformers.   If you use java, you can use something like java3d or jogl.   You won't make anything that closely resembles a fully featured game for some time. Don't sweat it.
  8. Gl2eenDl2agon

    Misuse of downvotes

      Downvotes are supposed to be a way to keep spam in check. This doesn't work when people use downvotes as a form of censorship. (this is why reddit is a joke, its a site full of areas of people who are all in 100% agreement with each other so no productive debate of any kind can be had because you'll be downvoted until your account is hidden if you aren't in 100% agreement with everyone in that subreddit)   I downvote anyone who downvotes me, as well as anyone who downvotes newbs. I upvote almost anyone who replies to a topic I start as long as its not completely wrong.
  9. Gl2eenDl2agon

    Skeletal animation is hella slow

      You can't really slerp matricies. I said that I calculated the matricies recursively (so that parents move children). The matricies are computed by the rotation quaternions and translations. Typically most game ready 3d meshes don't have tons of joints/bones so you are really only redoing maybe up to 20x2 matricies once per frame per mesh. When I compute the rotation and translation I do it only at intervals and not every frame. I compute start and end rotation+translations for every joint/bone and then use the current time to interop between them. For me it seemed that traversing the running animations, handling masking and blending etc was a bit much to do every frame. Heck, I even put that in another thread to itself.
  10.   I still have to argue with people who think that bitmaps can't have transparency.   There are alot of features of bitmaps that nobody supports though. For example Microsoft allows for PNG and JPEG compression, but most of their software doesn't support it in a file (its used for GDI only). Its kind of funny how those two modes work, they have basically an entire complete PNG or JPEG file where the pixel data should be. (you can read in a JPEG file, stick it inside of a bitmap container in memory, and send it to GDI and it will render it)
  11. Gl2eenDl2agon

    Skeletal animation is hella slow

    I would prefer this:   At constant intervals iterate through all animations and do the required logic to determine which keyframes you are on etc. Then iterate through each bone and iterate through the small list of only currently playing animations and accumulate the transforms for that bone (if any) and store it with the bone. Then go through all bones and recursively caculate the parents' matrix and then that bone's matrix using some flag to prevent redudant calculation. Upload the results per bone to your shader.   I suppose you could find a way to even do that in a shader, but I tend to just use C++ to get-er done.
  12. First:   Bitmaps are stored BGR and not RGB.   Second:   Bitmaps are 4 byte aligned. This means that each horizontal line comes out to a multiple of 4 bytes. Typically this is called "scanline size". This means that ( y * w + x ) *3 doesn't work. You will have to find the scanline size by finding the smallest multiple of 4 larger than the width in bytes. Like for( int scansize = 0; scansize < w_bytes; scansize += 4); will work (but not the best way). You will need to allocate a buffer of (height * scanline_size) bytes and find the offset for each pixel by ( y * scaline_size + x * bytes_per_pixel). In other words a generic 2d array wont work unless you can be sure that the scanline size is the same as (width * bytes per pixel).     Oh.... also bitmaps are stored upside down. This means that the first pixel in the file is actually the first pixel on the last scanline.
  13. I'm not sure where this concept of Unity being easier than Unreal came from... They are very similar. Both are going to be really hard for someone who almost knows just one programming language. Unreal even has a visual script builder called "blueprint" so that you can make an entire game without writing any code.
  14.   The files I import from typically store the keyframes inside of the joints where not every joint is present in every keyframe and its assumed you interop for the missing keyframes (each keyframe stores absolute translation and rotation and not deltas). I convert that into my format that requires that every keyframe has every joint that moves (missing joints are assumed to be at original position) to make it easier to copy and paste frames or to play in reverse.   Anyways, as long as the rendering framerate is less than the animation framerate everything works normally. If you turn up the speed on the animation, then things start to look bad as keyframes are skipped over when using the traditional interop between frame before current time and frame after (or use the frame that is equal to current time). This is because there are alot of intermediate keyframes that were created by the artist and the keyframe that stores the largest motion that most accuratly represents the essence of that animation tends to be skipped over.     True, but if you need to playback the animation at increased speed then just increasing the rendering framerate won't be viable. (like adjusting the speed of the running animation to reflect a run speed increase spell etc) There may also be times when the model is far away from the camera and I want to turn down the refresh rate for animations on those model instances (basically skipping frames) without the animations looking too bad.       Apparently mine does I just though it might work and tried it. So far it looks OK. Its mostly for when I turn up the animation playback speed and not for low FPS, but it also works in those situations.   I mostly buy 3D assets since I'm not much of an artist myself. The 3DRT dragon had an insane amount of keyframes (like 70MB of them) so I modified my importer to use a process similar to what I'm doing above to "condense" keyframes to like only 30fps. That particular model would sometimes crash blender when I imported the Ms3d variant.
  15. I made my own model importer and animation code. It works really well actually which is unusual for my first attempt at something.   However, I encountered one problem: what do I do when the animation plays faster than the framerate of the renderer? In examples I've found they just kind of skip over those keyframes... basically the keyframe displayed is always an interop between the closest frame before the current time and the frame right after. This leads to some weird looking playback as this tends to end up landing on the "weaker" parts of the animation and skips over the "largest" frames (the ones that move the mesh the most) when playback happens at a faster rate.   I did try to handle the problem though. What I did was instead of a simple interop, I iterate through all of the keyframes from last frame until the current time and find the keyframe that has the largest movements and use that one. It seems to make the animations look better as the joints/bones do get moved to the extremes of the animation instead of just undulating through all of the "halfway" points.   What do you think? How do you hadle this? What about when the animation is being played at like 10x speed?
  16. Gl2eenDl2agon

    Should I use OpenGL or Directx

      I disagree. Learning to write shaders (the right way) for me was harder than everything else about 3D combined. Upconverting from GL 1.x to 2.0+ isn't very hard either. I typically protoype in GL1.x to get more work done since I don't have to concern myself with the actual work of rendering. Then I tend to adapt some older GL3.0 code and throw it in there later on.         First part isn't that hard and for most people they just keep copy-pasting the same code they wrote 5 years ago... or just use SDL.   Typically only the features added after a major version are extensions. If you want to use pretty much every feature of a DX10 graphics card you would use GL3.0 for example. You really don't need the extensions if you aim for the major GL version that has those features baked in. If your name is Carmack, then you use extensions because he is like the Chuck Norris of the 3D world.
  17.   ...but if the model has a ton of keyframes the closest two keyframes are most likely going to be nearly identical and the keyframe that displays the most movement could have been skipped over.   Lets say for example you are playing a jumping animation. There are 10 frames. Frame #5 is the highest frame. But because of a render-framerate to animation-framerate mismatch you only playback frames 1.25, 3, 8.5, and 10. To the end user it will appear that the model only moved like 2 inches off the ground and not the entire 12 inches that it should have moved in frame 5.   This is why I decided to go with the other approach. In that example, When I land on frame 8.5 after doing the "current time - start time" to frame time conversion I then see that I skipped everything after last frame (3) so I iterate through them all and find that frame 5 moved the most so I display frame 5 and not frame 8 iterop 9. Because of the lagging render framerate the user doesn't notice that frame 5 is out of step and it doesn't look jerky. Whether the animation is played back at 0.5x speed or 10x speed the model still jumps 12 inches.
  18. Gl2eenDl2agon

    Linker errors Eugh!

    Technically you can just skip glew and SDL2 altogether and just use the win32 api on windows and X11 on linux and mac. For a beginner tutorial not recommended. You will have to manage getting SDL2 dll's on every users computer to run your exe though. I'm not sure why glew is needed. I don't see it used in the tutorial source code.
  19. Gl2eenDl2agon

    Should I use OpenGL or Directx

    I think everyone is missing the point of the OP.   This guy doen't know enough stuff to be able to jump into DX12 or Vulcan or even DX9 for that matter.   I'd suggest you go to nehe.gamedev.net and learn good ole OpenGL version 1.5'ish. This will teach you the 3d side of things. Once you can create a window, render a gui, and load a model from file and move it around then you can move on.   To learn OpenGL 1.5ish basics (and the basics of 3D!! ) nehe.gamedev.net (tutorials listed on the right side of the screen)   To load an animated 3D model easily http://milkshape3d.com/ (download the "MilkShape 3D Binary Model Viewer (/w src)" and at first copy paste but then learn it) (also, 3drt.com has freebies in Ms3d format and also sells the premium models as Ms3d)   TBH there is enough source code at those 2 places to copy and paste together a working yet very lame working game.   I'm suggesting GL < 2.0 because its really hard for a beginner to learn how to write shaders. Obviosly once the OP knows the 3D basics then he can start with OpenGL 3.0+ or D3D10 and learn how to write shaders.   I'm a big fanboy of OpenGL myself simply because I like being able to write my OpenGL renderer and by using a few #ifdef #define's to wrap the OS specific lines of code (not very many) I can simply compile my C++ OpenGL renderer on Windows, Mac, and Linux with little problems. Of course I'm only using X11 on Mac which works fine because learning Objective C++ is just too weird for me at this moment. I do plan on adding DX8, 9, 10, 11, and maybe even 12 renderers to my current project along with Vulkan and Metal (once the Obj C weirdness goes away). I've already made renderers for GL 3.0 and DX9 and 10 before.
  20. Why is it cheaper to rent many single core servers (VPS or physical) than it is to rent a multi-core server? To me it seems that pricing reflects a marketing decision more than it does the reality of the hardware.  
  21. Lets say your GUI uses a logical width and height of 1920x1080 pixels. Your actual screen width and height can change at any time like when the user resizes the window or changes resolution. All of the coordinates and dimensions expressed by your GUI code are expressed relative to the logical size and you must do the conversion when you render the textured 2 triangle box.   So you need to do the following: Compute the ratio of logical width to screen width, and the same for height. The smallest ratio becomes the zoom factor. Compute the padding needed to center the GUI. (this is basically the make-the-image-fill-a-box-and-preserve-aspect-ratio algorithm)   I've implemented it, and I'm drawing it to the screen with identity world matrix.   So basically screen_x = logical_x * ratio;   I haven't figured out the padding yet (i seem to have too much padding) and the zoom seems to be a bit off when the window is extremely squished into a rectangle.   What irritates me is that I've solved this before but now I can't remember how and I can't find that code from so long ago.
  22. I was going at it completely wrong.   OK, so the way that works is...   Compute the ratios like before. Take the greatest ratio and use it to normalize the two ratios (divide both of them by the biggest one). Use these two normalized ratios as the zoom factor (ie, ratio_x becomes zoom_x) To find the padding, find the extra space and divide by half. (ie, padding_x = (1.0f - zoom_x) * 0.5f ).   So when you render the box, you take the x position, y position, width and height, divide by logical screen dimensions, multiply by zoom factor, and add padding and you end up with vertex coords in the range of 0.0 to 1.0f. To use those with identify matrix, you do x * 2.0f - 1.0f.   For those of you who are wondering what I'm doing... I'm zooming the GUI down and adding padding to center it so that I can have a consistent GUI across all screen resolutions and aspect ratios. When you position and size the GUI elements, you only need to place them using the logical 1920x1080 screen space. The user doesn't have to manually drag things around because their screen is too big or too small. The only downside is the textures for the GUI elements will become blurry as you scale them down for really low resolutions.
  23. You could always make OpenGL and Direct3D behave the same by flipping your world view matrix. Going through all of your assets just to flip the Z is insanity.
  24. Gl2eenDl2agon

    Serving large files over TCP

    Only if you keep the entire file there. But, as I said, you could probably stream them to/from disk so you don't have to keep the entire file in memory, or as others said if you forward  them directly to the user while you download them yourself.     What Bob and everyone is saying is....   std::fstream f;   f.open(...);   f.seekg(0,f.end); size_t m = f.tellg(); f.seekg(0,f.beg);   size_t i, l; i = 0; while( i < m  ) { l = 1024; if(l < m - i ) l = m - i; f.read( buff, l ) send( skt, buff, l, 0 ); }   f.close(...) aka stream it from file to the network. Notice how only a tiny part of the file ever resides in memory (only 1024 bytes in that code).
  25.   What does that have to do with getting your binary hacked? You are going to get hacked whether you use pointers or not.   buffer overflows have nothing do with pointers in your code- not having pointers doesn't prevent buffer overflows. A buffer overflow is when you have a buffer on your stack (like char mytext[256]; in C) and then you read input into it or copy into it without making sure the size copied is less than the buffer size. If this buffer resides in memory in the stack before the instruction pointer, then overflowing the buffer and changing the value of the instruction pointer to point to the buffer where you inserted x86 opcodes will allow you to run that code when the current function returns. The instruction pointer is put there in the stack by your CPU when it jumps to a function so it knows where to jump back to when it returns.
  • 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!