Git Product home page Git Product logo

Comments (21)

 avatar commented on July 29, 2024

Hello,

Thanks for buying the book!

Regarding your error, a few questions/suggestions:

  1. Are you able to run the first OpenGL project in chapter 9?

    https://github.com/electronut/pp/tree/master/simplegl

  2. Instead of copying the dll and hardcoding paths, could you follow the process outlined in Appendix A, page 298? (See image below.)

The error indicates that the OpenGL context is invalid, which could be due to a number of reasons, but let's try to get the chapter 9 code to work first.

screen shot 2016-04-11 at 9 04 50 am

from pp.

patmo141 avatar patmo141 commented on July 29, 2024

Re ch9: You have caught me! Trying to run before I walk. Yes I will try this first.

Re PATH: Yes that's no problem, it was just laziness on my part.

It will probably be sometime toward end of week. Thanks, Patrick

from pp.

 avatar commented on July 29, 2024

Sure. Let me know if you need help.

from pp.

patmo141 avatar patmo141 commented on July 29, 2024

Ok, couldn't resist playing some more.

  1. I set up my PYTHONPATH and GLFW_LIBRARY environment variables
  2. I read (ok, I read part of and skimmed all of) Ch. 9
  3. I ran simpleglfw.py and....

image

More information to come

from pp.

 avatar commented on July 29, 2024

Could you try this quick test:

 > cd c:\dev\...\simplegl
 > python simpleglfw.py

Just wondering if it's still a path issue.

from pp.

patmo141 avatar patmo141 commented on July 29, 2024

image

I have multiple python versions so I did a slightly different by explicity pointing to python34 since that is where my OpenGL is installed in site-packages.

from pp.

 avatar commented on July 29, 2024

I am a bit stumped...

How about the official glfw example below. Can you try running it?

https://pypi.python.org/pypi/glfw

If you can't run the above, one guess would be that your OS doesn't have an OpenGL driver installed. Could you try installing a driver for your graphics card? If you send me the system details, I can try to help.

from pp.

patmo141 avatar patmo141 commented on July 29, 2024

While I am getting driver's updated. I have one of those dual graphics card situations, where the builtin chip operates some times, and the dedicated GPU works others.

image

from pp.

 avatar commented on July 29, 2024

Any luck with the official glfw example?

from pp.

patmo141 avatar patmo141 commented on July 29, 2024

was able to run hello world gflw example from https://pypi.python.org/pypi/glfw
I downloaded glfw.py from https://github.com/FlorianRhiem/pyGLFW
I had to hardcode the location of glfw3.dll in that example because it could not find it even with the envorinment variable set, however once I did that, all was well

image

from pp.

 avatar commented on July 29, 2024

So if the official glfw sample works, simpleglfw.py should work?

from pp.

patmo141 avatar patmo141 commented on July 29, 2024

The bindings are all different in the github version https://github.com/FlorianRhiem/pyGLFW/blob/master/glfw.py For example glfw.init() vs glfw.glfwInit(). I will alter them and see if I can get glsimple.py to work if I change the bindings.

from pp.

patmo141 avatar patmo141 commented on July 29, 2024

Ok, I changed all the functions in simpleglfw.py to match the glfw.py bindings from github, and I get the same error 'invalid operation', so I must have an issue with OpenGL drivers or PyOpenGL

from pp.

 avatar commented on July 29, 2024

Can we go back to the glfw example:

https://pypi.python.org/pypi/glfw

Do NOT use https://github.com/FlorianRhiem/pyGLFW

You should be using glfw.py from the common/ directory of the book's source code.

Can you send me your PYTHONPATH?

from pp.

patmo141 avatar patmo141 commented on July 29, 2024

the example code from pypi.python.org will not work with pp-master/common/glfw.py because the bindings are defined differently (eg, CamelCase vs lower_case).

My PYTHONPATH is only "C:\Dev\pp-master\common" I do the majority of my work in Blender python so I have not added anything to PYTHONPATH except this project :-)

from pp.

patmo141 avatar patmo141 commented on July 29, 2024

I am starting fresh, updating drivers, installing PyOpenGL from PyPi, downloading fresh pp-master source to eliminate any setup errors on my part. Thanks for all of your help so far! I'll report back shortly

from pp.

patmo141 avatar patmo141 commented on July 29, 2024

Step 1. Fresh pp-master directory
Step 2. PYTHONPATH: "C:\Dev\pp-master\common",
Step 3. GLFW_LIBRARY "C\Dev\glfw\lib-vc2012\glfw3.dll
Step 4. Modify the example from PyPi to match the functions in C:\Dev\pp-master\common\glfw.py

import glfw

def main():
    # Initialize the library
    if not glfw.glfwInit():
        return
    # Create a windowed mode window and its OpenGL context
    window = glfw.glfwCreateWindow(640, 480)
    if not window:
        print("failed to open window")
        glfw.glfwTerminate()
        return
    # Make the window's context current
    glfw.glfwMakeContextCurrent(window)

    # Loop until the user closes the window
    while not glfw.glfwWindowShouldClose(window):
        # Render here, e.g. using pyOpenGL

        # Swap front and back buffers
        glfw.glfwSwapBuffers(window)

        # Poll for and process events
        glfw.glfwPollEvents()

    glfw.glfwTerminate()

if __name__ == "__main__":
    main()

This works, I get a blank glfw window

from pp.

patmo141 avatar patmo141 commented on July 29, 2024

So, hours and hours ago, I tried global settings to test Nvida card and Builtin Intel card. Apparently it was ignoring my settings because once I specified that Python uses the Nvidia card, it works.

image

from pp.

 avatar commented on July 29, 2024

Awesome. Glad to see it working!

from pp.

patmo141 avatar patmo141 commented on July 29, 2024

Me too. I'm sorry I hope I did not waste too much of your time. And for final closure

image

from pp.

 avatar commented on July 29, 2024

Happy to help!

A request:

If you like the book, please take a few minutes to write a review on amazon.com:

http://www.amazon.com/Python-Playground-Projects-Curious-Programmer/dp/1593276044

from pp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.