示例#1
0
void SDLFrontend::bindTexture (Texture* texture, int textureUnit)
{
	if (textureUnit != 0)
		error(LOG_CLIENT, "only one texture unit is supported in the sdl frontend");
	SDL_Texture *sdltexture = static_cast<SDL_Texture *>(texture->getData());
	SDL_GL_BindTexture(sdltexture, nullptr, nullptr);
}
示例#2
0
文件: ui.c 项目: zbanks/radiance
static void render_textbox(char * text, int width, int height) {
    GLint location;

    glUseProgramObjectARB(text_shader);
    location = glGetUniformLocationARB(text_shader, "iResolution");
    glUniform2fARB(location, width, height);

    int text_w;
    int text_h;

    SDL_Texture * tex = render_text(text, &text_w, &text_h);

    location = glGetUniformLocationARB(text_shader, "iTextResolution");
    glUniform2fARB(location, text_w, text_h);
    location = glGetUniformLocationARB(text_shader, "iText");
    glUniform1iARB(location, 0);
    glActiveTexture(GL_TEXTURE0);
    SDL_GL_BindTexture(tex, NULL, NULL);

    glLoadIdentity();
    gluOrtho2D(0, width, 0, height);
    glViewport(0, 0, width, height);
    glClear(GL_COLOR_BUFFER_BIT);
    fill(width, height);
    SDL_DestroyTexture(tex);
}
示例#3
0
/*
 * Draw an image in OpenGL
 */
static void draw_image(VALUE el, int x, int y) {
  
  struct img_data *data;
  Data_Get_Struct(rb_iv_get(el, "@data"), struct img_data, data);
  
  glEnable(GL_BLEND);
  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  
  SDL_GL_BindTexture(data->texture, NULL, NULL);
  
  int w = data->surface->w;
  int h = data->surface->h;
  
  glBegin(GL_QUADS);
    
    glColor4f(1, 1, 1, 1);
    
    glTexCoord2f(0, 0);
    glVertex2f(x, y);
    
    glTexCoord2f(w, 0);
    glVertex2f(x + w, y);
    
    glTexCoord2f(w, h);
    glVertex2f(x + w, y + h);
    
    glTexCoord2f(0, h);
    glVertex2f(x, y + h);
    
  glEnd();
  
  SDL_GL_UnbindTexture(data->texture);
}
示例#4
0
文件: game.cpp 项目: ricky26/ld29
void Game::render()
{
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	//glScalef(0.5f, 0.5f, 1);
	glTranslatef(0, -m_cameraOffset, 0);

	glBindFramebuffer(GL_FRAMEBUFFER, m_lightFB);
	glClearColor(0.03f,0.03f,0.05f, 0);
	glClear(GL_COLOR_BUFFER_BIT);
	for(std::unique_ptr<Renderable> &renderable: m_renderables)
		renderable->renderLight();
	glBindFramebuffer(GL_FRAMEBUFFER, 0);

	glLoadIdentity();
	glTranslatef(0, -m_cameraOffset, 0);

	// background
	{
		float fW, fH;
		SDL_GL_BindTexture(m_background.get(), &fW, &fH);
		glBegin(GL_QUADS);	
		glColor3f(1,1,1);
		glTexCoord2f(0, fH);
		glVertex2f(0, 2400);
		glTexCoord2f(fW, fH);
		glVertex2f(800, 2400);
		glTexCoord2f(fW, 0);
		glVertex2f(800, -2400);
		glTexCoord2f(0, 0);
		glVertex2f(0, -2400);
		glEnd();
		SDL_GL_UnbindTexture(m_background.get());
	}

	for(std::unique_ptr<Renderable> &renderable: m_renderables)
		renderable->render();

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	glBlendFunc(GL_DST_COLOR, GL_SRC_COLOR);

	glBindTexture(GL_TEXTURE_2D, m_lightTexture);
	glBegin(GL_QUADS);
	glColor4f(1,1,1,1);
	glTexCoord2f(0, 1);
	glVertex2f(0, 0);
	glTexCoord2f(1, 1);
	glVertex2f(800, 0);
	glTexCoord2f(1, 0);
	glVertex2f(800, 600);
	glTexCoord2f(0, 0);
	glVertex2f(0, 600);
	glEnd();
	glBindTexture(GL_TEXTURE_2D, 0);
}
示例#5
0
文件: game.cpp 项目: ricky26/ld29
	void softenTexture(SDL::Texture &tex)
	{
		float w, h;
		SDL_GL_BindTexture(tex.get(), &w, &h);
		
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
		
		SDL_GL_UnbindTexture(tex.get());
	}
