Exemplo n.º 1
0
void opengl_font_delete(font_t* font)
{
	opengl_font_t* f = (opengl_font_t*)font->data;	
	texture_atlas_delete(f->atlas);
	texture_font_delete(f->font);
	free(f);
}
Exemplo n.º 2
0
// ------------------------------------------------------------------- main ---
int main( int argc, char **argv )
{
    GLFWwindow* window;

    glfwSetErrorCallback( error_callback );

    if (!glfwInit( ))
    {
        exit( EXIT_FAILURE );
    }

    glfwWindowHint( GLFW_VISIBLE, GL_FALSE );
    glfwWindowHint( GLFW_RESIZABLE, GL_FALSE );

    window = glfwCreateWindow( 1, 1, argv[0], NULL, NULL );

    if (!window)
    {
        glfwTerminate( );
        exit( EXIT_FAILURE );
    }

    glfwMakeContextCurrent( window );
    glfwSwapInterval( 1 );

    glfwSetFramebufferSizeCallback( window, reshape );
    glfwSetWindowRefreshCallback( window, display );
    glfwSetKeyCallback( window, keyboard );

#ifndef __APPLE__
    GLenum err = glewInit();
    if (GLEW_OK != err)
    {
        /* Problem: glewInit failed, something is seriously wrong. */
        fprintf( stderr, "Error: %s\n", glewGetErrorString(err) );
        exit( EXIT_FAILURE );
    }
    fprintf( stderr, "Using GLEW %s\n", glewGetString(GLEW_VERSION) );
#endif

    init();

    glfwSetWindowSize( window, 850, 200 );
    glfwShowWindow( window );

    while(!glfwWindowShouldClose( window ))
    {
        display( window );
        glfwPollEvents( );
    }

    glDeleteTextures( 1, &atlas->id );
    atlas->id = 0;
    texture_atlas_delete( atlas );

    glfwDestroyWindow( window );
    glfwTerminate( );

    return EXIT_SUCCESS;
}
Exemplo n.º 3
0
// -------------------------------------------------------- console_delete ---
void
console_delete( console_t *self )
{
    glDeleteTextures( 1, &self->atlas->id );
    self->atlas->id = 0;
    texture_atlas_delete( self->atlas );
}
Exemplo n.º 4
0
	Font::~Font()
	{
		texture_font_delete(m_font);
		texture_atlas_delete(m_atlas);
		vertex_buffer_delete(m_buffer);
		delete m_fontFile;
	}
