Help me verify an image.gl_load() bug

Its very easy to test this bug and should not take you more than a minute to do so.

  1. go to image editor and load an image of your choosing

  2. Go to text editor or the console and enter/run there this code

 
img = bpy.data.images[0]
texture= img.gl_load()
print("Opengl Error value:", texture)
print("Bindcode : ",img.bindcode)

  1. and please paste back anything the print , prints to you.

thanks for your help.

PS: in case you wonder what the above code does, it just try to load the latest image you loaded in the image editor as opengl texture so that it can be used by the bgl library which can display it on top of blender windows. It prints the error that makes the load fail (it should return 0 if the load is successful). Bindcode is the code (just a number) that points to the image that is loaded in the opengl memory.

I got:


Opengl Error value: 0
Bindcode :  7

So i guess it’s a not bug?

Could you check some code for me, I know I should ask in a separate thread, but I just need someone else to run this line for me:

bpy.types.CyclesRenderSettings.samples = 100

Thanks :slight_smile:

Thank you very much, yes it confirms my fear, this is not a blender bug but probably a strange interactiong between blender and my gpu. Bad news indeed :smiley:

Anyway your code will not do what you want. IF you want to change the amount of sample for cycles you will have to do this instead

bpy.context.scene.cycles.preview_samples = 100

assuming you want to change the preview_samples

the object you accessing is just the object used bpy the scene object to store the sample setting, but it does not point to the scene object, so you dont actually affect the usage of cycles.

to give you an idea its like doing

samples = 100
instead of
blender_gui.render.cycles.samples = 100

so generally you should never need to access bpy.types besides defining your own custom types like properties. If you want to change a setting then you will have to find where that type is stored in blender and accessed by the gui or blender itself to be used .

Thanks, that was really helpful :slight_smile:

Good look with your gpu!

When I run your code I get…

Opengl Error value: 0
Bindcode : 6

Kilon, I think your GPU is fine. Try this:


img = bpy.data.images[0]
for i in range(1, 6):  # Make up to 6 tries to load image
    texture = img.gl_load()
    print("Opengl Error value:", texture)
    print("Bindcode : ",img.bindcode)
    if img.bindcode != 0:
        break

I had this problem with gl_load when adding the map function for the sun position addon. Before adding the retry code, I noticed that sometimes the image would go blank (this happened on different machines).

After investigating, I decided bindcode always needs to be checked when the draw callback portion of code is executed, even after gl_load was successful at some point. Sometimes it would take up to 3 retries of gl_load before bindcode was 0. Although I never saw more than 3 needed retries,I gave 6 as an upper limit just to be sure. Once I did this, I never had blank images again.

Is it a bug with gl_load? I don’t know. I remember reading in an online openGL manual that error codes need to be frequently checked and I reasoned that with textures being swapped in and out of the GPU, you couldn’t always be guaranteed that your image would remain without doing a little work, i.e. reloading the image with gl_load.

Blender 2.62.0
Win7 Pro 64-bit
4 GB ram
Video chipset is some integrated Intel offering. It has a GPU but it is nothing special by any means.

Blender crashes when I make the “img.gl_load()” call.

Are you getting a crash or an error code? Are you sure that your image format is compatible with the GL context you are rendering into?

my pleasure .

yeah pretty much confirms my fears , its my gpu

no it does not crash for me, most likely its your crappy (no offense) gpu, intel integrated are the worst ones and do not even provide proper support for opengl.

Yeah I am sure I am doing it right , because it used to work with 2.57 with no problems. Devs changed the behavior of gl loading of textures / images and made my life more difficult :smiley: But I blame my lack of knowledge of Opengl which I need to study thoroughly.

None taken, it’s just a stock laptop that work gives out.

Ya know, the error codes that gl_load returns should tell you what is going wrong…in theory at least, it just return the error from openGL so if that is less than helpful not much can be done.

When I ported over the image GL loading stuff to 2.5x I was (and still am) on a crappy intel gpu so I doubt that has anything to do with it, if your gpu can show icons in the UI then it can show images in the 3dview using bgl.

