Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


AlanSmithee

Member Since 19 May 2011
Offline Last Active Today, 09:19 AM

Posts I've Made

In Topic: PerfectMMORPG

14 April 2015 - 03:03 PM

"return of the retarded"...

Troll much?

In Topic: Boss 101 - On Greenlight (action, adventure, millions of bosses)

01 April 2015 - 01:45 AM

looks great!


In Topic: SDL External Libraries & window management suggestions

17 March 2015 - 06:26 PM

I think what Sean is saying is that even when you are doing a xmlhttprequest, or AJAX call, and only replacing the content of parts of the DOM instead of the whole page, the browser is still refreshing the entire screen ever so often. In SDL you do the same. The screen will update at some rate (FPS) and it is up to you to decide which parts "widgets" of that screen that should have its content replaced as well as how and when. He also suggested some common methods/frameworks.

In Topic: How to implemnt lighting in 2d sdl game?

06 March 2015 - 04:12 AM

 


I do not think this answers his question since there is no concept of a camera in SDL.

Assuming that you are using SDL_BlitSurface, then have a look at the SDL_SetAlpha function especially with its flag parameter set to SDL_SRCALPHA. This allows for alpha blending. Then use an image with an alpha channel, totally black but with full alpha in a central circle, falling off to 30% or so towards the borders. Set the surface to alpha blending, and blit it so that the destination rectangle matches the current view area. That is already what Orymus3 suggested, but expressed using SDL terms.

 

 


I drawed a black square on top of the screen with alpha blending so the game looked like it was dark, but now I have no idea on how to make things visivle and add those "lights".

Notice that the above trick does not lighting but darkening! The state of the destination surface before is a fully lit scene, and then only those parts of the scene that should not be lit are darkened.

 

 

Personally, I am using SDL2 with SDL_Texture's and SDL_RenderCopy. However I think I would be able to use SDL_SetTextureAlphaMod to achive the same result.

 

I think my question was a bit missguided, because my use-case is different.

I want to blend two textures (or surfaces) given a transparency mask where white is 100% image a and black is 100% image b and all shades of gray are a mix of a and b.

My idea was to render image a, then render image b over it with per-pixel alpha applied to it by the mask.

I guess I could use your suggested technique for this.

 

I don't want to hijack this thread any more though, so I'll just thank you for your feedback, and if I need any additional help, I'll start a new thread =)


In Topic: How to implemnt lighting in 2d sdl game?

06 March 2015 - 01:30 AM

Do you need real lights?

One of the 'easiest' tricks is to bind a transparent png or image file to the camera that has this shape. Unless you plan on having other light sources, it works great and requires no pre-computations.

I do not think this answers his question since there is no concept of a camera in SDL.

I don't have an answer to your question Twk Amz, but I am too interested in how to achive transparency with some kind of a mask in SDL.


PARTNERS