opengl rotation using gldrawpixels

2019-05-07 14:35发布

My team is currently limited to drawing images on an opengl 1.4 platform, which means that we can't use any nifty texture mapping to draw an image (yes, we're confined to using the intel integrated graphics platform, it's very annoying). So far, we're able to draw, scale, and flip an image, but the guy doing the graphics claims that rotation via glRotate can't be done while using glDrawPixels, that we'd have to go to textures and so forth, which don't work on the Intel platform.

I've bet him lunch that there is a rotation function, like glRotate, that will work for straight bitmaps. Does such a function exist? Would glRotate work? I'm a bit of a novice to this graphics thing, but it seems ludicrous that the library wouldn't allow for bitmap rotation except via texture rotation.

Thanks.

1条回答
神经病院院长
2楼-- · 2019-05-07 14:48

You can't use glRotate with glDrawPixels.

glDrawPixels is the worst and least performant way to get pixels onto the screen by far. You will even get better performance by putting the pixels onto the screen using a bad written software-rasterizer.

In short glDRawPixels will copy pixel data from the process-memory to the graphics memory and will do some very trivial transformations like flipping and scaling. Everything more advanced (like rotating) requires you to actually use the features of the graphic-chipset. E.g. You have to use textures.

And textures do work. They also work well with GL 1.4 and the Intel graphic chipsets. I've worked on such a chipset myself for quite a while. You won't get the performance of modern ATI or NVIDIA chipsets, but they aren't that bad either.

My best bet is that someone tried to create textures of a non power of two size, failed to do so and decided that textures in general don't work on the chipset.

That's not true. They do work. You just have to know that OpenGL requires you to create textures at power of two dimensions and that you have to either use a subrectangle of the larger texture or put multiple images into one very large texture (the later is called a texture atlas).

You can compensate for the smaller image within a larger texture by adjusting the texture-coordinates.

查看更多
登录 后发表回答