IDK, maybe it needs to throw an exception if the image fails to load instead of just returning the error code so it can be done in a try/except block?

----edit----

Just looked at the source and it looks like the same old code that has always been there from the initial port.

my pleasure .

yeah pretty much confirms my fears , its my gpu

no it does not crash for me, most likely its your crappy (no offense) gpu, intel integrated are the worst ones and do not even provide proper support for opengl.

Yeah I am sure I am doing it right , because it used to work with 2.57 with no problems. Devs changed the behavior of gl loading of textures / images and made my life more difficult :smiley: But I blame my lack of knowledge of Opengl which I need to study thoroughly.

anyway i leave you with a screenshot of texture morphs from my Morpheas new add ons gui :wink: Morpheas draws on top of Blender GUI and its goal is to not affect standard Blender gui behavior in any way.


Hey kilon,
did you see this message - it should solve your problem …
I tried it out myself and got:

Opengl Error value: 0
Bindcode : 40

But once i got an Error or something, but this surely was something else (as i got a value of 2012 or so … quite high at least).

By the way, i’m quite impressed of your project and of the Enepher - was this the virtual programming one? - i somehow forgot.
If this works, godness, this will be awesome, blender will become even more powerfull, although that’s hardly possible.

Keep going, citizens of earth! :cool: :eek:
jon

until we realize Knight’s K.I.T.T. using higg’s field

oups I missed that reply , thanks for pointing out, that is what happens when you trust email notifications too much.

Anyway I will definetly try it out his solution tomorrow and keep you posted.

Yeah part of Ephestos is Proteas which has the goal of implementing visual coding. As you can see there is already a REPL implemented which is a bit like the python window console inside blender but I hope with advanced features in the not so far future (we look into ways to integrate Ipython in it) and with advantage that unlike the one offered by blender, this one can access your addon objects directly and manipulate its code. And I got loads of suprises on Morpheas side too which is the GUI side of things. My goal is not so much to make Blender more powerful though we introducing already a GUI which is way more powerful than what Blender offers and all pure python, but to make Blender and python a lot easier to use and handle. Hopefully I will release version 1 in 2013. But you can follow my thread for it, I will bump it each month with latest news and features added in.

I love KIT I love Transformer so yes that picture is awesome.

Well I am in the unfortunate position to report that sadly xaire solution did not work for me. I still get error 1281 and bindcode 0 with my work pc though my iMAC works fine with this. I even tried a loop with 10 trys , no luck.

PS : I dont know what has happened with post 11, I edited several times and it keeps going back to copying my previous post . Uncle Entity sorry I was trying to replying to you but it seems i Hit a bug with the forum , anyway I was saying that I agree with you that this problem I am getting is very weird for a GPU that might be old but it plays fine many MMORGS I have tried. So it may be a blender bug afterall.

and to you kastoria I was trying to reply that if a computer does it job , its a good computer and does not matter if it is not perfect. Thanks to all of you for helping me out , I really appreciate this.

Well here’s another possibility as I noticed one of Kilon’s image shots was on a Mac.
A bug for gl_load was reported for Macs in the bug tracker and supposedly fixed in April by Campbell.
Here’s the link:http://projects.blender.org/tracker/?func=detail&atid=498&aid=31036&group_id=9

I’m editing this post as it is out of order with a previous one that I submitted that hasn’t appeared.

Bugs were reported for gl_load for Macs which were supposedly fixed in April.
This was regarding bugtracker ( #31036). If my other post ever shows up, the link is in it which you can follow to get all the details. It may be there are still bugs in gl_load or new ones introduced. Even though you may not be getting crashes, try filling in the parameters for gl_load just to see what happens as in the following:


    texture = img.gl_load(bgl.GL_NEAREST, bgl.GL_NEAREST)

Error code 1281 == GL_INVALID_VALUE.

The only way I know of to figure this out (since it works for almost everyone else) is to step through the function in a debugger and check if it throws an error after every call to find out which value your gfx/drivers doesn’t like.