本文整理汇总了C++中sf::Window::GetWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ Window::GetWidth方法的具体用法?C++ Window::GetWidth怎么用?C++ Window::GetWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sf::Window
的用法示例。
在下文中一共展示了Window::GetWidth方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initOpenGL
void initOpenGL() {
// Initialize GLEW on Windows, to make sure that OpenGL 2.0 is loaded
#ifdef FRAMEWORK_USE_GLEW
GLuint error = glewInit();
if (GLEW_OK != error) {
std::cerr << glewGetErrorString(error) << std::endl;
exit(-1);
}
if (!GLEW_VERSION_2_0 || !GL_EXT_framebuffer_object) {
std::cerr << "This program requires OpenGL 2.0 and FBOs" << std::endl;
exit(-1);
}
#endif
// This initializes OpenGL with some common defaults. More info here:
// http://www.sfml-dev.org/tutorials/1.6/window-opengl.php
glClearDepth(1.0f);
//glClearColor(0.529f, 0.808f, 0.980f, 1.0f);//sky blue
//glClearColor(0.529f, 0.808f, 0.980f, 1.0f);//sky blue
glClearColor(0.15f, 0.15f, 0.15f, 1.0f);//sky blue
glEnable(GL_DEPTH_TEST);
GL_CHECK(glEnable(GL_TEXTURE_2D));
glViewport(0, 0, window.GetWidth(), window.GetHeight());
}
示例2: setMatrices
void setMatrices(const aiScene * scene) {
// Set up the projection and model-view matrices
GLfloat aspectRatio = (GLfloat)window.GetWidth()/window.GetHeight();
GLfloat nearClip = 0.1f;
GLfloat farClip = 500.0f;
GLfloat fieldOfView = 45.0f; // Degrees
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(fieldOfView, aspectRatio, nearClip, farClip);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(current_location.x, current_location.y, current_location.z,
current_location.x + current_forward.x,
current_location.y + current_forward.y,
current_location.z + current_forward.z, 0.0f, 1.0f, 0.0f);
setupLights();
// Pass in our view matrix for cubemapping purposes
// note: this may not be the best place to actually pass it to the shader...
int shaderNum = 1;
GLfloat* vMatrix = new GLfloat[16];
glGetFloatv(GL_MODELVIEW_MATRIX, vMatrix);
// // Ugly, ugly, UGLY!
// aiMatrix4x4 invertMe = aiMatrix4x4(vMatrix[0], vMatrix[1], vMatrix[2], vMatrix[3], vMatrix[4], vMatrix[5], vMatrix[6], vMatrix[7], vMatrix[8], vMatrix[9], vMatrix[10], vMatrix[11], vMatrix[12], vMatrix[13], vMatrix[14], vMatrix[15]);
// aiMatrix4x4 inverted = invertMe.Inverse();
// GLfloat* vInvMatrix = new GLfloat{ inverted.a1, inverted.a2, inverted.a3, inverted.a4, inverted.b1, inverted.b2, inverted.b3, inverted.b4, inverted.c1, inverted.c2, inverted.c3, inverted.c4};
GLint vM = glGetUniformLocation(shaders[shaderNum]->programID(), "viewMatrix");
glUniformMatrix4fv(vM,1,true,vMatrix);
applyMatrixTransform(scene->mRootNode);
}
示例3: renderFrame
void renderFrame() {
glUseProgram(_mainShader.programID());
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f, _window.GetWidth()/_window.GetHeight(), 0.1f, 500);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
_camera.setViewTransform();
/*
glBegin(GL_TRIANGLES);
glVertex2f(0.0f, 0.0f);
glVertex2f(1.0f, 0.0f);
glVertex2f(1.0f, 1.0f);
glEnd();*/
for (int i =0; i < _scene._VBOs.size(); i++) {
Scene::VBO vbo = _scene._VBOs.at(i);
glBindBuffer(GL_ARRAY_BUFFER, vbo.position);
glVertexAttribPointer(_mainShader.getAttribLocationOf("positionIn"), 3, GL_FLOAT, GL_FALSE, sizeof(aiVector3D), 0);
glBindBuffer(GL_ARRAY_BUFFER, vbo.texcoord);
glVertexAttribPointer(_mainShader.getAttribLocationOf("texcoordIn"), 2, GL_FLOAT, GL_FALSE, sizeof(aiVector3D), 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbo.indices);
glDrawElements(GL_TRIANGLES, vbo.numIndices, GL_UNSIGNED_INT, 0);
}
}
示例4: setMatrices
void setMatrices()
{
// Set up the projection and model-view matrices
GLfloat aspectRatio = (GLfloat)window.GetWidth()/window.GetHeight();
GLfloat nearClip = 0.1f;
GLfloat farClip = 500.0f;
GLfloat fieldOfView = 45.0f; // Degrees
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(fieldOfView, aspectRatio, nearClip, farClip);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0.0, 0.0, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f);
glPushMatrix(); // set the light in the scene correctly
transNode(cathedralScene, cathedralScene->mRootNode);
GLfloat light0_position[] = { 0, 30, 0, 0 };
glLightfv( GL_LIGHT0, GL_POSITION, light0_position );
GLfloat light1_position[] = { 0, 11, 0, 0.0 };
glLightfv( GL_LIGHT1, GL_POSITION, light1_position );
glPopMatrix();
glRotatef(rad_to_deg(pitch), 1.0, 0.0, 0.0);
glRotatef(rad_to_deg(yaw), 0.0, 1.0, 0.0);
glTranslatef(position.x, position.y, position.z);
// We store the modelview matrix here, but it's actually the view matrix because we haven't done any model transforms yet
// static double viewMatrix[16];
GLfloat *viewMatrix = new GLfloat[16];
glGetFloatv(GL_MODELVIEW_MATRIX, viewMatrix);
GLint inverseViewMatrixUniform = glGetUniformLocation(envMapShader->programID(), "inverseViewMatrix");
glUniformMatrix4fv(inverseViewMatrixUniform, 1, true, viewMatrix);
delete [] viewMatrix;
}
示例5: init
void init(int argc, const char **argv)
{
assert(glewInit() == GLEW_OK);
assert(GLEW_VERSION_2_0 || GL_EXT_framebuffer_object);
glClearDepth(1.0f);
glClearColor(0.15f, 0.15f, 0.15f, 1.0f);
glEnable(GL_DEPTH_TEST);
glViewport(0, 0, window.GetWidth(), window.GetHeight());
}
示例6: setPerspective
void setPerspective()
{
mat4 r;
switch (fflag) {
case 'a':
case 'q': dir = rot(-ROT_SPEED * bank * abs(bank) / 50 / 50, dir);
if (bank < MAX_BANK) {
r = glm::rotate(mstack.top(), BANK_SPEED, glm::vec3(0.0f, 0.0f, 1.0f));
mstack.pop();
mstack.push(r);
bank += BANK_SPEED ;
}
break;
case 'd':
case 'e':
dir = rot(-ROT_SPEED * bank * abs(bank) / 50 / 50, dir);
if (bank > -MAX_BANK) {
r = glm::rotate(mstack.top(), -BANK_SPEED, glm::vec3(0.0f, 0.0f, 1.0f));
mstack.pop();
mstack.push(r);
bank -= BANK_SPEED;
}
break;
default:
if (speed_multiplier > 0.2 && fflag == 's') speed_multiplier -= 0.01;
if (speed_multiplier < 4.0 && fflag == 'w') speed_multiplier += 0.01;
if (bank < BANK_SPEED && bank > -BANK_SPEED) {
r = glm::rotate(mstack.top(), -bank, glm::vec3(0.0f, 0.0f, 1.0f));
bank = 0;
}
else {
dir = rot(-ROT_SPEED * bank * abs(bank) / 50 / 50, dir);
r = glm::rotate(mstack.top(), -bank * BANK_SPEED / 40, glm::vec3(0.0f, 0.0f, 1.0f));
bank += -bank * BANK_SPEED / 40;
}
mstack.pop();
mstack.push(r);
break;
}
if (move)
eye += vec2(dir.x * PLANE_SPEED, dir.y * PLANE_SPEED);
g_projection = glm::perspective(45.0f,
(GLfloat)window.GetWidth()/window.GetHeight(), 0.1f, 175.0f);
g_modelview = glm::lookAt(vec3(eye.x, 5, eye.y), vec3(eye.x+dir.x, 4.7, eye.y+dir.y), vec3(0, 1, 0));
}
示例7: initOpenGL
void initOpenGL() {
// Initialize GLEW on Windows, to make sure that OpenGL 2.0 is loaded
#ifdef FRAMEWORK_USE_GLEW
GLint error = glewInit();
if (GLEW_OK != error) {
std::cerr << glewGetErrorString(error) << std::endl;
exit(-1);
}
if (!GLEW_VERSION_2_0 || !GL_EXT_framebuffer_object) {
std::cerr << "This program requires OpenGL 2.0 and FBOs" << std::endl;
exit(-1);
}
#endif
// This initializes OpenGL with some common defaults. More info here:
// http://www.sfml-dev.org/tutorials/1.6/window-opengl.php
glClearDepth(1.0f);
glClearColor(0.15f, 0.15f, 0.15f, 1.0f);
glEnable(GL_DEPTH_TEST);
glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
glViewport(0, 0, window.GetWidth(), window.GetHeight());
position = aiVector3D(35.0, -20.0, 0.0);
yaw = M_PI * 3 / 2.0;
pitch = -M_PI / 7;
GLfloat light0_position[] = { 0.0, 30.0, 0.0, 0.0 };
GLfloat light0_ambient[] = { 245/2550.0, 222/2550.0, 179/2550.0, 1 };
GLfloat light0_diffuse[] = { 245/255.0, 232/255.0, 199/255.0, 1 };
GLfloat light0_specular[] = { 0.7, 0.7, 0.7, 1 };
GLfloat shininess = 90;
glLightfv(GL_LIGHT0, GL_POSITION, light0_position);
glLightfv( GL_LIGHT0, GL_AMBIENT, light0_ambient );
glLightfv( GL_LIGHT0, GL_DIFFUSE, light0_diffuse );
glLightfv( GL_LIGHT0, GL_SPECULAR, light0_specular );
glLightfv( GL_LIGHT0, GL_SHININESS, &shininess );
glEnable(GL_LIGHT0);
GLfloat light1_position[] = { 0, 11, 0, 0.0 };
GLfloat light1_diffuse[] = { 145/2550.0, 222/2550.0, 149/2550.0, 1 };
GLfloat light1_specular[] = { 0.1, 0.1, 0.1, 1 };
glLightfv( GL_LIGHT1, GL_POSITION, light1_position );
glLightfv( GL_LIGHT1, GL_DIFFUSE, light1_diffuse );
glLightfv( GL_LIGHT1, GL_SPECULAR, light1_specular );
glEnable(GL_LIGHT1);
depthRenderTarget = new DepthRenderTarget(RENDER_WIDTH * SHADOW_MAP_RATIO, RENDER_HEIGHT * SHADOW_MAP_RATIO);
}
示例8: createView
void createView() {
// Set up the projection and model-view matrices
GLfloat aspectRatio = (GLfloat) window.GetWidth() / window.GetHeight();
GLfloat nearClip = 0.1f;
GLfloat farClip = 500.0f;
GLfloat fieldOfView = 45.0f; // Degrees
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(fieldOfView, aspectRatio, nearClip, farClip);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(cameraX, cameraY, cameraZ, 0, 0, 0, 0, 1, 0);
}
示例9: main
int main(int argc, char** argv) {
initOpenGL();
loadAssets();
// go to a square Viewport
glViewport(0, 0, CUBE_MAP_SIZE, CUBE_MAP_SIZE);
generateEnvironmentMap();
// go to our window Viewport
glViewport(0, 0, window.GetWidth(), window.GetHeight());
// Put your game loop here (i.e., render with OpenGL, update animation)
while (window.IsOpened()) {
handleInput();
renderFrame();
window.Display();
updatePositions();
}
return 0;
}
示例10: main
int main ( int argc, char **argv )
{
// On cr�e notre fen�tre gr�ce � SFML
Application.Create( sf::VideoMode( 800, 500, 32 ), "SFML : Bullet physics", sf::Style::Titlebar | sf::Style::Resize | sf::Style::Close);
//Application.Create(sf::VideoMode::GetMode(0), "SFML Window", sf::Style::Fullscreen);
// Creation d'une fen�tre plein �cran avec le meilleur mode vid�o
/// Bullet physics
///collision configuration contains default setup for memory, collision setup
myCollisionConfiguration = new btDefaultCollisionConfiguration();
///use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded)
myDispatcher = new btCollisionDispatcher(myCollisionConfiguration);
myBroadphase = new btDbvtBroadphase();
///the default constraint solver. For parallel processing you can use a different solver (see Extras/BulletMultiThreaded)
mySequentialImpulseConstraintSolver = new btSequentialImpulseConstraintSolver;
// initialisation du monde bullet
myWorld = new btDiscreteDynamicsWorld(myDispatcher,myBroadphase,mySequentialImpulseConstraintSolver,myCollisionConfiguration);
// On d�finit la gravit�, de fa�on � ce que les objets tombent vers le bas (-Y).
myWorld->setGravity( btVector3(0,-10,0) );
/// SOL ///////////////////////////////////////////
// create a shape
btCollisionShape* shape_sol = new btBoxShape( btVector3(100,1,100) );
myTransform.setIdentity();
myTransform.setOrigin( btVector3(0,0,0) );
btVector3 localInertiaSol(0,0,0);
btScalar mass = 0;
// Using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
myMotionState_Sol = new btDefaultMotionState(myTransform);
btRigidBody::btRigidBodyConstructionInfo rbInfo_sol( mass, myMotionState_Sol, shape_sol, localInertiaSol );
body_sol = new btRigidBody(rbInfo_sol);
// Add the body to the dynamics world
myWorld->addRigidBody(body_sol);
// Create a clock for measuring time elapsed
sf::Clock montre;
//Variable pour calculer le delta de d�placement de la souris quand les clicks droit et gauche de la souris sont enfonc� pour manipuler la cam�ra
// Pour d�clancher la chute d'un seul kapla quand la touche Espace est relach�e
bool trigger = false;
unsigned int windowsWidth = Application.GetWidth();
unsigned int windowsHeight = Application.GetHeight();
int startPointX(0),startPointY(0);
float deltaX(0),deltaY(0),prevDeltaX(1),prevDeltaY(1);
int MouseX(0);
int MouseY(0);
bool show = true;
//unsigned int sizeWidth = sf::Window::GetWidth();
//On initialise une cam�ra qui sera plac� par d�faut par le constructeur
Camera camcam(110,60.0,60.0);
Cursor cursor;
bool test = false;
float time;
// pour avoir les infos clavier en temps r�el
const sf::Input& Input = Application.GetInput();
// Notre boucle d'affichage
while(Application.IsOpened() )
{
Application.ShowMouseCursor (false);
// r�f�rence vers l'entr�e associ�e � une fen�tre (pour r�cup�rer les donn�s clavier en temps r�el
sf::Event Event;
//Utilise les fl�che pour d�placer le Kapla qui va �tre lach�
// Get some useless input states, just to illustrate the tutorial
bool LeftKeyDown = Input.IsKeyDown(sf::Key::Left);
bool RightKeyDown = Input.IsKeyDown(sf::Key::Right);
bool UpKeyDown = Input.IsKeyDown(sf::Key::Up);
bool DownKeyDown = Input.IsKeyDown(sf::Key::Down);
bool RightButtonDown = Input.IsMouseButtonDown(sf::Mouse::Right);
bool LeftButtonDown = Input.IsMouseButtonDown(sf::Mouse::Left);
bool Espace = Input.IsKeyDown(sf::Key::Space);
bool Shift = Input.IsKeyDown(sf::Key::LShift);
MouseX = Input.GetMouseX() ;
MouseY = Input.GetMouseY() ;
//.........这里部分代码省略.........
示例11: initGL
void initGL() {
glClearDepth(1.0f);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glEnable(GL_DEPTH_TEST);
glViewport(0, 0, _window.GetWidth(), _window.GetHeight());
}
示例12: handleEvents
void handleEvents()
{
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();
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Space))
board->newGame(true);
// This is for grading your code. DO NOT REMOVE
if(Event.Type == sf::Event::KeyPressed && Event.Key.Code == sf::Key::Equal)
{
unsigned char *dest;
unsigned int w = App->GetWidth();
unsigned int h = App->GetHeight();
glPixelStorei(GL_PACK_ALIGNMENT, 1);
dest = (unsigned char *) malloc( sizeof(unsigned char)*w*h*3);
glReadPixels(0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE, dest);
FILE *file;
file = fopen("_program1.ppm", "wb");
fprintf(file, "P6\n%i %i\n%i\n", w, h, 255);
for(int i=h-1; i>=0; i--)
fwrite(&dest[i*w*3], sizeof(unsigned char), w*3, file);
fclose(file);
free(dest);
}
if(Event.Type == sf::Event::KeyPressed && Event.Key.Code == sf::Key::N){
board->newGame();
}
//handle mouse pressed
if(Event.Type == sf::Event::MouseButtonPressed)
{
if(Event.MouseButton.Button == sf::Mouse::Right) board->cancelPickup();
if(Event.MouseButton.Button == sf::Mouse::Left) {
int x = Event.MouseButton.X;
int y = Event.MouseButton.Y;
y = RESOLUTION - y;
board->display(true);
glFlush();
glFinish();
float clickColor[4];
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glReadPixels(x, y, 1, 1, GL_RGBA, GL_FLOAT, clickColor);
GLuint clickId = 0;
clickId = clickId | ((unsigned int)(clickColor[0] * 255.0f) << 0);
clickId = clickId | ((unsigned int)(clickColor[1] * 255.0f) << 8);
clickId = clickId | ((unsigned int)(clickColor[2] * 255.0f) << 16);
clickId = clickId | ((unsigned int)(clickColor[3] * 255.0f) << 24);
unsigned int objectId = clickId;
//printf("Selected: %02X %02X %02X %02X\n", (objectId >> 24) & 0xFF, (objectId >> 16) & 0xFF, (objectId >> 8) & 0xFF, objectId & 0xFF );
if(!board->piecePlace(objectId)){
board->piecePickUp(objectId);
}
}
}
}
}
示例13: loadAssets
void loadAssets()
{
loadParticles();
loadPlane();
pstack.push(glm::perspective(45.0f,
(GLfloat)window.GetWidth()/window.GetHeight(), 0.1f, 175.0f));
mstack.push(glm::lookAt(vec3(0, 2.7, 7), vec3(0, 2.4, 6), vec3(0, 1, 0)));
// Load terrain shader
if (!g_program.compileShaderFromFile(
ROOT_PATH_RELATIVE SHADER_DIR "terrain-vert.glsl",
GLSLShader::VERTEX)) {
fprintf(stderr, "%s\n", g_program.log().c_str());
exit(1);
}
if (!g_program.compileShaderFromFile(
ROOT_PATH_RELATIVE SHADER_DIR "terrain-frag.glsl",
GLSLShader::FRAGMENT)) {
fprintf(stderr, "%s\n", g_program.log().c_str());
exit(1);
}
if (!g_program.compileShaderFromFile(
ROOT_PATH_RELATIVE SHADER_DIR "terrain-tc.glsl",
GLSLShader::TESS_CONTROL)) {
fprintf(stderr, "%s\n", g_program.log().c_str());
exit(1);
}
if (!g_program.compileShaderFromFile(
ROOT_PATH_RELATIVE SHADER_DIR "terrain-te.glsl",
GLSLShader::TESS_EVALUATION)) {
fprintf(stderr, "%s\n", g_program.log().c_str());
exit(1);
}
if (!g_program.link()) {
fprintf(stderr, "%s\n", g_program.log().c_str());
exit(1);
}
// Load plane shader
if (!d_program.compileShaderFromFile(
ROOT_PATH_RELATIVE SHADER_DIR "default-vert.glsl",
GLSLShader::VERTEX)) {
fprintf(stderr, "%s\n", d_program.log().c_str());
exit(1);
}
if (!d_program.compileShaderFromFile(
ROOT_PATH_RELATIVE SHADER_DIR "default-frag.glsl",
GLSLShader::FRAGMENT)) {
fprintf(stderr, "%s\n", d_program.log().c_str());
exit(1);
}
const char *outputNames[] = { "Position" };
glTransformFeedbackVaryings(d_program.getHandle(), 1, outputNames, GL_SEPARATE_ATTRIBS);
if (!d_program.link()) {
fprintf(stderr, "%s\n", d_program.log().c_str());
exit(1);
}
g_program.use();
g_program.setUniform("Viewport", viewport);
g_program.setUniform("MinTessLevel", 1.0f);
g_program.setUniform("MaxTessLevel", max_tess);
//g_program.setUniform("MaxTessLevel", 20.0f);
g_program.setUniform("NearClip", 0.1f);
g_program.setUniform("FarClip", 175.0f);
g_program.setUniform("NearFog", 10.0f);
g_program.setUniform("FarFog", 125.0f);
g_program.setUniform("Light0.position", vec3(L0POSITION));
g_program.setUniform("Light0.La", vec3(L0AMBIENT));
g_program.setUniform("Light0.Ld", vec3(L0DIFFUSE));
GLuint terrainmap = SOIL_load_OGL_texture (
ROOT_PATH_RELATIVE TEXTURE_DIR "heightmap-vlarge.png",
SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_LOAD_L );
GLuint watermap = SOIL_load_OGL_texture (
ROOT_PATH_RELATIVE TEXTURE_DIR "watermap.jpg",
SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_LOAD_L );
GLuint ttex1 = SOIL_load_OGL_texture (
ROOT_PATH_RELATIVE TEXTURE_DIR "grass.jpg",
SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_LOAD_L );
GLuint ttex2 = SOIL_load_OGL_texture (
ROOT_PATH_RELATIVE TEXTURE_DIR "stonesnow.jpg",
SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_LOAD_L );
GLuint ttex3 = SOIL_load_OGL_texture (
ROOT_PATH_RELATIVE TEXTURE_DIR "water.jpg",
SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_LOAD_L );
//.........这里部分代码省略.........
示例14: generateCubeMap
void generateCubeMap()
{
glViewport(0, 0, CUBE_MAP_SIZE, CUBE_MAP_SIZE);
glUseProgram(phongShader->programID());
GLint drawShadows = glGetUniformLocation(phongShader->programID(), "drawShadows");
glUniform1i(drawShadows, 0);
glGenTextures(1, &cubeMapTextureID);
glBindTexture(GL_TEXTURE_CUBE_MAP, cubeMapTextureID);
glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
for (uint face = 0; face < 6; face++) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Set up the projection and model-view matrices
GLfloat aspectRatio = 1.0f;
GLfloat nearClip = 0.1f;
GLfloat farClip = 500.0f;
GLfloat fieldOfView = 90.0f; // Degrees
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(fieldOfView, aspectRatio, nearClip, farClip);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
switch (face) {
case 0:
/// positive x
gluLookAt(0.0f, 2.0f, 0.0f,
1.0f, 2.0f, 0.0f,
0.0f, 1.0f, 0.0f);
break;
case 1:
// negative x
gluLookAt(0.0f, 2.0f, 0.0f,
-1.0f, 2.0f, 0.0f,
0.0f, 1.0f, 0.0f);
break;
case 2:
// positive y
gluLookAt(0.0f, 2.0f, 0.0f,
0.0f, 3.0f, 0.0f,
0.0f, 0.0f, -1.0f);
break;
case 3:
// negative y
gluLookAt(0.0f, 2.0f, 0.0f,
0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 1.0f);
break;
case 4:
// positive z
gluLookAt(0.0f, 2.0f, 0.0f,
0.0f, 2.0f, 1.0f,
0.0f, 1.0f, 0.0f);
break;
case 5:
// negative z
gluLookAt(0.0f, 2.0f, 0.0f,
0.0f, 2.0f, -1.0f,
0.0f, 1.0f, 0.0f);
break;
default:
break;
}
// TODO: WHY SO DARK CUBEMAP
glPushMatrix(); // set the light in the scene correctly
transNode(cathedralScene, cathedralScene->mRootNode); // TODO: STILL NEED TO FIGURE OUT WHY I DO THIS
GLfloat light0_position[] = { 0, 30, 0, 0 };
glLightfv( GL_LIGHT0, GL_POSITION, light0_position );
GLfloat light1_position[] = { 0, 11, 0, 0.0 };
glLightfv( GL_LIGHT1, GL_POSITION, light1_position );
glPopMatrix();
renderNode(phongShader, cathedralScene, cathedralScene->mRootNode, false);
// Copy the back buffer into the current face of the cube map
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, 0, GL_RGBA,
CUBE_MAP_SIZE, CUBE_MAP_SIZE, 0, GL_RGBA, GL_FLOAT, NULL);
glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, 0, 0, 0, 0, 0, CUBE_MAP_SIZE, CUBE_MAP_SIZE);
}
glUniform1i(drawShadows, 1);
glViewport(0, 0, window.GetWidth(), window.GetHeight());
}