X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pages%2FSDL-Cookbook-OpenGL.html-inc;h=8bc33d9644d4c7c942d7ee864162ceb131b5c6cd;hb=1dbe16975541da864f8bfa5169c89a2ab8893bf2;hp=11328ab1a7e72f073f9e63bfb0691aa1cf286cd8;hpb=ca0a3441dd72000cbbbb4be484b18d0d305fdb29;p=sdlgit%2FSDL-Site.git diff --git a/pages/SDL-Cookbook-OpenGL.html-inc b/pages/SDL-Cookbook-OpenGL.html-inc index 11328ab..8bc33d9 100644 --- a/pages/SDL-Cookbook-OpenGL.html-inc +++ b/pages/SDL-Cookbook-OpenGL.html-inc @@ -8,7 +8,8 @@ -
  • SEE ALSO +
  • SEE ALSO
  • +
  • AUTHORS

  • @@ -45,27 +46,27 @@ use SDL::Event; use OpenGL qw(:all); - my ($SDLAPP, $WIDTH, $HEIGHT, $SDLEVENT); + +

    You can use OpenGL as needed here.

    +
    	my ($SDLAPP, $WIDTH, $HEIGHT, $SDLEVENT);
     
     	$| = 1;
     	$WIDTH = 1024;
     	$HEIGHT = 768;
    -	$SDLAPP = SDLx::App->new(-title => "Opengl App", -width => $WIDTH, -height => $HEIGHT, -gl => 1);
    +	$SDLAPP = SDLx::App->new(title => "Opengl App", width => $WIDTH, height => $HEIGHT, gl => 1);
     	$SDLEVENT = SDL::Event->new;
     
    -
    -
    -
    -	glEnable(GL_DEPTH_TEST);
    +
    +

    SDLx::App can start an OpenGL application with the parameter gl => 1.

    +
    	glEnable(GL_DEPTH_TEST);
     	glMatrixMode(GL_PROJECTION);
     	glLoadIdentity;
     	gluPerspective(60, $WIDTH / $HEIGHT, 1, 1000);
     	glTranslatef(0, 0, -20);
     
    -
    -
    -
    -	while (1) {
    +
    +

    Above we enable GL and set the correct prespective

    +
    	while (1) {
     	  &handlepolls;
     	  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
     	  glRotatef(.1, 1, 1, 1);
    @@ -73,13 +74,9 @@
     	  $SDLAPP->sync;
     	}
     
    -
    -
    -
    -
    -
    -
    -	sub drawscene {
    +
    +

    For SDLx::App sync handles the GL buffer clean.

    +
    	sub drawscene {
     	  my ($color, $x, $y, $z);
     
     	  for (-2 .. 2) {
    @@ -96,15 +93,6 @@
     
     
     
    -
    -
    -
    -
    -
    -
    -
    -
    -
     	sub draw_cube {
     	  my (@indices, @vertices, $face, $vertex, $index, $coords);
     
    @@ -131,16 +119,9 @@
     	  return "";
     	}
     
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -	sub handlepolls {
    +
    +

    Below we can use SDL::Events as normal:

    +
    	sub handlepolls {
     	  my ($type, $key);
     
     	  SDL::Events::pump_events();
    @@ -168,7 +149,16 @@
     
     

    SEE ALSO

    Top

    -

    perl SDLx::App OpenGL

    +

    perl SDLx::App OpenGL

    + +
    +

    AUTHORS

    Top

    +
    +

    See /SDL.html#AUTHORS.

    + + + +
    \ No newline at end of file