// Called by Rocket when it wants to render geometry that it does not wish to optimise.
void RocketSDL2Renderer::RenderGeometry(Rocket::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, const Rocket::Core::TextureHandle texture, const Rocket::Core::Vector2f& translation)
{
    // SDL uses shaders that we need to disable here  
    glUseProgramObjectARB(0);
    glPushMatrix();
    glTranslatef(translation.x, translation.y, 0);
 
    std::vector<Rocket::Core::Vector2f> Positions(num_vertices);
    std::vector<Rocket::Core::Colourb> Colors(num_vertices);
    std::vector<Rocket::Core::Vector2f> TexCoords(num_vertices);
    float texw, texh;
 
    SDL_Texture* sdl_texture = NULL;
    if(texture)
    {
        glEnableClientState(GL_TEXTURE_COORD_ARRAY);
        sdl_texture = (SDL_Texture *) texture;
        SDL_GL_BindTexture(sdl_texture, &texw, &texh);
    }
 
    for(int  i = 0; i < num_vertices; i++) {
        Positions[i] = vertices[i].position;
        Colors[i] = vertices[i].colour;
        if (sdl_texture) {
            TexCoords[i].x = vertices[i].tex_coord.x * texw;
            TexCoords[i].y = vertices[i].tex_coord.y * texh;
        }
        else TexCoords[i] = vertices[i].tex_coord;
    };
 
    glEnableClientState(GL_VERTEX_ARRAY);
    glEnableClientState(GL_COLOR_ARRAY);
    glVertexPointer(2, GL_FLOAT, 0, &Positions[0]);
    glColorPointer(4, GL_UNSIGNED_BYTE, 0, &Colors[0]);
    glTexCoordPointer(2, GL_FLOAT, 0, &TexCoords[0]);
 
    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glDrawElements(GL_TRIANGLES, num_indices, GL_UNSIGNED_INT, indices);
    glDisableClientState(GL_VERTEX_ARRAY);
    glDisableClientState(GL_COLOR_ARRAY);
 
    if (sdl_texture) {
        SDL_GL_UnbindTexture(sdl_texture);
        glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    }
 
    glColor4f(1.0, 1.0, 1.0, 1.0);
    glPopMatrix();
    /* Reset blending and draw a fake point just outside the screen to let SDL know that it needs to reset its state in case it wants to render a texture */
    glDisable(GL_BLEND);
    SDL_SetRenderDrawBlendMode(mRenderer, SDL_BLENDMODE_NONE);
    SDL_RenderDrawPoint(mRenderer, -1, -1);
}
示例#7
0
/*
 * Draw text with SDL2_ttf in OpenGL
 */
