The Allegro Wiki is migrating to github at https://github.com/liballeg/allegro_wiki/wiki

Difference between revisions of "Graphics2"

From Allegro Wiki
Jump to: navigation, search
(twiki import)
 
(twiki import)
Line 1: Line 1:
Proposed changes to the original graphics API proposal:
+
=Proposed changes to the original graphics API proposal:=
 
+
* Implicit surface parameter for the current "render target"
* implicit surface parameter for the current "render target"
+
* Renamed AL_BITMAP to AL_SURFACE
* renamed AL_BITMAP to AL_SURFACE
 
  
 
AL_DISPLAY *al_create_display(...)
 
AL_DISPLAY *al_create_display(...)
  
 
AL_EVENT_SOURCE *al_get_display_event_source(AL_DISPLAY)
 
AL_EVENT_SOURCE *al_get_display_event_source(AL_DISPLAY)
AL_SURFACE *al_get_surface(AL_DISPAY)
+
 
 +
AL_SURFACE *al_get_display_surface(AL_DISPAY)
  
 
AL_SURFACE *al_get_bitmap_surface(AL_BITMAP)
 
AL_SURFACE *al_get_bitmap_surface(AL_BITMAP)
 +
 
al_select_surface(AL_SURFACE)
 
al_select_surface(AL_SURFACE)
 
al_select_bitmap_surface(AL_BITMAP) - shortcut combining the previous two functions
 
  
 
AL_BITMAP *al_create_bitmap(...)
 
AL_BITMAP *al_create_bitmap(...)
  
 
al_line(int x, y, w, h, color)
 
al_line(int x, y, w, h, color)
al_blit(AL_BITMAP *bitmap, int x, int y)
+
 
 +
al_blit(AL_BITMAP *bitmap, int x, int y)  
 +
al_update() - on a display surface, does things like page flipping. else could do things like finalize an [[OpenGL|OpenGL]] context, or upload a modified texture. On a memory bitmap, a no-op.<br />al_update_rect(x, y, w, h)
 +
 
 +
Example:
 +
<pre>
 +
AL_DISPLAY *display = al_create_display(640, 480, 0, 0, 0);
 +
AL_SURFACE *display_surface = al_get_display_surface(display)
 +
al_select_surface(surface)
 +
al_line(0, 0, 100, 100, RED);
 +
 
 +
AL_BITMAP *bitmap = al_create_bitmap(100, 100, 0, 0, 0);
 +
 
 +
AL_SURFACE *bitmap_surface = al_get_bitmap_surface(bitmap)
 +
al_select_surface(bitmap_surface);
 +
 
 +
al_line(0, 0, 100, 100, BLUE);
 +
 
 +
al_select_surface(display_surface);
 +
 
 +
al_blit(bitmap, 50, 50);
 +
 
 +
al_refresh();
 +
</pre>
  

Revision as of 05:37, December 23, 2006

Proposed changes to the original graphics API proposal:

  • Implicit surface parameter for the current "render target"
  • Renamed AL_BITMAP to AL_SURFACE

AL_DISPLAY *al_create_display(...)

AL_EVENT_SOURCE *al_get_display_event_source(AL_DISPLAY)

AL_SURFACE *al_get_display_surface(AL_DISPAY)

AL_SURFACE *al_get_bitmap_surface(AL_BITMAP)

al_select_surface(AL_SURFACE)

AL_BITMAP *al_create_bitmap(...)

al_line(int x, y, w, h, color)

al_blit(AL_BITMAP *bitmap, int x, int y) al_update() - on a display surface, does things like page flipping. else could do things like finalize an OpenGL context, or upload a modified texture. On a memory bitmap, a no-op.
al_update_rect(x, y, w, h)

Example:

AL_DISPLAY *display = al_create_display(640, 480, 0, 0, 0);
AL_SURFACE *display_surface = al_get_display_surface(display)
al_select_surface(surface)
al_line(0, 0, 100, 100, RED);

AL_BITMAP *bitmap = al_create_bitmap(100, 100, 0, 0, 0);

AL_SURFACE *bitmap_surface = al_get_bitmap_surface(bitmap)
al_select_surface(bitmap_surface);

al_line(0, 0, 100, 100, BLUE); 

al_select_surface(display_surface); 

al_blit(bitmap, 50, 50);

al_refresh();