Last active
December 17, 2015 10:49
-
-
Save mharju/5597241 to your computer and use it in GitHub Desktop.
Fixed the glitch.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Texture: 1024 x 1024 x 4bpp | |
// Contains 1024 x 768 image from (0,0) to (1024, 768) | |
// Use glOrtho like glOrtho2d | |
glOrtho(0, width, height, 0, -1, 1); | |
// This solved it! | |
glClear(GL_COLOR_BUFFER_BIT); | |
glClearColor(0.0, 1.0, 0.0, 1.0); | |
glMatrixMode(GL_MODELVIEW); | |
glLoadIdentity(); | |
glEnable(GL_TEXTURE_2D); | |
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); | |
glBindTexture(GL_TEXTURE_2D, display->texture); | |
GLfloat w = display->source_width / (GLfloat)TEXTURE_SIZE; | |
GLfloat h = display->source_height / (GLfloat)TEXTURE_SIZE; | |
GLfloat margin = display->width - display->source_width / 2; | |
GLfloat box[] = {margin,display->source_height,0, display->source_width,display->source_height,0, margin,0,0, display->source_width,0,0}; | |
GLfloat tex[] = {0,h, w,h, 0,0, w,0}; | |
glEnableClientState(GL_VERTEX_ARRAY); | |
glEnableClientState(GL_TEXTURE_COORD_ARRAY); | |
glVertexPointer(3, GL_FLOAT, 0, box); | |
glTexCoordPointer(2, GL_FLOAT, 0, tex); | |
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); | |
glDisableClientState(GL_VERTEX_ARRAY); | |
glDisableClientState(GL_TEXTURE_COORD_ARRAY); | |
glDisable(GL_TEXTURE_2D); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment