gl3w icon indicating copy to clipboard operation
gl3w copied to clipboard

Make prebuild gl3w.c/.h available

Open ocornut opened this issue 9 years ago • 7 comments

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!

ocornut avatar Nov 22 '15 17:11 ocornut

+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).

tombsar avatar Dec 14 '15 10:12 tombsar

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

dbechrd avatar Apr 09 '16 20:04 dbechrd

+1

sonoro1234 avatar Dec 10 '16 15:12 sonoro1234

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

warmist avatar Oct 18 '17 09:10 warmist

@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.

skaslev avatar Oct 18 '17 10:10 skaslev

@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()

golightlyb avatar Jun 30 '18 12:06 golightlyb

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

podsvirov avatar Jul 03 '18 22:07 podsvirov