Exemplo n.º 5
0
// ------------------------------------------------------------------- main ---
int main( int argc, char **argv )
{
    glfwSetErrorCallback( error_callback );
    if (!glfwInit( )) { exit( EXIT_FAILURE ); }

    glfwWindowHint( GLFW_VISIBLE, GL_FALSE );
    glfwWindowHint( GLFW_RESIZABLE, GL_FALSE );
    glfwWindowHint( GLFW_CONTEXT_VERSION_MAJOR, 4);
    glfwWindowHint( GLFW_CONTEXT_VERSION_MINOR, 3);
    glfwWindowHint( GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

    auto window = glfwCreateWindow( 1, 1, argv[0], nullptr, nullptr);

    if (!window) {
        glfwTerminate( );
        exit( EXIT_FAILURE );
    }

    glfwMakeContextCurrent( window );
    glfwSwapInterval( 1 );

    glfwSetFramebufferSizeCallback( window, reshape );
    glfwSetWindowRefreshCallback( window, display );
    glfwSetKeyCallback( window, keyboard );

#ifndef __APPLE__
    glewExperimental = GL_TRUE;
    GLenum err = glewInit();
    if (GLEW_OK != err)
    {
        /* Problem: glewInit failed, something is seriously wrong. */
        fprintf( stderr, "Error: %s\n", glewGetErrorString(err) );
        exit( EXIT_FAILURE );
    }
    fprintf( stderr, "Using GLEW %s\n", glewGetString(GLEW_VERSION) );
#endif

    init();
    fprintf(stderr, "Total time to generate distance map: %fs\n", total_time);
    glfwSetWindowSize( window, 800, 600 );
    glfwShowWindow( window );

    glfwSetTime(0.0);

    while(!glfwWindowShouldClose( window )) {
        display( window );
        glfwPollEvents( );
    }

    glDeleteTextures( 1, &atlas->id );
    atlas->id = 0;
    texture_atlas_delete( atlas );

    glfwDestroyWindow( window );
    glfwTerminate( );

    return EXIT_SUCCESS;
}
Exemplo n.º 6
0
void opengl_font_reload(font_t* f)
{
	opengl_font_t* o = (opengl_font_t*)f->data;

	texture_font_delete(o->font);
	texture_atlas_delete(o->atlas);
	
	o->atlas = texture_atlas_new(512, 512, 1);
	o->font = texture_font_new(o->atlas, o->name, f->size * window_zoom);
	texture_font_load_glyphs(o->font, cache);	
}
Exemplo n.º 7
0
void
font_manager_delete( FontManager *self )
{
    assert( self );
    vector_delete( self->fonts );
    texture_atlas_delete( self->atlas );
    if( self->cache )
    {
        free( self->cache );
    }
    free( self );
}
Exemplo n.º 8
0
Stats::~Stats()
{
	texture_atlas_delete(texture_atlas);

	glDetachShader(text_program, text_vs);
	glDetachShader(text_program, text_fs);
	glDeleteShader(text_vs);
	glDeleteShader(text_fs);
	glDeleteProgram(text_program);

	glDeleteSamplers(1, &sampler);

	glDeleteBuffers(1, &position_vbo);
	glDeleteBuffers(1, &texcoord_vbo);
	glDeleteVertexArrays(1, &vao);

	glDeleteBuffers(1, &uniform_instance_buffer);
}
Exemplo n.º 9
0
	void Font::ResizeFont(int size)
	{
		if(m_font) texture_font_delete(m_font);
		if(m_atlas) texture_atlas_delete(m_atlas);

		delete m_textureAtlas;

		m_atlas = texture_atlas_new(512, 512, 1);
		m_font = texture_font_new(m_atlas, m_fontFile->m_buffer, m_fontFile->m_bufLength, (float)size);

		texture_font_load_glyphs(m_font, 
			L" !\"#$%&'()*+,-./0123456789:;<=>?"
			L"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"
			L"`abcdefghijklmnopqrstuvwxyz{|}~", 
			m_fontFile->m_buffer, m_fontFile->m_bufLength);

		m_textureAtlas = new GLTexture(m_atlas->id, 512, 512);
	}
Exemplo n.º 10
0
// ---------------------------------------------------- font_manager_delete ---
void
font_manager_delete( font_manager_t * self )
{
    size_t i;
    texture_font_t *font;
    assert( self );

    for( i=0; i<vector_size( self->fonts ); ++i)
    {
        font = *(texture_font_t **) vector_get( self->fonts, i );
        texture_font_delete( font );
    }
    vector_delete( self->fonts );
    texture_atlas_delete( self->atlas );
    if( self->cache )
    {
        free( self->cache );
    }
    free( self );
}
Exemplo n.º 11
0
// ------------------------------------------------------------------- main ---
int main( int argc, char **argv )
{
    GLFWwindow* window;
    char* screenshot_path = NULL;

    if (argc > 1)
    {
        if (argc == 3 && 0 == strcmp( "--screenshot", argv[1] ))
            screenshot_path = argv[2];
        else
        {
            fprintf( stderr, "Unknown or incomplete parameters given\n" );
            exit( EXIT_FAILURE );
        }
    }

    glfwSetErrorCallback( error_callback );

    if (!glfwInit( ))
    {
        exit( EXIT_FAILURE );
    }

    glfwWindowHint( GLFW_VISIBLE, GL_TRUE );
    glfwWindowHint( GLFW_RESIZABLE, GL_FALSE );

    window = glfwCreateWindow( 512, 512, argv[0], NULL, NULL );

    if (!window)
    {
        glfwTerminate( );
        exit( EXIT_FAILURE );
    }

    glfwMakeContextCurrent( window );
    glfwSwapInterval( 1 );

    glfwSetFramebufferSizeCallback( window, reshape );
    glfwSetWindowRefreshCallback( window, display );
    glfwSetKeyCallback( window, keyboard );

#ifndef __APPLE__
    glewExperimental = GL_TRUE;
    GLenum err = glewInit();
    if (GLEW_OK != err)
    {
        /* Problem: glewInit failed, something is seriously wrong. */
        fprintf( stderr, "Error: %s\n", glewGetErrorString(err) );
        exit( EXIT_FAILURE );
    }
    fprintf( stderr, "Using GLEW %s\n", glewGetString(GLEW_VERSION) );
#endif

    init();

    glfwShowWindow( window );
    reshape( window, 512, 512 );

    while (!glfwWindowShouldClose( window ))
    {
        display( window );
        glfwPollEvents( );

        if (screenshot_path)
        {
            screenshot( window, screenshot_path );
            glfwSetWindowShouldClose( window, 1 );
        }
    }

    glDeleteTextures( 1, &atlas->id );
    atlas->id = 0;
    texture_atlas_delete( atlas );

    glfwDestroyWindow( window );
    glfwTerminate( );

    return EXIT_SUCCESS;
}
Exemplo n.º 12
0
void TextureAtlas::doRelease() {
	LOGI("--->texture_atlas_t.id %d", atlas->id);
    texture_atlas_delete(atlas);
}