I write code and play games and stuff. My old username from reddit and HN was already taken and I couldn’t think of anything else I wanted to be called so I just picked some random characters like this:

>>> import random
>>> ''.join([random.choice("abcdefghijklmnopqrstuvwxyz0123456789") for x in range(5)])
'e0qdk'

My avatar is a quick doodle made in KolourPaint. I might replace it later. Maybe.

日本語が少し分かるけど、下手です。

Alt: e0qdk@reddthat.com

  • 1 Post
  • 28 Comments
Joined 9 months ago
cake
Cake day: September 22nd, 2023

help-circle
  • It’s not a GUI library, but Jupyter was pretty much made for the kind of mathematical/scientific exploratory programming you’re interested in doing. It’s not the right tool for making finished products, but is intended for creating lab notebooks that contain executable code snippets, formatted text, and visual output together. Given your background experience and the libraries you like, it seems like it’d be right up your alley.


  • Can Z3 account for lost bits? Did it come up with just one solution?

    It gave me just one solution the way I asked for it. With additional constraints added to exclude the original solution, it also gives me a second solution – but the solution it produces is peculiar to my implementation and does not match your implementation. If you implemented exactly how the bits are supposed to end up in the result, you could probably find any other solutions that exist correctly, but I just did it in a quick and dirty way.

    This is (with a little clean up) what my code looked like:

    solver code
    #!/usr/bin/env python3
    
    import z3
    
    rand1 = 0.38203435111790895
    rand2 = 0.5012949781958014
    rand3 = 0.5278898433316499
    rand4 = 0.5114834443666041
    
    def xoshiro128ss(a,b,c,d):
        t = 0xFFFFFFFF & (b << 9)
        r = 0xFFFFFFFF & (b * 5)
        r = 0xFFFFFFFF & ((r << 7 | r >> 25) * 9)
        c = 0xFFFFFFFF & (c ^ a)
        d = 0xFFFFFFFF & (d ^ b)
        b = 0xFFFFFFFF & (b ^ c)
        a = 0xFFFFFFFF & (a ^ d)
        c = 0xFFFFFFFF & (c ^ t)
        d = 0xFFFFFFFF & (d << 11 | d >> 21)
        return r, (a, b, c, d)
    
    a,b,c,d = z3.BitVecs("a b c d", 64)
    nodiv_rand1, state = xoshiro128ss(a,b,c,d)
    nodiv_rand2, state = xoshiro128ss(*state)
    nodiv_rand3, state = xoshiro128ss(*state)
    nodiv_rand4, state = xoshiro128ss(*state)
    
    z3.solve(a >= 0, b >= 0, c >= 0, d >= 0,
      nodiv_rand1 == int(rand1*4294967296),
      nodiv_rand2 == int(rand2*4294967296),
      nodiv_rand3 == int(rand3*4294967296),
      nodiv_rand4 == int(rand4*4294967296)
      )
    
    

    I never heard about Z3

    If you’re not familiar with SMT solvers, they are a useful tool to have in your toolbox. Here are some links that may be of interest:

    Edit: Trying to fix formatting differences between kbin and lemmy
    Edit 2: Spoiler tags and code blocks don’t seem to play well together. I’ve got it mostly working on Lemmy (where I’m guessing most people will see the comment), but I don’t think I can fix it on kbin.


  • If I understand the problem correctly, this is the solution:

    solution

    a = 2299200278
    b = 2929959606
    c = 2585800174
    d = 3584110397

    I solved it with Z3. Took less than a second of computer time, and about an hour of my time – mostly spent trying to remember how the heck to use Z3 and then a little time debugging my initial program.


  • What I’d do is set up a simple website that uses a little JavaScript to rewrite the date and time into the page and periodically refresh an image under/next to it. Size the image to fit the remaining free space of however you set up the iPad, and then you can stick anything you want there (pictures/reminder text/whatever) with your favorite image editor. Upload a new image to the server when you want to change the note. The idea with an image is that it’s just really easy to do and keeps the amount of effort to redo layout to a minimum – just drag stuff around in your image editor and you’ll know it’ll all fit as expected as long as you don’t change the resolution (instead of needing to muck around with CSS and maybe breaking something if you can’t see the device to check that it displays correctly).

    There’s a couple issues to watch out for – e.g. what happens if the internet connection/server goes down, screen burn-in, keeping the browser from being closed/switched to another page, keeping it powered, etc. that might or might not matter depending on your particular circumstances. If you need to fix all that for your circumstances, it might be more trouble than just buying something purpose built… but getting a first pass DIY version working is trivial if you’re comfortable hosting a website.

    Edit: If some sample code that you can use as a starting point would be helpful, let me know.





  • Haven’t used that particular library, but have written libraries that do similar sorts of things and have played with a few other similar libraries in C++ and Haskell. I’ve taken a quick glance at the documentation here, but since I don’t know this library specifically apologizes in advance if I make a mistake.

    For OneOrMore(Word(alphanums)) + OneOrMore(Char(printables)) it looks it matches as many alphanum Words as it can (whitespace sequences being an acceptable separator between tokens by default) and when it hits ( it cannot continue with that so tries to match the next expression in the sequence. (i.e. OneOrMore(Char(printables)))

    The documentation says:

    Char - a convenience form of Word that will match just a single character from a string of matching characters

    Presumably, that means it will not group the characters together, which is why you get individual character matches after that point for all the remaining non-whitespace characters. (Your result also seems to imply there was a semicolon at the end of your input?)

    For OneOrMore(Word(alphanums)) + OneOrMore(Char(string.punctuation)) it looks like it cannot match further than ( since 1 is not a punctuation character; so, you got the tokens for the parts of the string that matched. (If you chained the parser expression with something like + Word(alphanum) I’d expect you’d get another token [i.e. "1"] added onto the end of your result.) You may eventually want StringEnd/LineEnd or something like that – I’d expect they’d fail the parser expression if there’s unconsumed input (for error detection), but again, haven’t used this specific library, so it may work different than I expect.

    There appears to be a Combine class you can use to join string results together; that might be useful for future reference.

    i was trying to parse a string with pyparsing so all the words were separated from the punctuation signs

    Have not tested it (since I don’t have a copy of the library installed anywhere and can’t set up an environment for it easily right now) but perhaps something like OneOrMore(Word(alphanums)|Char(string.punctuation)) would be more like what you are looking for?






  • You’re incorrectly passing the shader type instead of the shader handle as the first argument to the glShaderSource calls. Also, you’ve put vbo instead of ebo for the glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ...) call. If I change those, I get the orange rectangle again.

    This may come in handy if it works on your implementation: https://www.khronos.org/opengl/wiki/Debug_Output

    Note the example code at the very bottom of the page.

    That helped me catch the shader type/handle issue. The vbo/ebo one I noticed by reading the code line by line and saying “wait, elements but you’re passing vbo?!”


  • This is really hard to follow. You will likely find it much easier to learn if you just write simple, top-to-bottom C style code as much as possible while you learn OpenGL and GLFW. You can abstract things into classes later when you have a better feel for the APIs, but right now you are shooting yourself in the foot…

    Your immediate problem seems to be that you did not bind the vertex array after creating it. Changing the code to this:

    VAObject vao(1);
    vao.bind_vao();
    
    

    prevents the crash for me – however, there is also an issue with the vertices. With only the above change, the window is drawn blank. Changing vertices to match the example like this:

    float vertices[] = {
         0.5f,  0.5f, 0.0f,  // top right
         0.5f, -0.5f, 0.0f,  // bottom right
        -0.5f, -0.5f, 0.0f,  // bottom left
        -0.5f,  0.5f, 0.0f   // top left
    };
    
    

    results in an orange rectangle drawn.


  • e0qdk@kbin.socialtoLinux@lemmy.mlOpenGL version problem
    link
    fedilink
    arrow-up
    2
    ·
    edit-2
    9 months ago
    • GLFW is intended to be built with cmake.
    • After unzipping the source, make a build directory, and configure glfw3
    • ^^ I like using ccmake to do this interactively, but you can also just pass flags to cmake if you know what they are
    • You should build with GLFW_USE_WAYLAND and GLFW_USE_OSMESA turned off to get it to try to build against X11.
    • You will probably also want to turn off GLFW_BUILD_DOCS, GLFW_BUILD_EXAMPLES, GLFW_BUILD_TESTS
    • You can adjust CMAKE_INSTALL_PREFIX if you don’t want to use the /usr/local default install path.
    • After generating a Makefile, run make and make install
    • glfw3 generates a pkg-config compatible .pc file as part of its build process that lists flags needed for compilation and linking against the library. Normally, you’d just call pkg-config --cflags --libs --static glfw3 to get this info as part of your own build process (in a Makefile, for example) or else require glfw3 as part of a cmake-based build, but you can read what’s generated in there if that program is not available to you for some reason. In case it’s helpful for comparison, what I get with a custom build of the static library version of glfw3 installed into /usr/local on a slightly old version of Ubuntu is output like -I/usr/local/include -L/usr/local/lib -lglfw -lrt -lm -ldl -lX11 -lpthread -lxcb -lXau -lXdmcp but you may need something different for your particular configuration.

    Basically, something like this, probably, to do the compilation and get the flags to pass to g++:

    wget 'https://github.com/glfw/glfw/releases/download/3.3.8/glfw-3.3.8.zip'
    unzip glfw-3.3.8.zip
    mkdir build
    cd build
    cmake -D GLFW_BUILD_DOCS=OFF -D GLFW_BUILD_EXAMPLES=OFF -D GLFW_BUILD_TESTS=OFF -D GLFW_USE_OSMESA=OFF -D GLFW_USE_WAYLAND=OFF -D GLFW_VULKAN_STATIC=OFF ../glfw-3.3.8
    make
    make install
    
    pkg-config --cflags --libs --static glfw3
    
    

    If you want to just compile a single cpp file after building and install, you can do something like

    g++ main.cpp `pkg-config --cflags --libs --static glfw3` -lGL
    
    


    • You are running Wayland
    • Your GLFW programs are using EGL, not GLX, to talk to your graphics drivers/hardware
    • glxinfo is talking to a software implementation, not your hardware
    • glxinfo’s output is irrelevant if you want to talk to your hardware with your current configuration; if you want to use the software implementation recompile GLFW targeting GLX and it should match that (but will be VERY slow).
    • One of your old posts describes your GPU as: Intel GMA3100 (G31) – is this the same system you’re running on now? If so, that is ancient. It looks like that came out in 2007 – which predates the existence of OpenGL 3.0; so, getting 2.1 as the newest context available when talking to actual hardware is not surprising…


  • 65543 seems to be the constant defined for GLFW_VERSION_UNAVAILABLE passed back from the error handling code I was looking at in egl_context.c – that helps confirm I’m looking at the right chunk of code in GLFW’s guts, thanks.

    As I suggested in my other comment, try commenting out the hint lines and see if a window shows up at all. (Your program doesn’t do anything other than quit after making the window, so it should just flash a window briefly, I’d expect.)


  • I was digging around in the GLFW code a bit before I saw your comment, and the “Arguments are inconsistent” message seems to be how GLFW describes an EGL_BAD_MATCH error code. There’s a few places in egl_context.c where getEGLErrorString is called that could return that string, but it’s probably in _glfwCreateContextEGL given the “Failed to create context” part of the error quoted.

    The error handling there (if this is the right place – I would have also expected “EGL” in the message, but maybe OP dropped it) follows a failure of eglCreateContext. The reference documentation for that function here – https://registry.khronos.org/EGL/sdk/docs/man/html/eglCreateContext.xhtml – unfortunately doesn’t give much detail about the kinds of errors that can happen, but does talk about OpenGL versions so a mismatch on that makes sense; I think this is on the right track.

    Googling the OpenGL renderer string: llvmpipe (LLVM 16.0.6, 128 bits) line from the glxinfo output suggests that’s software rendering, so the OpenGL version shown there may differ from what is actually supported by hardware rendering. Is there an EGL equivalent to glxinfo? (eglinfo, maybe?)

    I’d personally comment out all the glfwWindowHint calls and see if a window shows up at all – then mess with the OpenGL version if needed.