Is there a way from code or settings to disable video/hardware acceleration by default? It looks like you can do it from the launcher, but I'd like to not give the option and just disable it for my game by default if possible. Thanks!
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
#92
General discussion / Re: How to make a bitmap to be blend-compatible ?
August 06, 2016, 03:47:35 AM
I just created a new image with a transparent background and used a brush to place the large white dot in the middle, which faded into the background.
I don't know the exact option right off the top of my head, but you should be able to convert the black in your first image into the transparent color and that would give an image that you could use for the light effect.
I don't know the exact option right off the top of my head, but you should be able to convert the black in your first image into the transparent color and that would give an image that you could use for the light effect.
#93
Development / Re: Failed to create software surface
August 03, 2016, 04:09:42 AM
I am now almost positive that the crash is related to clear(), as MetalZelda had mentioned earlier. If I change the clear line to fill_color (which appears to have the same effect anyway, at least in my case) I can run the game for hours without a crash.
#94
Development / Re: Failed to create software surface
August 03, 2016, 12:04:41 AM
Hmmm... were you running the most recent Github version?
Oh! The mountaintop dungeon and the other inside areas that use lights I think I still need to optimize. I'll look at that tomorrow, lol
Oh! The mountaintop dungeon and the other inside areas that use lights I think I still need to optimize. I'll look at that tomorrow, lol
#95
Development / Re: Failed to create software surface
July 31, 2016, 08:16:29 PM
Thanks for the replies Christopho and MetalZelda!
I did refactor my code a bit based on Christopho's advice, and so far I've been able to prevent the crash. I do plan to just let my game run for an hour or so and see if I get it then, but by playtesting so far has been fine.
MetalZelda, I think it's a good idea to let your game run for a while to ensure you don't get the crash. If you do, move some stuff out of on_draw like Christopho suggests.
I did refactor my code a bit based on Christopho's advice, and so far I've been able to prevent the crash. I do plan to just let my game run for an hour or so and see if I get it then, but by playtesting so far has been fine.
MetalZelda, I think it's a good idea to let your game run for a while to ensure you don't get the crash. If you do, move some stuff out of on_draw like Christopho suggests.
#96
Development / Re: New free enemies for the sample quest [feedback wanted!]
July 31, 2016, 04:15:32 PM
These are really cool - loved the video! Great work!
#97
Development / Re: Failed to create software surface
July 31, 2016, 04:14:00 PM
I'm rebuilding the surfaces because the lights may change and the player moves, so the light around him has to move as well. I don't know of another way to do this. I could probably move some of the non-drawing functions to on_update instead, but I don't know how much difference it will make since I think the majority of the overhead is coming from the drawing itself.
#98
Development / Failed to create software surface
July 31, 2016, 01:52:18 AM
I'm using a modified version of Satoh's code that was posted at http://forum.solarus-games.org/index.php/topic,676.15.html to make the day/night system I had work with the new blend modes introduced in 1.5. It uses the map metatable to force a night overlay to drawn on all maps when it's night time. The problem is that after 10 to 15 minutes of game play at night (an overlay with blend modes being drawn) my game crashes with the fatal error "Failed to create software surface". I'm assuming that my code is just inefficient and the repeated re-drawing is causing memory issues, but I'm not sure how to improve it. Hopefully someone here will have an idea that can help me improve me code! And thanks for looking!
Code ("lua") Select
function map_metatable:on_draw(dst_surface)
local game = self:get_game()
local hour_of_day = (time_counter / 3000)
-- Put the night (or sunrise or sunset) overlay on any outdoor map if it's night time.
if (hour_of_day >= 19.6 or hour_of_day <= 7.4) and
(game:is_in_outside_world() or (self:get_world() == "dungeon_2" and self:get_id() == "20") or
(self:get_world() == "dungeon_2" and self:get_id() == "21") or (self:get_world() == "dungeon_2" and self:get_id() == "22")) then
local x,y = game:get_map():get_camera():get_position()
local w,h = game:get_map():get_camera():get_size()
if draw_counter >= 15 then
shadow:clear()
if hour_of_day >= 19.6 and hour_of_day < 20 then
t[1] = 255; t[2] = 255; t[3] = 255
-- Dusk
if t[1] >= 2 then
t[1] = t[1] - 2 -- Red: Goal is 0 (fade to black, which is the same as fading in for this blend mode)
else
game:set_value("time_of_day", "night")
game:set_value("hour_of_day", 20)
end
if t[2] >= 3 then
t[2] = t[2] - 3 -- Green: Goal is 0
else
game:set_value("time_of_day", "night")
game:set_value("hour_of_day", 20)
end
if t[3] >= 4 then
t[3] = t[3] - 4 -- Blue: Goal is 0
else
game:set_value("time_of_day", "night")
game:set_value("hour_of_day", 20)
end
shadow:fill_color(t)
elseif hour_of_day >= 20 and hour_of_day <= 21 then
-- Sunset
if t[1] >= 32 then t[1] = t[1] - 3 end -- Red: Goal is 32 (from 255)
if t[2] >= 64 then t[2] = t[2] - 2 end -- Green: Goal is 64 (from 255)
if t[3] >= 128 then t[3] = t[3] - 1 end -- Blue: Goal is 128 (from 255)
shadow:fill_color(t)
elseif hour_of_day >= 6 and hour_of_day <= 7 then
-- Sunrise
t[1] = (182*(hour_of_day-6))+18 -- Red: Goal is 182 (from 32)
t[2] = (62*(hour_of_day-6))+66 -- Green: Goal is 126 (from 64)
t[3] = (37*(1-(hour_of_day-6)))+87 -- Blue: Goal is 91 (from 128)
shadow:fill_color(t)
elseif hour_of_day > 7 and hour_of_day <= 7.4 then
-- Dawn
if t[1] <= 253 then
t[1] = t[1] + 2 -- Red: Goal is 255 (fade to white, which is the same as fading out for this blend mode)
else
game:set_value("time_of_day", "day")
game:set_value("hour_of_day", 7.5)
end
if t[2] <= 252 then
t[2] = t[2] + 3 -- Green: Goal is 255
else
game:set_value("time_of_day", "day")
game:set_value("hour_of_day", 7.5)
end
if t[3] <= 251 then
t[3] = t[3] + 4 -- Blue: Goal is 255
else
game:set_value("time_of_day", "day")
game:set_value("hour_of_day", 7.5)
end
shadow:fill_color(t)
else
-- Night
shadow:fill_color({32,64,128,255})
game:set_value("time_of_day", "night")
end
lights:clear()
for e in game:get_map():get_entities("torch_") do
if e:get_sprite():get_animation() == "lit" and e:get_distance(game:get_hero()) <= 250 then
local xx,yy = e:get_position()
local sp = sol.sprite.create("entities/torch_light")
sp:set_blend_mode("blend")
sp:draw(lights, xx-32, yy-32)
end
end
for e in game:get_map():get_entities("night_") do
if e:is_enabled() and e:get_distance(game:get_hero()) <= 250 then
local xx,yy = e:get_position()
local sp = sol.sprite.create("entities/torch_light")
sp:set_blend_mode("blend")
sp:draw(lights, xx-24, yy-24)
end
end
for e in game:get_map():get_entities("lava_") do
if e:is_enabled() and e:get_distance(game:get_hero()) <= 250 then
local xx,yy = e:get_position()
local sp = sol.sprite.create("entities/torch_light_tile")
sp:set_blend_mode("blend")
sp:draw(lights, xx-8, yy-8)
end
end
for e in game:get_map():get_entities("warp_") do
if e:is_enabled() and e:get_distance(game:get_hero()) <= 200 then
local xx,yy = e:get_position()
local sp = sol.sprite.create("entities/torch_light_tile")
sp:set_blend_mode("blend")
sp:draw(lights, xx-16, yy-16)
end
end
for e in game:get_map():get_entities("poe") do
if e:is_enabled() and e:get_distance(game:get_hero()) <= 200 then
local xx,yy = e:get_position()
local sp = sol.sprite.create("entities/torch_light")
sp:set_blend_mode("blend")
sp:draw(lights, xx-32, yy-32)
end
end
-- Slowly drain magic when using lantern.
if magic_counter >= 50 then
game:remove_magic(1)
magic_counter = 0
end
if not game:is_suspended() then magic_counter = magic_counter + 1 end
draw_counter = 0
end
draw_counter = draw_counter + 1
if game:has_item("lamp") and game:get_magic() > 0 then
local xx, yy = game:get_map():get_entity("hero"):get_position()
local sp = sol.sprite.create("entities/torch_light_hero")
sp:set_blend_mode("blend")
sp:draw(lights, xx-64, yy-68)
end
lights:draw_region(x,y,w,h,shadow,x,y)
shadow:draw_region(x,y,w,h,dst_surface)
end
end
#99
Bugs & Feature requests / Re: Feature Request: Change a surface's blend mode
July 15, 2016, 03:06:05 AM
Alright - got it to work! Thanks!
I think something else on the map was throwing things off, so I tested on a fresh map and then moved the correct code. This actually cleaned up my code by a lot and created an infinitely better effect!
I think something else on the map was throwing things off, so I tested on a fresh map and then moved the correct code. This actually cleaned up my code by a lot and created an infinitely better effect!
#100
Bugs & Feature requests / Re: Feature Request: Change a surface's blend mode
July 15, 2016, 12:33:32 AM
Satoh, using your example code, what kind of image would you want to use to create the brightened area? I'm currently trying with a black image where a white circle represents the light area and it doesn't seem to be working. I'm trying to attack a glow to some statues that I already have in a map, but while dimming the entire room works, I'm not getting any glow (I'm attempting to create the glow sprite at run time and draw everything to the shadow surface, which I am drawing in map:on_draw).
Code (lua) Select
shadow:fill_color({32,32,255,255})
shadow:set_blend_mode("color_modulate")
light_mask:set_blend_mode("additive_blending")
for entity in map:get_entities("statue") do
local x, y, z = entity:get_position()
local sprite = sol.sprite.create("entities/torch_light")
sprite:set_xy(x, y)
sprite:draw(light_mask)
end
light_mask:draw(shadow)
#101
Bugs & Feature requests / Re: Feature Request: Change a surface's blend mode
July 08, 2016, 06:05:39 AM
Haha, you're the best! It'll be really cool to see what we can do with it
#102
Bugs & Feature requests / Re: Feature Request: Change a surface's blend mode
July 07, 2016, 04:07:33 AM
This would be amazing, and it sounds like it would be easy to implement! Maybe we could even have it (at least experimentally) for 1.5?
#103
Bugs & Feature requests / Re: Universal Windows App
June 27, 2016, 10:22:37 PM
It looks like UWP is only for Windows 10 and Windows 10 Mobile. I have a Windows 10 PC and could probably help with the compilation, but I don't have a lot of experience compiling C++ programs.
#104
Bugs & Feature requests / Re: Universal Windows App
June 27, 2016, 02:33:11 PM
UWA only works for XBox One. And this would not be a port, it would be compiling the existing Windows version in such as way that it supports this additional architecture that Microsoft has given us easy access to. It would allow Solarus to work on a console with (hopefully) minimal work on Christopho's part. He's a busy man
#105
Bugs & Feature requests / Re: Universal Windows App
June 26, 2016, 10:25:33 PM
This topic is specific to Solarus on Xbox as a technical capability due to the recent release by Microsoft of the Universal Windows Program, not about what systems it would be cool to have Solarus on. I kindly request that this remain on topic.