Now using OpenGL directly:
- // Clear the entire screen
glClear(GL_COLOR_BUFFER_BIT);
// Set up position, rotation, colour
glTranslatef(window_size.x/2, window_size.y/2, 0.0);
glRotatef(45.0, 0.0, 0.0, 1.0);
// Bind the texture to which subsequent calls refer to
glBindTexture(GL_TEXTURE_2D, background);
// Start drawing texture
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
GLfloat size[9], coords[9];
glVertexPointer(3, GL_FLOAT, 0, size);
glTexCoordPointer(2, GL_FLOAT, 0, coords);
// Top-left triangle
size = {-16,-16,0, 16,-16,0, 16,16,0};
coords = {0,0, 1,0, 1,1};
glDrawArrays(GL_TRIANGLES, 0, 3);
// Bottom-right triangle
size = {-16,-16,0, -16,16,0, 16,16,0};
coords = {0,0, 0,1, 1,1};
glDrawArrays(GL_TRIANGLES, 0, 3);
// Stop drawing texture
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
// Reset back to the origin
glLoadIdentity();
// Flip the buffers to update the screen
SDL_GL_SwapWindow(window);*
Exactly the same problem is occuring.
WilliamOn 1 August 2011 15:43, William Dyce <@William_Dyce> wrote:
Eureka! I think I’m really on to something now
So, the problem occurs when multiple images are blitted one on top of the
other. I was drawing a background texture first, followed by a sprite, then
SDL_RenderPresent:
*
// Clear the entire screen to the Renderer’s base colour
SDL_RenderClear(renderer);
// Render the background
SDL_RenderCopy(renderer, background, NULL, NULL);
// Draw the game objects
thing->draw(renderer);
// Flip the buffers to update the screen
SDL_RenderPresent(renderer);*
where Thing::draw(SDL_renderer* renderer) is:
- static SDL_Rect draw_dest, draw_src;
draw_dest.x = position.x - size.x/2;
draw_dest.y = position.y - size.y/2;
draw_dest.w = size.x;
draw_dest.h = size.y;
draw_src.x = draw_src.y = 0;
draw_src.w = draw_src.h = 32;
SDL_RenderCopy(renderer, sprite, &draw_src, &draw_dest);*
It seems that I can draw one texture OR the other, but not both one on top
of eachother, unless the second completely covers up the first. Am I using
RenderCopy and RenderPresent the wrong way? And if so, why does it work on
Ubuntu?
William