Use rectangle texture for render buffer

Game is rendered correctly even if hardware doesn't support non-power of two textures
The ARB_texture_rectangle extension is supported on almost all Macs running 10.4 Tiger
This commit is contained in:
alexey.lysiuk 2014-11-02 15:50:43 +02:00
parent d8be168474
commit 2f59a8792a

View file

@ -43,6 +43,7 @@
#include <Carbon/Carbon.h>
#include <OpenGL/OpenGL.h>
#include <OpenGL/gl.h>
#include <OpenGL/glext.h>
#include <SDL.h>
@ -1214,16 +1215,16 @@ static ApplicationController* appCtrl;
{
if (0 == m_softwareRenderingTexture)
{
glEnable(GL_TEXTURE_2D);
glEnable(GL_TEXTURE_RECTANGLE_ARB);
glGenTextures(1, &m_softwareRenderingTexture);
glBindTexture(GL_TEXTURE_2D, m_softwareRenderingTexture);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, m_softwareRenderingTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
}
delete[] m_softwareRenderingBuffer;
@ -1750,18 +1751,18 @@ int SDL_Flip(SDL_Surface* screen)
const int width = screen->w;
const int height = screen->h;
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8,
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, screen->pixels);
glBegin(GL_QUADS);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glTexCoord2f(0.0f, 0.0f);
glVertex2f(0.0f, 0.0f);
glTexCoord2f(1.0f, 0.0f);
glTexCoord2f(width, 0.0f);
glVertex2f(width, 0.0f);
glTexCoord2f(1.0f, 1.0f);
glTexCoord2f(width, height);
glVertex2f(width, height);
glTexCoord2f(0.0f, 1.0f);
glTexCoord2f(0.0f, height);
glVertex2f(0.0f, height);
glEnd();