All pastes #418543 Raw Edit

Mine

public cpp v1 · immutable
#418543 ·published 2007-03-31 17:42 UTC
rendered paste body
#include "../SOGLVideo/Window.h"#include "../SOGLInput/ActionManager.h"#include "../SOGLEvents/EventPump.h"#include <GL/glew.h>#include <boost/bind.hpp>#include <iostream>#include <cmath>SOGL::Video::Window mainWindow;bool ResetOGL(){	//glewInit();	//std::cout << "glew Initialised\n"; 	glShadeModel(GL_SMOOTH);	std::pair<int, int> size = mainWindow.GetSize();	glViewport(0, 0, size.first, size.second); 	glMatrixMode(GL_PROJECTION);	glLoadIdentity();	gluPerspective(40, 1, 0.0001, 1000.0);	glMatrixMode(GL_MODELVIEW);	glEnable(GL_DEPTH_TEST);}int main(int argc, char **argv){	SOGL::Events::EventPump eventLoop;	SOGL::Input::ActionManager input;	input.RegisterAction("Quit");	input.RegisterAction("Fullscreen");	input.RegisterActionKeyPress1("Quit", 'q');	input.RegisterActionKeyPress1("Fullscreen", 'a');	mainWindow.SetResetFunc(boost::bind(&ResetOGL));	mainWindow.CreateWindow(800, 600, 32, "testWindow");	eventLoop.SetKeyUpFunc(input.GetKeyReleasedFunc());	eventLoop.SetKeyDownFunc(input.GetKeyPressedFunc());	eventLoop.SetMouseButtonReleaseFunc(input.GetMouseButtonUpFunc());	eventLoop.SetMouseButtonPressFunc(input.GetMouseButtonDownFunc());	eventLoop.SetMouseMoveFunc(input.GetMouseMoveFunc());	eventLoop.SetWindowResizeFunc(boost::bind(&SOGL::Video::Window::SetSize, &mainWindow, _1, _2));	glewInit();	glClearColor(0.0, 0.0, 0.0, 1.0);	while (eventLoop.Update())	{		if (input.IsActive("Quit"))			eventLoop.PostQuitMessage();		if (input.IsActive("Fullscreen"))			mainWindow.SwitchFullscreen();		int width, height;		mainWindow.GetSize(width, height);		float halfWidth = static_cast<float>(width)/2.0f;		float halfHeight = static_cast<float>(height)/2.0f;		std::pair<int, int> mousePos = input.GetMousePosXY();		std::pair<float, float> mVec;		mVec.first = mousePos.first - halfWidth; mVec.second = mousePos.second - halfHeight;		float size = std::sqrt(mVec.first * mVec.first + mVec.second * mVec.second);		float percent = size / 400;		if (percent > 1.0) percent = 1.0;		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);		glLoadIdentity();		gluLookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);		glRotatef(percent * 180.0f, mVec.second, mVec.first, 0.0);		glBegin(GL_QUADS);			glColor3f(0.0, 0.0, 1.0);			glVertex3f(-1.0, -1.0, 1.0);			glColor3f(1.0, 0.0, 1.0);			glVertex3f(1.0, -1.0, 1.0);			glColor3f(1.0, 1.0, 1.0);			glVertex3f(1.0, 1.0, 1.0);			glColor3f(0.0, 1.0, 1.0);			glVertex3f(-1.0, 1.0, 1.0);			glColor3f(0.0, 0.0, 0.0);			glVertex3f(-1.0, -1.0, -1.0);			glColor3f(1.0, 0.0, 0.0);			glVertex3f(1.0, -1.0, -1.0);			glColor3f(1.0, 1.0, 0.0);			glVertex3f(1.0, 1.0, -1.0);			glColor3f(0.0, 1.0, 0.0);			glVertex3f(-1.0, 1.0, -1.0);			glColor3f(0.0, 0.0, 0.0);			glVertex3f(-1.0, -1.0, -1.0);			glColor3f(0.0, 0.0, 1.0);			glVertex3f(-1.0, -1.0, 1.0);			glColor3f(0.0, 1.0, 1.0);			glVertex3f(-1.0, 1.0, 1.0);			glColor3f(0.0, 1.0, 0.0);			glVertex3f(-1.0, 1.0, -1.0);			glColor3f(1.0, 0.0, 0.0);			glVertex3f(1.0, -1.0, -1.0);			glColor3f(1.0, 0.0, 1.0);			glVertex3f(1.0, -1.0, 1.0);			glColor3f(1.0, 1.0, 1.0);			glVertex3f(1.0, 1.0, 1.0);			glColor3f(1.0, 1.0, 0.0);			glVertex3f(1.0, 1.0, -1.0);			glColor3f(0.0, 0.0, 0.0);			glVertex3f(-1.0, -1.0, -1.0);			glColor3f(0.0, 0.0, 1.0);			glVertex3f(-1.0, -1.0, 1.0);			glColor3f(1.0, 0.0, 1.0);			glVertex3f(1.0, -1.0, 1.0);			glColor3f(1.0, 0.0, 0.0);			glVertex3f(1.0, -1.0, -1.0);			glColor3f(0.0, 1.0, 0.0);			glVertex3f(-1.0, 1.0, -1.0);			glColor3f(0.0, 1.0, 1.0);			glVertex3f(-1.0, 1.0, 1.0);			glColor3f(1.0, 1.0, 1.0);			glVertex3f(1.0, 1.0, 1.0);			glColor3f(1.0, 1.0, 0.0);			glVertex3f(1.0, 1.0, -1.0);		glEnd();				mainWindow.FlipBuffers();	}}