Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

256 Neutral

About Tolito

  • Rank
  1. Tolito

    UDP - Returning data.

    Thanks! It is the same thing in general. It is simply a matter of storing the sockaddr information and updating it for sendto, the SDL_net version. Thanks!
  2. I'm writing a simple command-line based chat client using C and SDL_net. This page has been useful: http://content.gpwiki.org/SDL:Tutorial:Using_SDL_net#Using_UDP   The code on that page works well for clients connecting to a host and sending messages to the host. What I am now trying to do is have the host send data back to each client.   It seems like it would be relatively simple, but I can't find any notes anywhere for it. Can anyone help me out with the code that needs to be added to the client and the host so the host can send messages back to the clients? Thanks!
  3. Tolito

    SDL 2.0 - Edit Renderer Pixels

    Thanks! Hopefully others with this question will come across this post!
  4. Tolito

    SDL 2.0 - Edit Renderer Pixels

    Update:   For my new multiplication function, I simply did this:     SDL_Rect r={0,0,XRES,YRES};     SDL_SetRenderDrawBlendMode(screen,SDL_BLENDMODE_MOD);     FillRect(screen,&r,color);This multiplies the new color to the screen without the need for accessing and editing the screen pixels, multiplying to them one by one. Since this is why I was needing to access the renderer pixels, this is no longer a problem.
  5. Tolito

    SDL 2.0 - Edit Renderer Pixels

    Thanks again! Since no pixel representation can be found, it sounds like my idea of storing said pixels as an SDL_Surface after they have been copied to the renderer is not a possibility. The only efficient possibility for doing this may be copying the to-be-blitted region of each texture, multiplying to the copy, rendering the copy to the SDL_Renderer, and destroying the copy. Doing this effectively is all over my head, though. Should I keep using SDL_Surfaces for everything and do the multiplication and rendering there, then storing as a texture and rendering that to the renderer at whatever scale?
  6. Tolito

    SDL 2.0 - Edit Renderer Pixels

    Thanks for the reply! Actually, I am using SDL_RenderCopy to copy textures to the screen, which is of type SDL_Renderer. Instead of updating every texture each frame, I want to edit the pixels of the renderer itself, basically the final version of the screen. I am trying to avoid using an SDL_Surface since this will be calculated each frame and I want to do all of this in the GPU. Creating a surface that is a copy of the renderer, multiplying the colors there, converting the surface to a texture, and using SDL_RenderCopy again to put the edited colors back on the renderer would work, but it seems like there is a more efficient way of doing that. Is there a way to access and edit the pixels of an SDL_Renderer itself? Thanks again!
  7. When I was storing the screen as an SDL_Surface, I could multiply colors to it like so:    Uint32 *pixels = (Uint32 *)screen->pixels;     unsigned int x, y;     for(y=0;y<screen->h;y++) {         for(x=0;x<screen->w;x++) {             // Code to edit each pixel here.         }     } I am migrating my code to work with SDL_Textures again, which requires using an SDL_Renderer. I am familiar with using SDL_RenderCopy and all of those functions, but I'm not sure how to go about editing the individual pixels rendered to an SDL_Renderer, and this is necessary. Does anyone have any suggestions on how to do this? Thanks!  
  8. Tolito

    SDL 2.0 - Double Screen Resolution

    Thank you for the useful responses, everyone! My guess was that using SDL_Textures instead would help, but there was a problem loading a 10,000x8 image as a texture. It looks like using an image that is squarer works, so that is no longer a problem.   I think my last question regarding SDL_Textures is this: by what means can I edit the contents of an SDL_Renderer? With SDL_Surfaces, using what will be rendered to the screen as a surface, I can easily edit pixels. I wrote a function to multiply a color to every pixel on a surface, which is then rendered to more. How can I go about doing the same thing for a renderer? Maybe I should start a new topic, but replies to this question are welcome. Thanks again, everyone!
  9. Tolito

    SDL 2.0 - Double Screen Resolution

    Thank you for your response!   One image is approximately 10,000x8 pixels, which doubles to 20,000x16. Having everything scaled in advance was working well with SDL 1.2, but when storing that many pixels was the only way to display a scaled version to the screen and they couldn't all be stored, and having been told that SDL 2.0 could natively draw graphics double the scale without a slowdown, I migrated the code to SDL 2.0.   There unfortunately is still a slowdown, even when scaling only the final version of the image instead of each individual one.   The native resolution is less than 320x240 pixels. This is a suitable resolution for the graphics that are in use and it saves space. It looks much better with double the resolution, however, but has high-detailed graphics that cannot all be stored in ram if everything is double the scale.   I heard that SDL 2.0 could natively do this. Would the slowdown still be present if I were to write my own version of SDL_BlitSurface that blits four pixels for every one pixel of a surface? What I'm thinking SDL_BlitScaled does is it does math to scale the surfaces before blitting them to the screen.
  10. I'm unfortunately bringing this topic back from the dead (initially posted here: http://www.gamedev.net/topic/651375-double-screen-resolution/)   In favor of using SDL_BlitScaled, I migrated all of the code to SDL 2.0. Unfortunately, the slowdown is back again. How can I double the screen resolution so that every 1x1 pixel is a 2x2 pixel? I'm surprised that they still haven't implemented anything like this. It runs at full speed at the small resolution, but I would like for it to be double that without having to scale all of the graphics in advance, which will consume more ram.   Is there something that I am forgetting? Thanks!
  11. Tolito

    SDL 2.0 - Enable VSync

    Thanks for the response.   I am using SDL without OpenGL, using SDL_RenderCopy to display graphics. Double buffering seems to be for OpenGL only: http://wiki.libsdl.org/SDL_GL_SetAttribute#Remarks   Tiles render, but VSync doesn't work: screen=SDL_CreateRenderer(window, -1, SDL_RENDERER_SOFTWARE ); Nothing renders (this should enable VSync alongside software rendering): screen=SDL_CreateRenderer(window, -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_SOFTWARE ); Everything renders but tiles (if using 2,000x8, the tiles render, but the 11,000x8 image is necessary for this project): screen=SDL_CreateRenderer(window, -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED ); What I am asking: How do I (a) enable VSync in SDL 2.0 with software rendering, or (b) how can I store the 11,000x8 pixels image as a texture in the GPU? It stores in ram properly because it renders with software rendering.
  12. The image that is the map tiles is approximately 11,000 pixels wide. When I load it into SDL_Texture with software rendering, it works. When I use this, however, it does not: screen=SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_SOFTWARE );Using SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_SOFTWARE without SDL_RENDERER_ACCELERATED also does not work. If I want the tiles to render, I must supply SDL_RENDERER_SOFTWARE only. How do I enable VSync in SDL 2.0 with software rendering, or why can I not store that as a texture in the GPU, yet I can store it in the CPU just fine?   Thanks!
  13. Tolito

    Double Screen Resolution

    I added code to work with surfaces that are double their original scale and made them be scaled after being loaded. It took a while to implement, but the doubled resolution renders more quickly now. The original, doubled, and fullscreen resolutions are now all available to the user. Hopefully storing the scaled surfaces will not be a problem for the system requirements! Thanks for the input! I was hoping there was a way to render at double the resolution without having to scale the surfaces, but this will do.
  14. Tolito

    Double Screen Resolution

    Thanks for the response! This is almost finished, so switching to something other than SDL 1.2 at the last minute may be more work than necessary. Is there some kind of way to scale screen and then do SDL_Flip(screen); instead of making a duplicate that is a scaled version of screen and then blitting to screen, flipping screen afterwards? I tried running the scaling code in the background without re-blitting and there was no slowdown. Blitting the duplicated and scaled surface to screen before doing SDL_Flip(screen); is what causes the major slowdown to occur.
  15. Tolito

    Double Screen Resolution

    if(new_screen_w && new_screen_h && (stored_res_x!=new_screen_w || stored_res_y!=new_screen_h) ) screen=SDL_SetVideoMode( new_screen_w, new_screen_h, 32, SDL_SWSURFACE ),stored_res_x=new_screen_w,stored_res_y=new_screen_h; That's what I was saying. The problem was probably not occurring because it only had to blit for one fourth of the size of the window. With that line of code enabled, however, it must do four times the blitting, which led to an entire system slowdown.     Instead of scaling and blitting a duplicate, how can I scale the screen itself and use SDL_Flip on that? For example, this: scale(screen); SDL_Flip(screen); Instead of this: SDL_Surface *scaled=scale(screen); SDL_BlitSurface(scaled,NULL,screen,NULL); SDL_Flip(screen); I tried running the code with scaling going on in the background with no re-blitting. There was no lag. Blitting without scaling also results in no lag. With both scaling and blitting, however, the entire system slows down. Thanks again!
  • 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!