-
-
Notifications
You must be signed in to change notification settings - Fork 277
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use resource pointers all the way for GUI textures (#8945)
* Use resource pointers all the way * Test wip * Add test
- Loading branch information
Showing
8 changed files
with
298 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
engine/gamesys/src/gamesys/test/gui/texture_resources/texture_resources.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
components { | ||
id: "gui" | ||
component: "/gui/texture_resources/texture_resources.gui" | ||
} | ||
components { | ||
id: "script" | ||
component: "/gui/texture_resources/texture_resources.script" | ||
} |
93 changes: 93 additions & 0 deletions
93
engine/gamesys/src/gamesys/test/gui/texture_resources/texture_resources.gui
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
script: "/gui/texture_resources/texture_resources.gui_script" | ||
textures { | ||
name: "atlas" | ||
texture: "/atlas/valid.atlas" | ||
} | ||
textures { | ||
name: "texture" | ||
texture: "/texture/valid_png.png" | ||
} | ||
background_color { | ||
x: 0.0 | ||
y: 0.0 | ||
z: 0.0 | ||
w: 0.0 | ||
} | ||
material: "/gui/gui.material" | ||
adjust_reference: ADJUST_REFERENCE_PARENT | ||
max_nodes: 512 | ||
|
||
nodes { | ||
position { | ||
x: 1.0 | ||
y: 0.0 | ||
z: 0.0 | ||
w: 0.0 | ||
} | ||
rotation { | ||
x: 1.0 | ||
y: 0.0 | ||
z: 0.0 | ||
w: 0.0 | ||
} | ||
scale { | ||
x: 1.0 | ||
y: 0.0 | ||
z: 0.0 | ||
w: 0.0 | ||
} | ||
size { | ||
x: 1.0 | ||
y: 0.0 | ||
z: 0.0 | ||
w: 0.0 | ||
} | ||
color { | ||
x: 1.0 | ||
y: 0.0 | ||
z: 0.0 | ||
w: 0.0 | ||
} | ||
id: "box1" | ||
type: TYPE_BOX | ||
blend_mode: BLEND_MODE_ALPHA | ||
texture: "texture" | ||
} | ||
|
||
nodes { | ||
position { | ||
x: 1.0 | ||
y: 0.0 | ||
z: 0.0 | ||
w: 0.0 | ||
} | ||
rotation { | ||
x: 1.0 | ||
y: 0.0 | ||
z: 0.0 | ||
w: 0.0 | ||
} | ||
scale { | ||
x: 1.0 | ||
y: 0.0 | ||
z: 0.0 | ||
w: 0.0 | ||
} | ||
size { | ||
x: 1.0 | ||
y: 0.0 | ||
z: 0.0 | ||
w: 0.0 | ||
} | ||
color { | ||
x: 1.0 | ||
y: 0.0 | ||
z: 0.0 | ||
w: 0.0 | ||
} | ||
id: "box2" | ||
type: TYPE_BOX | ||
blend_mode: BLEND_MODE_ALPHA | ||
texture: "atlas/valid_png_128" | ||
} | ||
|
28 changes: 28 additions & 0 deletions
28
engine/gamesys/src/gamesys/test/gui/texture_resources/texture_resources.gui_script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
-- Copyright 2020-2024 The Defold Foundation | ||
-- Copyright 2014-2020 King | ||
-- Copyright 2009-2014 Ragnar Svensson, Christian Murray | ||
-- Licensed under the Defold License version 1.0 (the "License"); you may not use | ||
-- this file except in compliance with the License. | ||
-- | ||
-- You may obtain a copy of the License, together with FAQs at | ||
-- https://www.defold.com/license | ||
-- | ||
-- Unless required by applicable law or agreed to in writing, software distributed | ||
-- under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
-- CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
-- specific language governing permissions and limitations under the License. | ||
|
||
function init(self) | ||
local w = 32 | ||
local h = 32 | ||
local orange = string.char(0xff) .. string.char(0x80) .. string.char(0x10) | ||
gui.new_texture("dynamic_texture", w, h, "rgb", string.rep(orange, w * h)) | ||
|
||
local n = gui.new_box_node(vmath.vector3(200, 200, 0), vmath.vector3(w, h, 0)) | ||
gui.set_texture(n, "dynamic_texture") | ||
gui.set_id(n, "box3") | ||
end | ||
|
||
function final(self) | ||
gui.delete_texture("dynamic_texture") | ||
end |
34 changes: 34 additions & 0 deletions
34
engine/gamesys/src/gamesys/test/gui/texture_resources/texture_resources.script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
-- Copyright 2020-2024 The Defold Foundation | ||
-- Copyright 2014-2020 King | ||
-- Copyright 2009-2014 Ragnar Svensson, Christian Murray | ||
-- Licensed under the Defold License version 1.0 (the "License"); you may not use | ||
-- this file except in compliance with the License. | ||
-- | ||
-- You may obtain a copy of the License, together with FAQs at | ||
-- https://www.defold.com/license | ||
-- | ||
-- Unless required by applicable law or agreed to in writing, software distributed | ||
-- under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
-- CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
-- specific language governing permissions and limitations under the License. | ||
|
||
function init(self) | ||
|
||
local tbuffer = buffer.create(32 * 32, { {name=hash("rgba"), type=buffer.VALUE_TYPE_FLOAT32, count=4} } ) | ||
local tstream = buffer.get_stream(tbuffer, hash("rgba")) | ||
local tparams = { | ||
width = 32, | ||
height = 32, | ||
type = resource.TEXTURE_TYPE_2D, | ||
format = resource.TEXTURE_FORMAT_RGBA, | ||
} | ||
|
||
resource.set_texture("/atlas/valid.texturec", tparams, tbuffer) | ||
resource.set_texture("/texture/valid_png.texturec", tparams, tbuffer) | ||
|
||
-- create a new texture and assign the the atlas | ||
local tnew = resource.create_texture("/texture/custom.texturec", tparams, tbuffer) | ||
local atlas_info = resource.get_atlas("/atlas/valid.t.texturesetc") | ||
atlas_info.texture = tnew | ||
resource.set_atlas("/atlas/valid.t.texturesetc", atlas_info) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.