Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

December 9,2009 by gleicher (link) glContexts – or why don my textures and shaders load?

0
Posted

December 9,2009 by gleicher (link) glContexts – or why don my textures and shaders load?

0

If your textures or shaders aren’t loading correctly, the problem might be when you’re doing it, even if you are doing it correctly. This is a common problem. You can only make calls to OpenGL (for example to initialize a texture or load a shader) once OpenGL is fully initialized and ready to go. Also, once you have OpenGL ready to go, you can only do things if OpenGL knows which window to associate the commands with. This is called “having a GL context.” So, basically, the only time you can make calls to OpenGL (including loading shaders or textures) is inside of the “draw” method of an FlTk Widget (or the draw methods of your object). If you look at the sample code, you’ll notice that things get initialized the first time draw is called (rather than in the constructor).

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123