diff options
Diffstat (limited to 'samples/opengl')
-rw-r--r-- | samples/opengl/.svn/all-wcprops | 17 | ||||
-rw-r--r-- | samples/opengl/.svn/entries | 96 | ||||
-rw-r--r-- | samples/opengl/.svn/format | 1 | ||||
-rw-r--r-- | samples/opengl/.svn/text-base/Makefile.svn-base | 18 | ||||
-rw-r--r-- | samples/opengl/.svn/text-base/OpenGL.cpp.svn-base | 143 | ||||
-rw-r--r--[-rwxr-xr-x] | samples/opengl/Makefile | 0 | ||||
-rw-r--r-- | samples/opengl/OpenGL.cpp | 2 |
7 files changed, 276 insertions, 1 deletions
diff --git a/samples/opengl/.svn/all-wcprops b/samples/opengl/.svn/all-wcprops new file mode 100644 index 0000000..3b356e4 --- /dev/null +++ b/samples/opengl/.svn/all-wcprops @@ -0,0 +1,17 @@ +K 25 +svn:wc:ra_dav:version-url +V 41 +/svnroot/sfml/!svn/ver/860/samples/opengl +END +OpenGL.cpp +K 25 +svn:wc:ra_dav:version-url +V 52 +/svnroot/sfml/!svn/ver/860/samples/opengl/OpenGL.cpp +END +Makefile +K 25 +svn:wc:ra_dav:version-url +V 50 +/svnroot/sfml/!svn/ver/169/samples/opengl/Makefile +END diff --git a/samples/opengl/.svn/entries b/samples/opengl/.svn/entries new file mode 100644 index 0000000..e8b7646 --- /dev/null +++ b/samples/opengl/.svn/entries @@ -0,0 +1,96 @@ +9 + +dir +915 +https://sfml.svn.sourceforge.net/svnroot/sfml/samples/opengl +https://sfml.svn.sourceforge.net/svnroot/sfml + + + +2008-09-07T16:59:18.761685Z +860 +laurentgom + + +svn:special svn:externals svn:needs-lock + + + + + + + + + + + +4e206d99-4929-0410-ac5d-dfc041789085 + +OpenGL.cpp +file + + + + +2008-11-01T16:24:41.000000Z +e4ea2e961c40c752fd6985ad8d1d4148 +2008-09-07T16:59:18.761685Z +860 +laurentgom + + + + + + + + + + + + + + + + + + + + + +5209 + +Makefile +file + + + + +2008-11-01T16:24:41.000000Z +355b25f0a9dd1115092ff0c046b0b184 +2007-08-07T12:03:36.394040Z +169 +laurentgom + + + + + + + + + + + + + + + + + + + + + +290 + diff --git a/samples/opengl/.svn/format b/samples/opengl/.svn/format new file mode 100644 index 0000000..ec63514 --- /dev/null +++ b/samples/opengl/.svn/format @@ -0,0 +1 @@ +9 diff --git a/samples/opengl/.svn/text-base/Makefile.svn-base b/samples/opengl/.svn/text-base/Makefile.svn-base new file mode 100644 index 0000000..42ff5ca --- /dev/null +++ b/samples/opengl/.svn/text-base/Makefile.svn-base @@ -0,0 +1,18 @@ +EXEC = opengl +OBJ = OpenGL.o + +all: $(EXEC) + +opengl: $(OBJ) + $(CC) $(LDFLAGS) -o $(EXECPATH)/$@ $(OBJ) -lsfml-graphics -lsfml-window -lsfml-system -lGLU -lGL + +%.o: %.cpp + $(CC) -o $@ -c $< $(CFLAGS) + +.PHONY: clean mrproper + +clean: + @rm -rf *.o + +mrproper: clean + @rm -rf $(EXECPATH)/$(EXEC) diff --git a/samples/opengl/.svn/text-base/OpenGL.cpp.svn-base b/samples/opengl/.svn/text-base/OpenGL.cpp.svn-base new file mode 100644 index 0000000..b08a549 --- /dev/null +++ b/samples/opengl/.svn/text-base/OpenGL.cpp.svn-base @@ -0,0 +1,143 @@ +
+////////////////////////////////////////////////////////////
+// Headers
+////////////////////////////////////////////////////////////
+#include <SFML/Graphics.hpp>
+#include <iostream>
+
+
+////////////////////////////////////////////////////////////
+/// Entry point of application
+///
+/// \return Application exit code
+///
+////////////////////////////////////////////////////////////
+int main()
+{
+ // Create main window
+ sf::RenderWindow App(sf::VideoMode(800, 600), "SFML OpenGL");
+ App.PreserveOpenGLStates(true);
+
+ // Create a sprite for the background
+ sf::Image BackgroundImage;
+ if (!BackgroundImage.LoadFromFile("datas/opengl/background.jpg"))
+ return EXIT_FAILURE;
+ sf::Sprite Background(BackgroundImage);
+
+ // Load an OpenGL texture.
+ // We could directly use a sf::Image as an OpenGL texture (with its Bind() member function),
+ // but here we want more control on it (generate mipmaps, ...) so we create a new one
+ GLuint Texture = 0;
+ {
+ sf::Image Image;
+ if (!Image.LoadFromFile("datas/opengl/texture.jpg"))
+ return EXIT_FAILURE;
+ glGenTextures(1, &Texture);
+ glBindTexture(GL_TEXTURE_2D, Texture);
+ gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, Image.GetWidth(), Image.GetHeight(), GL_RGBA, GL_UNSIGNED_BYTE, Image.GetPixelsPtr());
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
+ }
+
+ // Enable Z-buffer read and write
+ glEnable(GL_DEPTH_TEST);
+ glDepthMask(GL_TRUE);
+ glClearDepth(1.f);
+
+ // Setup a perspective projection
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ gluPerspective(90.f, 1.f, 1.f, 500.f);
+
+ // Bind our texture
+ glEnable(GL_TEXTURE_2D);
+ glBindTexture(GL_TEXTURE_2D, Texture);
+ glColor4f(1.f, 1.f, 1.f, 1.f);
+
+ // Create a clock for measuring the time elapsed
+ sf::Clock Clock;
+
+ // Start game loop
+ while (App.IsOpened())
+ {
+ // Process events
+ sf::Event Event;
+ while (App.GetEvent(Event))
+ {
+ // Close window : exit
+ if (Event.Type == sf::Event::Closed)
+ App.Close();
+
+ // Escape key : exit
+ if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
+ App.Close();
+
+ // Adjust the viewport when the window is resized
+ if (Event.Type == sf::Event::Resized)
+ glViewport(0, 0, Event.Size.Width, Event.Size.Height);
+ }
+
+ // Draw background
+ App.Draw(Background);
+
+ // Clear depth buffer
+ glClear(GL_DEPTH_BUFFER_BIT);
+
+ // Apply some transformations
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ glTranslatef(0.f, 0.f, -200.f);
+ glRotatef(Clock.GetElapsedTime() * 50, 1.f, 0.f, 0.f);
+ glRotatef(Clock.GetElapsedTime() * 30, 0.f, 1.f, 0.f);
+ glRotatef(Clock.GetElapsedTime() * 90, 0.f, 0.f, 1.f);
+
+ // Draw a cube
+ glBegin(GL_QUADS);
+
+ glTexCoord2f(0, 0); glVertex3f(-50.f, -50.f, -50.f);
+ glTexCoord2f(0, 1); glVertex3f(-50.f, 50.f, -50.f);
+ glTexCoord2f(1, 1); glVertex3f( 50.f, 50.f, -50.f);
+ glTexCoord2f(1, 0); glVertex3f( 50.f, -50.f, -50.f);
+
+ glTexCoord2f(0, 0); glVertex3f(-50.f, -50.f, 50.f);
+ glTexCoord2f(0, 1); glVertex3f(-50.f, 50.f, 50.f);
+ glTexCoord2f(1, 1); glVertex3f( 50.f, 50.f, 50.f);
+ glTexCoord2f(1, 0); glVertex3f( 50.f, -50.f, 50.f);
+
+ glTexCoord2f(0, 0); glVertex3f(-50.f, -50.f, -50.f);
+ glTexCoord2f(0, 1); glVertex3f(-50.f, 50.f, -50.f);
+ glTexCoord2f(1, 1); glVertex3f(-50.f, 50.f, 50.f);
+ glTexCoord2f(1, 0); glVertex3f(-50.f, -50.f, 50.f);
+
+ glTexCoord2f(0, 0); glVertex3f(50.f, -50.f, -50.f);
+ glTexCoord2f(0, 1); glVertex3f(50.f, 50.f, -50.f);
+ glTexCoord2f(1, 1); glVertex3f(50.f, 50.f, 50.f);
+ glTexCoord2f(1, 0); glVertex3f(50.f, -50.f, 50.f);
+
+ glTexCoord2f(0, 1); glVertex3f(-50.f, -50.f, 50.f);
+ glTexCoord2f(0, 0); glVertex3f(-50.f, -50.f, -50.f);
+ glTexCoord2f(1, 0); glVertex3f( 50.f, -50.f, -50.f);
+ glTexCoord2f(1, 1); glVertex3f( 50.f, -50.f, 50.f);
+
+ glTexCoord2f(0, 1); glVertex3f(-50.f, 50.f, 50.f);
+ glTexCoord2f(0, 0); glVertex3f(-50.f, 50.f, -50.f);
+ glTexCoord2f(1, 0); glVertex3f( 50.f, 50.f, -50.f);
+ glTexCoord2f(1, 1); glVertex3f( 50.f, 50.f, 50.f);
+
+ glEnd();
+
+ // Draw some text on top of our OpenGL object
+ sf::String Text("This is a rotating cube");
+ Text.SetPosition(250.f, 300.f);
+ Text.SetColor(sf::Color(128, 0, 128));
+ App.Draw(Text);
+
+ // Finally, display the rendered frame on screen
+ App.Display();
+ }
+
+ // Don't forget to destroy our texture
+ glDeleteTextures(1, &Texture);
+
+ return EXIT_SUCCESS;
+}
diff --git a/samples/opengl/Makefile b/samples/opengl/Makefile index 42ff5ca..42ff5ca 100755..100644 --- a/samples/opengl/Makefile +++ b/samples/opengl/Makefile diff --git a/samples/opengl/OpenGL.cpp b/samples/opengl/OpenGL.cpp index f4044f2..b08a549 100644 --- a/samples/opengl/OpenGL.cpp +++ b/samples/opengl/OpenGL.cpp @@ -75,7 +75,7 @@ int main() // Adjust the viewport when the window is resized
if (Event.Type == sf::Event::Resized)
glViewport(0, 0, Event.Size.Width, Event.Size.Height);
- }
+ }
// Draw background
App.Draw(Background);
|