Example #1
0
void GPU_GetDefaultRendererOrder(int* order_size, GPU_RendererID* order)
{
    int count = 0;
    GPU_RendererID default_order[GPU_RENDERER_ORDER_MAX];
    
    #ifndef SDL_GPU_DISABLE_GLES
        #ifndef SDL_GPU_DISABLE_GLES3
            default_order[count++] = GPU_MakeRendererID("OpenGLES 3", GPU_RENDERER_GLES_3, 3, 0);
        #endif
        #ifndef SDL_GPU_DISABLE_GLES2
            default_order[count++] = GPU_MakeRendererID("OpenGLES 2", GPU_RENDERER_GLES_2, 2, 0);
        #endif
        #ifndef SDL_GPU_DISABLE_GLES1
            default_order[count++] = GPU_MakeRendererID("OpenGLES 1", GPU_RENDERER_GLES_1, 1, 1);
        #endif
    #endif
    
    #ifndef SDL_GPU_DISABLE_OPENGL
        #ifdef __MACOSX__
        
            // My understanding of OS X OpenGL support:
            // OS X 10.9: GL 2.1, 3.3, 4.1
            // OS X 10.7: GL 2.1, 3.2
            // OS X 10.6: GL 1.4, 2.1
            #ifndef SDL_GPU_DISABLE_OPENGL_4
            default_order[count++] = GPU_MakeRendererID("OpenGL 4", GPU_RENDERER_OPENGL_4, 4, 1);
            #endif
            #ifndef SDL_GPU_DISABLE_OPENGL_3
            default_order[count++] = GPU_MakeRendererID("OpenGL 3", GPU_RENDERER_OPENGL_3, 3, 2);
            #endif
        
        #else
        
            #ifndef SDL_GPU_DISABLE_OPENGL_4
            default_order[count++] = GPU_MakeRendererID("OpenGL 4", GPU_RENDERER_OPENGL_4, 4, 0);
            #endif
            #ifndef SDL_GPU_DISABLE_OPENGL_3
            default_order[count++] = GPU_MakeRendererID("OpenGL 3", GPU_RENDERER_OPENGL_3, 3, 0);
            #endif
            
        #endif
        
        #ifndef SDL_GPU_DISABLE_OPENGL_2
        default_order[count++] = GPU_MakeRendererID("OpenGL 2", GPU_RENDERER_OPENGL_2, 2, 0);
        #endif
        #ifndef SDL_GPU_DISABLE_OPENGL_1
        default_order[count++] = GPU_MakeRendererID("OpenGL 1", GPU_RENDERER_OPENGL_1, 1, 1);
        #endif
        
    #endif
    
    if(order_size != NULL)
        *order_size = count;
    
    if(order != NULL && count > 0)
        memcpy(order, default_order, count*sizeof(GPU_RendererID));
}
Example #2
0
int main(int argc, char* argv[])
{
	GPU_Target* screen;
	
	// Prepare renderer for SDL_gpu to use
	GPU_RendererID rendererID = GPU_MakeRendererID("Dummy", GPU_ReserveNextRendererEnum(), 1, 0);
	GPU_RegisterRenderer(rendererID, &create_dummy_renderer, &free_dummy_renderer);

	printRenderers();
	
	// Request this specific renderer
	screen = GPU_InitRenderer(rendererID.renderer, 800, 600, GPU_DEFAULT_INIT_FLAGS);
	if(screen == NULL)
		return -1;
	
	printCurrentRenderer();
	
	{
		Uint8 done;
		SDL_Event event;
		
		GPU_Image* image = GPU_LoadImage("data/test.bmp");
		if(image == NULL)
            GPU_Log("Failed to load image.\n");
        
        done = 0;
        while(!done)
        {
            while(SDL_PollEvent(&event))
            {
                if(event.type == SDL_QUIT)
                    done = 1;
                else if(event.type == SDL_KEYDOWN)
                {
                    if(event.key.keysym.sym == SDLK_ESCAPE)
                        done = 1;
                }
            }
            
            GPU_Clear(screen);
        
            GPU_Blit(image, NULL, screen, screen->w/2, screen->h/2);
            
            GPU_Flip(screen);
            
            // Long delay to keep the logging from piling up too much
            SDL_Delay(500);
        }
        
        GPU_FreeImage(image);
	}
	
	GPU_Quit();
	
	return 0;
}
Example #3
0
void GPU_GetDefaultRendererOrder(int* order_size, GPU_RendererID* order)
{
    int count = 0;
    GPU_RendererID default_order[GPU_RENDERER_ORDER_MAX];
    
    #if defined(__ANDROID__) || defined(__IPHONEOS__)
        default_order[count++] = GPU_MakeRendererID(GPU_RENDERER_GLES_2, 2, 0);
        default_order[count++] = GPU_MakeRendererID(GPU_RENDERER_GLES_1, 1, 1);
    #else
        default_order[count++] = GPU_MakeRendererID(GPU_RENDERER_OPENGL_3, 3, 0);
        default_order[count++] = GPU_MakeRendererID(GPU_RENDERER_OPENGL_2, 2, 0);
        default_order[count++] = GPU_MakeRendererID(GPU_RENDERER_OPENGL_1, 1, 1);
    #endif
    
    if(order_size != NULL)
        *order_size = count;
    
    if(order != NULL && count > 0)
        memcpy(order, default_order, count*sizeof(GPU_RendererID));
}
Example #4
0
void GPU_GetDefaultRendererOrder(int* order_size, GPU_RendererID* order)
{
    int count = 0;
    GPU_RendererID default_order[GPU_RENDERER_ORDER_MAX];
    
    #if defined(__ANDROID__) || defined(__IPHONEOS__)
        default_order[count++] = GPU_MakeRendererID("OpenGLES 2", GPU_RENDERER_GLES_2, 2, 0);
        default_order[count++] = GPU_MakeRendererID("OpenGLES 1", GPU_RENDERER_GLES_1, 1, 1);
    #else
        #ifdef __MACOSX__
        // My understanding of OS X OpenGL support:
        // OS X 10.9: GL 2.1, 3.3, 4.1
        // OS X 10.7: GL 2.1, 3.2
        // OS X 10.6: GL 1.4, 2.1
        default_order[count++] = GPU_MakeRendererID("OpenGL 3", GPU_RENDERER_OPENGL_3, 3, 2);
        #else
        default_order[count++] = GPU_MakeRendererID("OpenGL 3", GPU_RENDERER_OPENGL_3, 3, 0);
        #endif
        default_order[count++] = GPU_MakeRendererID("OpenGL 2", GPU_RENDERER_OPENGL_2, 2, 0);
        default_order[count++] = GPU_MakeRendererID("OpenGL 1", GPU_RENDERER_OPENGL_1, 1, 1);
    #endif
    
    if(order_size != NULL)
        *order_size = count;
    
    if(order != NULL && count > 0)
        memcpy(order, default_order, count*sizeof(GPU_RendererID));
}
Example #5
0
GPU_RendererID GPU_GetRendererID(GPU_RendererEnum renderer)
{
	int i;

	gpu_init_renderer_register();

	for(i = 0; i < GPU_MAX_REGISTERED_RENDERERS; i++)
	{
		if(_gpu_renderer_register[i].id.renderer == renderer)
			return _gpu_renderer_register[i].id;
	}
	
	return GPU_MakeRendererID("Unknown", GPU_RENDERER_UNKNOWN, 0, 0);
}
Example #6
0
void gpu_register_built_in_renderers(void)
{
	#ifndef SDL_GPU_DISABLE_OPENGL
        #ifndef SDL_GPU_DISABLE_OPENGL_1_BASE
        GPU_RegisterRenderer(GPU_MakeRendererID("OpenGL 1 BASE", GPU_RENDERER_OPENGL_1_BASE, 1, 1),
                             &GPU_CreateRenderer_OpenGL_1_BASE,
                             &GPU_FreeRenderer_OpenGL_1_BASE);
        #endif
        
        #ifndef SDL_GPU_DISABLE_OPENGL_1
        GPU_RegisterRenderer(GPU_MakeRendererID("OpenGL 1", GPU_RENDERER_OPENGL_1, 1, 1),
                             &GPU_CreateRenderer_OpenGL_1,
                             &GPU_FreeRenderer_OpenGL_1);
        #endif
	
        #ifndef SDL_GPU_DISABLE_OPENGL_2
            GPU_RegisterRenderer(GPU_MakeRendererID("OpenGL 2", GPU_RENDERER_OPENGL_2, 2, 0),
                                 &GPU_CreateRenderer_OpenGL_2,
                                 &GPU_FreeRenderer_OpenGL_2);
        #endif
	
        #ifndef SDL_GPU_DISABLE_OPENGL_3
            #ifdef __MACOSX__
            // Depending on OS X version, it might only support core GL 3.3 or 3.2
            GPU_RegisterRenderer(GPU_MakeRendererID("OpenGL 3", GPU_RENDERER_OPENGL_3, 3, 2),
                                 &GPU_CreateRenderer_OpenGL_3,
                                 &GPU_FreeRenderer_OpenGL_3);
            #else
            GPU_RegisterRenderer(GPU_MakeRendererID("OpenGL 3", GPU_RENDERER_OPENGL_3, 3, 0),
                                 &GPU_CreateRenderer_OpenGL_3,
                                 &GPU_FreeRenderer_OpenGL_3);
            #endif
        #endif
    #endif
	
	#ifndef SDL_GPU_DISABLE_GLES
        #ifndef SDL_GPU_DISABLE_GLES_1
        GPU_RegisterRenderer(GPU_MakeRendererID("OpenGLES 1", GPU_RENDERER_GLES_1, 1, 1),
                             &GPU_CreateRenderer_GLES_1,
                             &GPU_FreeRenderer_GLES_1);
        #endif
        #ifndef SDL_GPU_DISABLE_GLES_2
        GPU_RegisterRenderer(GPU_MakeRendererID("OpenGLES 2", GPU_RENDERER_GLES_2, 2, 0),
                             &GPU_CreateRenderer_GLES_2,
                             &GPU_FreeRenderer_GLES_2);
        #endif
    #endif
	
}
Example #7
0
// Remove a renderer from the active map and free it.
void GPU_FreeRenderer(GPU_Renderer* renderer)
{
	int i;
	GPU_Renderer* current_renderer;
	
	if(renderer == NULL)
        return;
	
    current_renderer = GPU_GetCurrentRenderer();
    if(current_renderer == renderer)
        GPU_SetCurrentRenderer(GPU_MakeRendererID("Unknown", GPU_RENDERER_UNKNOWN, 0, 0));
        
	for(i = 0; i < GPU_MAX_ACTIVE_RENDERERS; i++)
	{
		if(renderer == _gpu_renderer_map[i])
		{
			gpu_free_renderer_memory(renderer);
			_gpu_renderer_map[i] = NULL;
			return;
		}
	}
}