add opengl
This commit is contained in:
parent
5c7b41fe8f
commit
8bf954dd97
4
Makefile
4
Makefile
@ -7,9 +7,9 @@ CXX := $(PREFIX)-g++
|
|||||||
LD := $(PREFIX)-ld
|
LD := $(PREFIX)-ld
|
||||||
CPPFLAGS := -I$(SFML_DIR)/include
|
CPPFLAGS := -I$(SFML_DIR)/include
|
||||||
CXXFLAGS := -mwindows
|
CXXFLAGS := -mwindows
|
||||||
LDFLAGS := -L$(SFML_DIR)/lib -lsfml-system -lsfml-window -static-libstdc++ -static-libgcc -mwindows
|
LDFLAGS := -L$(SFML_DIR)/lib -lsfml-system -lsfml-window -lopengl32 -lglu32 -static-libstdc++ -static-libgcc -mwindows
|
||||||
|
|
||||||
all: clock window events dlls
|
all: clock window events opengl dlls
|
||||||
|
|
||||||
%: %.cpp
|
%: %.cpp
|
||||||
$(CXX) -o $@ $(CPPFLAGS) $(CXXFLAGS) $^ $(LDFLAGS)
|
$(CXX) -o $@ $(CPPFLAGS) $(CXXFLAGS) $^ $(LDFLAGS)
|
||||||
|
87
opengl.cpp
Normal file
87
opengl.cpp
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
|
||||||
|
#include <SFML/Window.hpp>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
sf::Clock Clock;
|
||||||
|
sf::Window App(sf::VideoMode(800, 600, 32), "SFML OpenGL");
|
||||||
|
App.UseVerticalSync(true);
|
||||||
|
App.SetActive();
|
||||||
|
|
||||||
|
// Set color and depth clear value
|
||||||
|
glClearDepth(1.f);
|
||||||
|
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||||
|
|
||||||
|
// Enable Z-buffer read and write
|
||||||
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
glDepthMask(GL_TRUE);
|
||||||
|
|
||||||
|
// Setup a perspective projection
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
gluPerspective(90.f, 1.f, 1.f, 500.f);
|
||||||
|
|
||||||
|
while (App.IsOpened())
|
||||||
|
{
|
||||||
|
sf::Event Event;
|
||||||
|
while (App.GetEvent(Event))
|
||||||
|
{
|
||||||
|
if (Event.Type == sf::Event::Closed)
|
||||||
|
App.Close();
|
||||||
|
|
||||||
|
if ( (Event.Type == sf::Event::KeyPressed)
|
||||||
|
&& (Event.Key.Code == sf::Key::Escape) )
|
||||||
|
App.Close();
|
||||||
|
|
||||||
|
if (Event.Type == sf::Event::Resized)
|
||||||
|
glViewport(0, 0, Event.Size.Width, Event.Size.Height);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
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);
|
||||||
|
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
|
||||||
|
glVertex3f(-50.f, -50.f, -50.f);
|
||||||
|
glVertex3f(-50.f, 50.f, -50.f);
|
||||||
|
glVertex3f( 50.f, 50.f, -50.f);
|
||||||
|
glVertex3f( 50.f, -50.f, -50.f);
|
||||||
|
|
||||||
|
glVertex3f(-50.f, -50.f, 50.f);
|
||||||
|
glVertex3f(-50.f, 50.f, 50.f);
|
||||||
|
glVertex3f( 50.f, 50.f, 50.f);
|
||||||
|
glVertex3f( 50.f, -50.f, 50.f);
|
||||||
|
|
||||||
|
glVertex3f(-50.f, -50.f, -50.f);
|
||||||
|
glVertex3f(-50.f, 50.f, -50.f);
|
||||||
|
glVertex3f(-50.f, 50.f, 50.f);
|
||||||
|
glVertex3f(-50.f, -50.f, 50.f);
|
||||||
|
|
||||||
|
glVertex3f(50.f, -50.f, -50.f);
|
||||||
|
glVertex3f(50.f, 50.f, -50.f);
|
||||||
|
glVertex3f(50.f, 50.f, 50.f);
|
||||||
|
glVertex3f(50.f, -50.f, 50.f);
|
||||||
|
|
||||||
|
glVertex3f(-50.f, -50.f, 50.f);
|
||||||
|
glVertex3f(-50.f, -50.f, -50.f);
|
||||||
|
glVertex3f( 50.f, -50.f, -50.f);
|
||||||
|
glVertex3f( 50.f, -50.f, 50.f);
|
||||||
|
|
||||||
|
glVertex3f(-50.f, 50.f, 50.f);
|
||||||
|
glVertex3f(-50.f, 50.f, -50.f);
|
||||||
|
glVertex3f( 50.f, 50.f, -50.f);
|
||||||
|
glVertex3f( 50.f, 50.f, 50.f);
|
||||||
|
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
App.Display();
|
||||||
|
}
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user