Skip to content

Commit

Permalink
Initial.
Browse files Browse the repository at this point in the history
  • Loading branch information
aglitchman committed Sep 13, 2023
0 parents commit 450b5bb
Show file tree
Hide file tree
Showing 26 changed files with 1,916 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
BasedOnStyle: LLVM
ColumnLimit: 120
IncludeBlocks: Regroup
IndentWidth: 4
TabWidth: 4

...
53 changes: 53 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Defold Protocol Buffer Text Files (https://github.com/github/linguist/issues/5091)
*.animationset linguist-language=JSON5 gitlab-language=protobuf
*.atlas linguist-language=JSON5 gitlab-language=protobuf
*.camera linguist-language=JSON5 gitlab-language=protobuf
*.collection linguist-language=JSON5 gitlab-language=protobuf
*.collectionfactory linguist-language=JSON5 gitlab-language=protobuf
*.collectionproxy linguist-language=JSON5 gitlab-language=protobuf
*.collisionobject linguist-language=JSON5 gitlab-language=protobuf
*.cubemap linguist-language=JSON5 gitlab-language=protobuf
*.display_profiles linguist-language=JSON5 gitlab-language=protobuf
*.factory linguist-language=JSON5 gitlab-language=protobuf
*.font linguist-language=JSON5 gitlab-language=protobuf
*.gamepads linguist-language=JSON5 gitlab-language=protobuf
*.go linguist-language=JSON5 gitlab-language=protobuf
*.gui linguist-language=JSON5 gitlab-language=protobuf
*.input_binding linguist-language=JSON5 gitlab-language=protobuf
*.label linguist-language=JSON5 gitlab-language=protobuf
*.material linguist-language=JSON5 gitlab-language=protobuf
*.mesh linguist-language=JSON5 gitlab-language=protobuf
*.model linguist-language=JSON5 gitlab-language=protobuf
*.particlefx linguist-language=JSON5 gitlab-language=protobuf
*.render linguist-language=JSON5 gitlab-language=protobuf
*.sound linguist-language=JSON5 gitlab-language=protobuf
*.sprite linguist-language=JSON5 gitlab-language=protobuf
*.spinemodel linguist-language=JSON5 gitlab-language=protobuf
*.spinescene linguist-language=JSON5 gitlab-language=protobuf
*.texture_profiles linguist-language=JSON5 gitlab-language=protobuf
*.tilemap linguist-language=JSON5 gitlab-language=protobuf
*.tilesource linguist-language=JSON5 gitlab-language=protobuf

# Defold JSON Files
*.buffer linguist-language=JSON gitlab-language=json

# Defold GLSL Shaders
*.fp text eol=lf linguist-language=GLSL gitlab-language=glsl
*.vp text eol=lf linguist-language=GLSL gitlab-language=glsl

# Defold Lua Files
*.editor_script text eol=lf linguist-language=Lua gitlab-language=lua
*.render_script text eol=lf linguist-language=Lua gitlab-language=lua
*.script text eol=lf linguist-language=Lua gitlab-language=lua
*.gui_script text eol=lf linguist-language=Lua gitlab-language=lua

# Defold Project Settings
*.project linguist-language=INI gitlab-language=ini

# EOL Settings
*.cpp text eol=lf
*.html text eol=lf
*.json text eol=lf
*.lua text eol=lf
*.md text eol=lf
*.yml text eol=lf
38 changes: 38 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
47 changes: 47 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Build example

on:
workflow_dispatch:
push:
branches:
- main

jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3

- name: Install Java ♨️
uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: "17"

- name: Build 🔧
env:
DEFOLD_BOB_SHA1: ${{ secrets.DEFOLD_BOB_SHA1 }}
run: |
lsb_release -a
mkdir -p build/bundle
# Download the latest bob.jar
BOB_SHA1=${DEFOLD_BOB_SHA1:-$(curl -s 'https://d.defold.com/stable/info.json' | jq -r .sha1)}
BOB_LOCAL_SHA1=$((java -jar build/bundle/bob.jar --version | cut -d' ' -f6) || true)
if [ "${BOB_LOCAL_SHA1}" != "${BOB_SHA1}" ]; then wget --progress=dot:mega -O build/bundle/bob.jar "https://d.defold.com/archive/${BOB_SHA1}/bob/bob.jar"; fi
java -jar build/bundle/bob.jar --version
# Build the project
java -jar build/bundle/bob.jar --email a@b.com --auth 123 --texture-compression true --bundle-output build/bundle/js-web --platform js-web --archive --variant debug resolve build bundle
# Move to the public directory
mv build/bundle/js-web/* build/bundle/public
- name: Deploy to Pages 🚀
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: build/bundle/public
if: github.ref == 'refs/heads/main'
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/.internal
/build
.externalToolBuilders
.DS_Store
Thumbs.db
.lock-wscript
*.pyc
.project
.cproject
builtins
3 changes: 3 additions & 0 deletions .lua-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
column_limit: 120
keep_simple_control_block_one_line: false
keep_simple_function_one_line: false
2 changes: 2 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tabWidth: 4
printWidth: 120
121 changes: 121 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
Creative Commons Legal Code

CC0 1.0 Universal

CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
HEREUNDER.

Statement of Purpose

The laws of most jurisdictions throughout the world automatically confer
exclusive Copyright and Related Rights (defined below) upon the creator
and subsequent owner(s) (each and all, an "owner") of an original work of
authorship and/or a database (each, a "Work").

Certain owners wish to permanently relinquish those rights to a Work for
the purpose of contributing to a commons of creative, cultural and
scientific works ("Commons") that the public can reliably and without fear
of later claims of infringement build upon, modify, incorporate in other
works, reuse and redistribute as freely as possible in any form whatsoever
and for any purposes, including without limitation commercial purposes.
These owners may contribute to the Commons to promote the ideal of a free
culture and the further production of creative, cultural and scientific
works, or to gain reputation or greater distribution for their Work in
part through the use and efforts of others.

For these and/or other purposes and motivations, and without any
expectation of additional consideration or compensation, the person
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
is an owner of Copyright and Related Rights in the Work, voluntarily
elects to apply CC0 to the Work and publicly distribute the Work under its
terms, with knowledge of his or her Copyright and Related Rights in the
Work and the meaning and intended legal effect of CC0 on those rights.

1. Copyright and Related Rights. A Work made available under CC0 may be
protected by copyright and related or neighboring rights ("Copyright and
Related Rights"). Copyright and Related Rights include, but are not
limited to, the following:

i. the right to reproduce, adapt, distribute, perform, display,
communicate, and translate a Work;
ii. moral rights retained by the original author(s) and/or performer(s);
iii. publicity and privacy rights pertaining to a person's image or
likeness depicted in a Work;
iv. rights protecting against unfair competition in regards to a Work,
subject to the limitations in paragraph 4(a), below;
v. rights protecting the extraction, dissemination, use and reuse of data
in a Work;
vi. database rights (such as those arising under Directive 96/9/EC of the
European Parliament and of the Council of 11 March 1996 on the legal
protection of databases, and under any national implementation
thereof, including any amended or successor version of such
directive); and
vii. other similar, equivalent or corresponding rights throughout the
world based on applicable law or treaty, and any national
implementations thereof.

2. Waiver. To the greatest extent permitted by, but not in contravention
of, applicable law, Affirmer hereby overtly, fully, permanently,
irrevocably and unconditionally waives, abandons, and surrenders all of
Affirmer's Copyright and Related Rights and associated claims and causes
of action, whether now known or unknown (including existing as well as
future claims and causes of action), in the Work (i) in all territories
worldwide, (ii) for the maximum duration provided by applicable law or
treaty (including future time extensions), (iii) in any current or future
medium and for any number of copies, and (iv) for any purpose whatsoever,
including without limitation commercial, advertising or promotional
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
member of the public at large and to the detriment of Affirmer's heirs and
successors, fully intending that such Waiver shall not be subject to
revocation, rescission, cancellation, termination, or any other legal or
equitable action to disrupt the quiet enjoyment of the Work by the public
as contemplated by Affirmer's express Statement of Purpose.

3. Public License Fallback. Should any part of the Waiver for any reason
be judged legally invalid or ineffective under applicable law, then the
Waiver shall be preserved to the maximum extent permitted taking into
account Affirmer's express Statement of Purpose. In addition, to the
extent the Waiver is so judged Affirmer hereby grants to each affected
person a royalty-free, non transferable, non sublicensable, non exclusive,
irrevocable and unconditional license to exercise Affirmer's Copyright and
Related Rights in the Work (i) in all territories worldwide, (ii) for the
maximum duration provided by applicable law or treaty (including future
time extensions), (iii) in any current or future medium and for any number
of copies, and (iv) for any purpose whatsoever, including without
limitation commercial, advertising or promotional purposes (the
"License"). The License shall be deemed effective as of the date CC0 was
applied by Affirmer to the Work. Should any part of the License for any
reason be judged legally invalid or ineffective under applicable law, such
partial invalidity or ineffectiveness shall not invalidate the remainder
of the License, and in such case Affirmer hereby affirms that he or she
will not (i) exercise any of his or her remaining Copyright and Related
Rights in the Work or (ii) assert any associated claims and causes of
action with respect to the Work, in either case contrary to Affirmer's
express Statement of Purpose.

4. Limitations and Disclaimers.

a. No trademark or patent rights held by Affirmer are waived, abandoned,
surrendered, licensed or otherwise affected by this document.
b. Affirmer offers the Work as-is and makes no representations or
warranties of any kind concerning the Work, express, implied,
statutory or otherwise, including without limitation warranties of
title, merchantability, fitness for a particular purpose, non
infringement, or the absence of latent or other defects, accuracy, or
the present or absence of errors, whether or not discoverable, all to
the greatest extent permissible under applicable law.
c. Affirmer disclaims responsibility for clearing rights of other persons
that may apply to the Work or any use thereof, including without
limitation any person's Copyright and Related Rights in the Work.
Further, Affirmer disclaims responsibility for obtaining any necessary
consents, permissions or other rights required for any use of the
Work.
d. Affirmer understands and acknowledges that Creative Commons is not a
party to this document and has no duty or obligation with respect to
this CC0 or use of the Work.
58 changes: 58 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# WebGL memory tracker for Defold

A quick and easy way to find out the GPU and CPU memory usage of your Defold game on HTML5 platform.

So, this is an adaptation into a native extension of the great [WebGL-Memory](https://github.com/greggman/webgl-memory) script for the Defold engine. You add the extension to your project, then you can ask how much WebGL memory and resources you're using. It's important to keep in mind that WebGL-Memory tries to approximate the data, so the statistics may not be accurate.

As a bonus, this extension adds the size of the heap used by the game.

## Quick Start

Add this project as a [Defold library dependency](http://www.defold.com/manuals/libraries/). Open your `game.project` file and in the dependencies field under project add:

https://github.com/indiesoftby/defold-webgl-memory/archive/main.zip

Request for the data:

```lua
if webgl_memory then
local info = webgl_memory.get_info()
print("GPU memory used in total: " .. math.floor(info.memory.total / 1024 / 1024) .. " MB")
print("CPU heap size: " .. math.floor(info.memory.wasmheap / 1024 / 1024) .. " MB")
end
```

## Advanced Usage

When you call `webgl_memory.get_info()`, the result is:

```lua
{
memory = {
buffer = <bytes used by buffers>,
texture = <bytes used by textures>,
renderbuffer = <bytes used by renderbuffers>,
drawingbuffer = <bytes used by the canvas>,
total = <bytes used in total>,
wasmheap = <bytes used by the Defold engine>, -- is injected by the extension and equals to `Module.HEAP8.length`.
},
resources = {
buffer = <count of buffers>,
renderbuffer = <count of renderbuffers>,
program = <count of programs>,
query = <count of query objects, WebGL2 only>,
sampler = <count of samplers, WebGL2 only>,
shader = <count of shaders>,
sync = <count of sync objects, WebGL2 only>,
texture = <count of textures>,
transformFeedback = <count of transformfeedbacks, WebGL2 only>,
vertexArray = <count of vertexArrays, only if used or WebGL2>,
}
}
```

## Credits

This project is licensed under the terms of the CC0 1.0 Universal license. It's developed and supported by [@aglitchman](https://github.com/aglitchman).

It includes includes a release version of WebGL-Memory, license MIT.
15 changes: 15 additions & 0 deletions example/assets/defold-white-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 450b5bb

Please sign in to comment.