X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pages%2FSDL-Cookbook-OpenGL.html-inc;h=663bfd409784a02e040d04be0fe2ffd26edead7a;hb=801213bdc2b379a428fdebad07e9d404cec99a06;hp=11328ab1a7e72f073f9e63bfb0691aa1cf286cd8;hpb=411e0b6a19b323b88847fbffe2323afe98e9f8dc;p=sdlgit%2FSDL-Site.git diff --git a/pages/SDL-Cookbook-OpenGL.html-inc b/pages/SDL-Cookbook-OpenGL.html-inc index 11328ab..663bfd4 100644 --- a/pages/SDL-Cookbook-OpenGL.html-inc +++ b/pages/SDL-Cookbook-OpenGL.html-inc @@ -45,7 +45,9 @@ 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; @@ -53,19 +55,17 @@ $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 +73,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 +92,6 @@ - - - - - - - - - sub draw_cube { my (@indices, @vertices, $face, $vertex, $index, $coords); @@ -131,16 +118,9 @@ return ""; } - - - - - - - - - - sub handlepolls { ++
Below we can use SDL::Events as normal:
+sub handlepolls { my ($type, $key); SDL::Events::pump_events(); @@ -168,7 +148,7 @@SEE ALSO
\ No newline at end of file