Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make prebuild gl3w.c/.h available #25

Open
ocornut opened this issue Nov 22, 2015 · 7 comments
Open

Make prebuild gl3w.c/.h available #25

ocornut opened this issue Nov 22, 2015 · 7 comments

Comments

@ocornut
Copy link

ocornut commented Nov 22, 2015

May I suggest creating a separate repository to publish prebuilt gl3w.c/.h ?
Running Python is an additional step that is pretty much in the way for most people willing to use the resulting output (especially for Windows users). And it'd be nice to have versioned updates of gl3w.c following updates of glcorearb.h

Thanks a lot!

@tombsar
Copy link
Collaborator

tombsar commented Dec 14, 2015

+1 I can't think of a good reason not to do this, unless there is a copyright/licensing issue (my reading of glcorearb.h suggests not).

@dbechrd
Copy link

dbechrd commented Apr 9, 2016

Please do this.. I really don't want to have to install Python to build a single header file.

@sonoro1234
Copy link

+1

@warmist
Copy link

warmist commented Oct 18, 2017

I know this is a ancient issue, but i think this could have releases done (semi) automatically?

@skaslev
Copy link
Owner

skaslev commented Oct 18, 2017

@warmist I like the idea. A script can run periodically, downloading glcorearb.h, compare it with the one from the latest gl3w release and cook a new release if they differ.

I'll take a stab at it when I find some time. In the mean time PRs are welcome.

@golightlyb
Copy link

@skaslev - if you leave the generated files as part of the repo, people could just wget or download the raw versions straight from GitHub.

In case its useful to anyone else, here's my python script that downloads gl3w, glxext.h, wglext.h, then runs gl3w. It's still python but it's one step rather than cloning a repo then running a file etc.

get-deps.py

import helpers

helpers.file_get("gl3w_gen.py", "gl3w_gen", "https://raw.githubusercontent.com/skaslev/gl3w/master/gl3w_gen.py")
helpers.file_get("include/GL/glxext.h", "glxext.h", "https://www.khronos.org/registry/OpenGL/api/GL/glxext.h")
helpers.file_get("include/GL/wglext.h", "wglext.h", "https://www.khronos.org/registry/OpenGL/api/GL/wglext.h")

print("\ngl3w_gen:")
import gl3w_gen

helpers/init.py

import os
import requests
import sys
import time

CHUNK_SIZE = 32*1024


class Progress:
    def __init__(self, text):
        self.current = 0
        self.old_current = 0
        self.max = 100
        self.tolerance = 100.0 / 211 # first prime > 200
        self.lastline = ""
        sys.stdout.write(text)
        sys.stdout.flush()
    
    def start(self, total):
        self.max = total
        self.tolerance = (1.0 * total) / 211 # first prime > 200

    def update(self, current):
        self.old_current += self.current
        self.current = current

        if abs(self.current - self.old_current) > self.tolerance:
            self.display()
            self.old_current = current

    def done(self):
        self.out("Done")
        sys.stdout.write("\n")
        sys.stdout.flush()

    def display(self):
        pc = (100.0 * self.current) / self.max
        self.out("%d/%d (%.1f%%)" % (self.current, self.max, pc))

    def out(self, line):
        padding = len(self.lastline) - len(line)
        if padding > 0:
            padding = " " * padding
        else:
            padding = ""

        sys.stdout.write(("\b"*len(self.lastline)) + line + padding)
        sys.stdout.flush()
        self.lastline = line


def file_get(dest, name, uri):
    if os.path.isfile(dest):
        print("Cached: %s" % name)
        return

    progress = Progress("Downloading %s: " % name)

    r = requests.get(uri, stream=True)
    if not "content-length" in r.headers:
        raise Exception("Missing content-length (download not found?) for %s" % uri)

    with open(dest, 'wb') as f:
        content_length = int(r.headers.get('content-length'))
        chunk_size = CHUNK_SIZE
        was_read = 0
        progress.start(content_length)
        for chunk in r.iter_content(chunk_size=chunk_size):
            if chunk:
                was_read += len(chunk)
                f.write(chunk)
                f.flush()
                progress.update(was_read)
        progress.done()

@podsvirov
Copy link
Contributor

Hello all!
Please review #59 - it's allow make install CMake's gl3w package and then use it without python.

Repository owner deleted a comment from uday7981 Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants