Skip to main content
gamedev.net
🔒 Locked

Reflections

Started by AndyEsser 2 replies 550+ views
Original Post
AndyEsser
AndyEsser
For reflections on consoles and glass etc I've found articles that suggest the use of glReadPixels() but when i've tried to implement this it all goes wrong. I'm doing this: glReadPixels 0, 0, Screen.Width, Screen.height, rpRGB, pxlByte, reflection and it's causing VB to crash to desktop or throw up a memory error. I've tried it with pxlFloat as well and still nothing. Can anyone suggest what's going on? Thanks Andy
Solias
Solias
I've never used opengl with vb, but is reflection big enough to hold the result of the read pixels call? It's possible your vb ogl binding may check the params for you, but the underlying ogl implementation won't. That sounds like the kind of thing that would result in a memory error.

At a more fundamental level I think this may be the wrong approach. Are you planning to load this pixel data into a texture to display the reflection? Read pixels is going to be slow, and if you are just sending the data back across the bus it is not needed. Take a look at glCopyTexImage2D and glCopyTexSubImage2D as alternatives for getting data from the screen to a texture. You may also want to look at the FBO extension eventually, but probably start with the copy functions.
AndyEsser
AndyEsser
Thanks for your help. I'll check out those other functions.

thanks
cwhite
cwhite
You might as well just bite the bullet and learn how to use framebuffer objects. They're the way of the future for rendering to a texture, and their only downfall is a slight lack of good documentation. But it's worth the effort. There's really no point in learning a deprecated technology.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.