But, this doesn’t work… I have written code for doing this before, but I don’t know what I’ve done wrong this time… but by looking at my code it feels like im forgeting something obviouse…
Your glCopyTexSubImage2D call looks ok. It assumes a texture format has already been chosen/is present, no format parameter needed. For your glCopyTexImage2D call I would specify GL_RGB8 as the internal format or whatever it is you use.
Why do you copy the image both on “init” and on “update”? It would seem that you only need to copy the data on “update”. I also don’t see you actually creating the texture levels anywhere – that first image copy is likely to fail. Perhaps you meant “glTexImage2D()” at that point?
That kind of error is easily caught if you litter your code with “assert(!glGetError());” absolutely EVERYWHERE! Putting this at the beginning and end of each function that calls GL is a good start.
Originally posted by jwatte: I also don’t see you actually creating the texture levels anywhere – that first image copy is likely to fail. Perhaps you meant “glTexImage2D()” at that point?
It looks perfectly fine to me. Remember that glCopyTexImage2D IS glTexImage2D but it takes pixel data from the frame buffer instead of system mem.
What I get is just a blank black texture… The code I posted is the only code I have for that part of my texture class for rendering to texture… I feel like I’m missing something…
Originally posted by jwatte: Meanwhile, I think a bunch of assert(!glGetError()) calls would still help find issues
For sure, I use it all the time nowadays after I saw one of your postings. It’s a life saver. Not only does it catch the obvious mistakes, but also helps finding inconsistencies within driver versions. One driver version might silently accept faulty code while another fails it.