static void draw_text(VALUE el, char *text, int x, int y) {
  
  struct text_data *data;
  Data_Get_Struct(rb_iv_get(el, "@data"), struct text_data, data);
  
  int w, h;
  TTF_SizeText(data->font, text, &w, &h);
  
  glEnable(GL_BLEND);
  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  
  SDL_GL_BindTexture(data->texture, NULL, NULL);
  
  glBegin(GL_QUADS);
    glColor4f(1, 1, 1, 1);
    glTexCoord2f(0, 0); glVertex2f(x, y);
    glTexCoord2f(w, 0); glVertex2f(x + w, y);
    glTexCoord2f(w, h); glVertex2f(x + w, y + h);
    glTexCoord2f(0, h); glVertex2f(x, y + h);
  glEnd();
  
  SDL_GL_UnbindTexture(data->texture);
}
示例#8
0
文件: ui.c 项目: zbanks/radiance
static void ui_render(bool select) {
    GLint location;
    GLenum e;

    // Render strip indicators
    switch(strip_indicator) {
        case STRIPS_SOLID:
        case STRIPS_COLORED:
            glLoadIdentity();
            glViewport(0, 0, config.pattern.master_width, config.pattern.master_height);
            glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, strip_fb);
            glUseProgramObjectARB(strip_shader);

            location = glGetUniformLocationARB(strip_shader, "iPreview");
            glUniform1iARB(location, 0);
            location = glGetUniformLocationARB(strip_shader, "iResolution");
            glUniform2fARB(location, config.pattern.master_width, config.pattern.master_height);
            location = glGetUniformLocationARB(strip_shader, "iIndicator");
            glUniform1iARB(location, strip_indicator);

            glActiveTexture(GL_TEXTURE0);
            glBindTexture(GL_TEXTURE_2D, crossfader.tex_output);

            glClear(GL_COLOR_BUFFER_BIT);
            glBegin(GL_QUADS);
            for(struct output_device * d = output_device_head; d != NULL; d = d->next) {
#ifdef SOLID_LINE_INDICATOR
                bool first = true;
                double x;
                double y;
                for(struct output_vertex * v = d->vertex_head; v != NULL; v = v->next) {
                    if(!first) {
                        double dx = v->x - x;
                        double dy = -v->y - y;
                        double dl = hypot(dx, dy);
                        dx = config.ui.strip_thickness * dx / dl;
                        dy = config.ui.strip_thickness * dy / dl;
                        glVertex2d(x + dy, y - dx);
                        glVertex2d(v->x + dy, -v->y - dx);
                        glVertex2d(v->x - dy, -v->y + dx);
                        glVertex2d(x - dy, y + dx);
                    } else {
                        first = false;
                    }
                    x = v->x;
                    y = -v->y;
                }
#else // PIXEL INDICATOR
                // Maybe this is horrendously slow because it has to draw a quad for every output pixel? 
                // It looks cool though
                for (size_t i = 0; i < d->pixels.length; i++) {
                    double x = d->pixels.xs[i];
                    double y = d->pixels.ys[i];
                    double dx = config.ui.point_thickness;
                    double dy = config.ui.point_thickness;
                    glVertex2d(x + dx, y);
                    glVertex2d(x, y + dy);
                    glVertex2d(x - dx, y);
                    glVertex2d(x, y - dy);
                }
#endif
            }
            glEnd();
            break;
        default:
        case STRIPS_NONE:
            break;
    }

    // Render the patterns
    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, pat_fb);

    int pw = config.ui.pattern_width;
    int ph = config.ui.pattern_height;
    glUseProgramObjectARB(pat_shader);
    location = glGetUniformLocationARB(pat_shader, "iResolution");
    glUniform2fARB(location, pw, ph);
    glUseProgramObjectARB(pat_shader);
    location = glGetUniformLocationARB(pat_shader, "iSelection");
    glUniform1iARB(location, select);
    location = glGetUniformLocationARB(pat_shader, "iPreview");
    glUniform1iARB(location, 0);
    location = glGetUniformLocationARB(pat_shader, "iName");
    glUniform1iARB(location, 1);
    GLint pattern_index = glGetUniformLocationARB(pat_shader, "iPatternIndex");
    GLint pattern_intensity = glGetUniformLocationARB(pat_shader, "iIntensity");
    GLint name_resolution = glGetUniformLocationARB(pat_shader, "iNameResolution");

    glLoadIdentity();
    gluOrtho2D(0, pw, 0, ph);
    glViewport(0, 0, pw, ph);

    for(int i = 0; i < config.ui.n_patterns; i++) {
        struct pattern * p = deck[map_deck[i]].pattern[map_pattern[i]];
        if(p != NULL) {
            glActiveTexture(GL_TEXTURE0);
            glBindTexture(GL_TEXTURE_2D, p->tex_output);
            glActiveTexture(GL_TEXTURE1);
            SDL_GL_BindTexture(pattern_name_textures[i], NULL, NULL);
            glUniform1iARB(pattern_index, i);
            glUniform1fARB(pattern_intensity, p->intensity);
            glUniform2fARB(name_resolution, pattern_name_width[i], pattern_name_height[i]);
            glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, pattern_textures[i], 0);
            glClear(GL_COLOR_BUFFER_BIT);
            fill(pw, ph);
        }
    }

    // Render the crossfader
    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, crossfader_fb);

    int cw = config.ui.crossfader_width;
    int ch = config.ui.crossfader_height;
    glUseProgramObjectARB(crossfader_shader);
    location = glGetUniformLocationARB(crossfader_shader, "iResolution");
    glUniform2fARB(location, cw, ch);
    location = glGetUniformLocationARB(crossfader_shader, "iSelection");
    glUniform1iARB(location, select);
    location = glGetUniformLocationARB(crossfader_shader, "iPreview");
    glUniform1iARB(location, 0);
    location = glGetUniformLocationARB(crossfader_shader, "iStrips");
    glUniform1iARB(location, 1);
    location = glGetUniformLocationARB(crossfader_shader, "iIntensity");
    glUniform1fARB(location, crossfader.position);
    location = glGetUniformLocationARB(crossfader_shader, "iIndicator");
    glUniform1iARB(location, strip_indicator);

    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, crossfader.tex_output);

    glActiveTexture(GL_TEXTURE1);
    glBindTexture(GL_TEXTURE_2D, strip_texture);

    glLoadIdentity();
    gluOrtho2D(0, cw, 0, ch);
    glViewport(0, 0, cw, ch);
    glClear(GL_COLOR_BUFFER_BIT);
    fill(cw, ch);

    int sw = 0;
    int sh = 0;
    int vw = 0;
    int vh = 0;
    if(!select) {
        analyze_render(tex_spectrum_data, tex_waveform_data, tex_waveform_beats_data);

        // Render the spectrum
        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, spectrum_fb);

        sw = config.ui.spectrum_width;
        sh = config.ui.spectrum_height;
        glUseProgramObjectARB(spectrum_shader);
        location = glGetUniformLocationARB(spectrum_shader, "iResolution");
        glUniform2fARB(location, sw, sh);
        location = glGetUniformLocationARB(spectrum_shader, "iBins");
        glUniform1iARB(location, config.audio.spectrum_bins);
        location = glGetUniformLocationARB(spectrum_shader, "iSpectrum");
        glUniform1iARB(location, 0);
        glActiveTexture(GL_TEXTURE0);
        glBindTexture(GL_TEXTURE_1D, tex_spectrum_data);

        glLoadIdentity();
        gluOrtho2D(0, sw, 0, sh);
        glViewport(0, 0, sw, sh);
        glClear(GL_COLOR_BUFFER_BIT);
        fill(sw, sh);

        // Render the waveform
        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, waveform_fb);

        vw = config.ui.waveform_width;
        vh = config.ui.waveform_height;
        glUseProgramObjectARB(waveform_shader);
        location = glGetUniformLocationARB(waveform_shader, "iResolution");
        glUniform2fARB(location, sw, sh);
        location = glGetUniformLocationARB(waveform_shader, "iLength");
        glUniform1iARB(location, config.audio.waveform_length);
        location = glGetUniformLocationARB(waveform_shader, "iWaveform");
        glUniform1iARB(location, 0);
        location = glGetUniformLocationARB(waveform_shader, "iBeats");
        glUniform1iARB(location, 1);
        glActiveTexture(GL_TEXTURE0);
        glBindTexture(GL_TEXTURE_1D, tex_waveform_data);
        glActiveTexture(GL_TEXTURE1);
        glBindTexture(GL_TEXTURE_1D, tex_waveform_beats_data);

        glLoadIdentity();
        gluOrtho2D(0, vw, 0, vh);
        glViewport(0, 0, vw, vh);
        glClear(GL_COLOR_BUFFER_BIT);
        fill(vw, vh);
    }

    // Render to screen (or select fb)
    if(select) {
        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, select_fb);
    } else {
        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
    }

    glLoadIdentity();
    gluOrtho2D(0, ww, 0, wh);
    glViewport(0, 0, ww, wh);

    glClear(GL_COLOR_BUFFER_BIT);

    glUseProgramObjectARB(main_shader);

    location = glGetUniformLocationARB(main_shader, "iResolution");
    glUniform2fARB(location, ww, wh);
    location = glGetUniformLocationARB(main_shader, "iSelection");
    glUniform1iARB(location, select);
    location = glGetUniformLocationARB(main_shader, "iSelected");
    glUniform1iARB(location, selected);
    location = glGetUniformLocationARB(main_shader, "iLeftDeckSelector");
    glUniform1iARB(location, left_deck_selector);
    location = glGetUniformLocationARB(main_shader, "iRightDeckSelector");
    glUniform1iARB(location, right_deck_selector);

    fill(ww, wh);

    // Blit UI elements on top
    glEnable(GL_BLEND);
    glUseProgramObjectARB(blit_shader);
    glActiveTexture(GL_TEXTURE0);
    location = glGetUniformLocationARB(blit_shader, "iTexture");
    glUniform1iARB(location, 0);

    for(int i = 0; i < config.ui.n_patterns; i++) {
        struct pattern * pattern = deck[map_deck[i]].pattern[map_pattern[i]];
        if(pattern != NULL) {
            glBindTexture(GL_TEXTURE_2D, pattern_textures[i]);
            blit(map_x[i], map_y[i], pw, ph);
        }
    }

    glBindTexture(GL_TEXTURE_2D, crossfader_texture);
    blit(config.ui.crossfader_x, config.ui.crossfader_y, cw, ch);

    if(!select) {
        glBindTexture(GL_TEXTURE_2D, spectrum_texture);
        blit(config.ui.spectrum_x, config.ui.spectrum_y, sw, sh);

        glBindTexture(GL_TEXTURE_2D, waveform_texture);
        blit(config.ui.waveform_x, config.ui.waveform_y, vw, vh);

        if(pat_entry) {
            for(int i = 0; i < config.ui.n_patterns; i++) {
                if(map_selection[i] == selected) {
                    glBindTexture(GL_TEXTURE_2D, pat_entry_texture);
                    blit(map_pe_x[i], map_pe_y[i], config.ui.pat_entry_width, config.ui.pat_entry_height);
                    break;
                }
            }
        }
    }

    glDisable(GL_BLEND);

    if((e = glGetError()) != GL_NO_ERROR) FAIL("OpenGL error: %s\n", gluErrorString(e));
}
示例#9
0
void renderBackgroundImage(AppState* state,Uint8* image)
{
    Uint8 *pixels = 0;
    int pitch1;

    if (0 == SDL_LockTexture(state->background, NULL, (void **)&pixels, &pitch1))
    {
        GLboolean isLightingOn = glIsEnabled(GL_LIGHTING);
        GLboolean isDepthTestOn = glIsEnabled(GL_DEPTH_TEST);


        if (isDepthTestOn) glDisable(GL_DEPTH_TEST);
        if (isLightingOn) glDisable(GL_LIGHTING);

        switch(gsBGTextureFormat) {
        case SDL_PIXELFORMAT_YV12:

            //        memcpy(pixels,             image, size1  );
            //        memcpy(pixels + size1,     pFrame_YUV420P->data[2], size1/4);
            //        memcpy(pixels + size1*5/4, pFrame_YUV420P->data[1], size1/4);
            break;
        case SDL_PIXELFORMAT_RGB24:
            memcpy( pixels, image, gsARTImageHeight*gsARTImageWidth*sizeof(Uint8)*3);
            break;
        }

        SDL_UnlockTexture(state->background);
        SDL_UpdateTexture(state->background, NULL, pixels, pitch1);

        float width,height;

        float posX = 0, posY = 0;


        glMatrixMode(GL_PROJECTION);
        glPushMatrix();
        glLoadIdentity();
        glOrtho(0.0f, gsARTImageWidth, gsARTImageHeight, 0.0f, -1.0f, 1.0f);

        glMatrixMode(GL_MODELVIEW);
        glPushMatrix();
        glLoadIdentity();

        /* this accounts for Texture2D vs TextureRectangle */
        if (0 == SDL_GL_BindTexture(state->background, &width, &height ))
        {
            glBegin(GL_QUADS);
                glTexCoord2f(0, 0);
                glVertex2f(posX,posY);
                glTexCoord2f(1*width, 0);
                glVertex2f(posX + width, posY);
                glTexCoord2f(1*width, 1*height);
                glVertex2f(posX + width, posY + height);
                glTexCoord2f(0, 1*height);
                glVertex2f(posX, posY + height);
            glEnd();


//            SDL_GL_UnbindTexture(state->background);
        }

        glMatrixMode(GL_PROJECTION);
        glPopMatrix();
        glMatrixMode(GL_MODELVIEW);
        glPopMatrix();

        if (isDepthTestOn) glEnable(GL_DEPTH_TEST);
        if (isLightingOn) glEnable(GL_LIGHTING);

    }
}
示例#10
0
// Called by Rocket when it wants to render geometry that it does not wish to optimise.
void RocketSDLRenderInterfaceOpenGLES2::RenderGeometry(Rocket::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, const Rocket::Core::TextureHandle texture, const Rocket::Core::Vector2f& translation)
{
    SDL_Texture* sdl_texture = NULL;
    if(texture) render_data.glUseProgram(program_texture_id);
    else render_data.glUseProgram(program_color_id);
    int width, height;
    SDL_Rect rvp;
    SDL_RenderGetViewport(renderer, &rvp);

    GLfloat projection[4][4];

    // Prepare an orthographic projection
    projection[0][0] = 2.0f / rvp.w;
    projection[0][1] = 0.0f;
    projection[0][2] = 0.0f;
    projection[0][3] = 0.0f;
    projection[1][0] = 0.0f;
    //if (renderer->target) {
    //    projection[1][1] = 2.0f / height;
    //} else {
        projection[1][1] = -2.0f / rvp.h;
    //}
    projection[1][2] = 0.0f;
    projection[1][3] = 0.0f;
    projection[2][0] = 0.0f;
    projection[2][1] = 0.0f;
    projection[2][2] = 0.0f;
    projection[2][3] = 0.0f;
    projection[3][0] = -1.0f;
    //if (renderer->target) {
    //    projection[3][1] = -1.0f;
    //} else {
        projection[3][1] = 1.0f;
    //}
    projection[3][2] = 0.0f;
    projection[3][3] = 1.0f;

    // Set the projection matrix
    if (texture) {
        render_data.glUniformMatrix4fv(u_texture_projection, 1, GL_FALSE, (GLfloat *)projection);
        render_data.glUniform2f(u_texture_translation, translation.x, translation.y);
    }
    else {
        render_data.glUniformMatrix4fv(u_color_projection, 1, GL_FALSE, (GLfloat *)projection);
        render_data.glUniform2f(u_color_translation, translation.x, translation.y);
    }

    render_data.glEnable(GL_BLEND);
    render_data.glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    float texw, texh;

    unsigned short newIndicies[num_indices];
    for (int i = 0; i < num_indices; i++)
    {
      newIndicies[i] = (unsigned short) indices[i];
    }

    glVertexAttribPointer(ROCKETGLUE_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, sizeof(Rocket::Core::Vertex), &vertices[0].position);
    glVertexAttribPointer(ROCKETGLUE_ATTRIBUTE_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(Rocket::Core::Vertex), &vertices[0].colour);
    render_data.glEnableVertexAttribArray(ROCKETGLUE_ATTRIBUTE_POSITION);
    render_data.glEnableVertexAttribArray(ROCKETGLUE_ATTRIBUTE_TEXCOORD);
    render_data.glEnableVertexAttribArray(ROCKETGLUE_ATTRIBUTE_COLOR);

    if(texture) {
        sdl_texture = (SDL_Texture *) texture;
        SDL_GL_BindTexture(sdl_texture, &texw, &texh);
        render_data.glUniform1i(u_texture, 0);
        glVertexAttribPointer(ROCKETGLUE_ATTRIBUTE_TEXCOORD, 2, GL_FLOAT, GL_FALSE, sizeof(Rocket::Core::Vertex), &vertices[0].tex_coord);
    }
    else {
        render_data.glActiveTexture(GL_TEXTURE0);
        render_data.glDisable(GL_TEXTURE_2D);
        render_data.glDisableVertexAttribArray(ROCKETGLUE_ATTRIBUTE_TEXCOORD);
    }

    render_data.glDrawElements(GL_TRIANGLES, num_indices, GL_UNSIGNED_SHORT, newIndicies);

    /* We can disable ROCKETGLUE_ATTRIBUTE_COLOR (2) safely as SDL will reenable the vertex attrib 2 if it is required */
    render_data.glDisableVertexAttribArray(ROCKETGLUE_ATTRIBUTE_COLOR);

    /* Leave ROCKETGLUE_ATTRIBUTE_POSITION (0) and ROCKETGLUE_ATTRIBUTE_TEXCOORD (1) enabled for compatibility with SDL which
       doesn't re enable them when you call RenderCopy/Ex */
    if(sdl_texture) SDL_GL_UnbindTexture(sdl_texture);
    else render_data.glEnableVertexAttribArray(ROCKETGLUE_ATTRIBUTE_TEXCOORD);

    /* Reset blending and draw a fake point just outside the screen to let SDL know that it needs to reset its state in case it wants to render a texture */
    render_data.glDisable(GL_BLEND);
    SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE);
    SDL_RenderDrawPoint(renderer, -1, -1);

}