Thread: openGL skybox help

  1. #1
    Registered User
    Join Date
    Apr 2011

    openGL skybox help

    I am currently doing a skybox for a living room using openGL with c++. All my codes are ready expect for the picture of the living room that I want to divide into 5 parts to make a skybox. I know how to use the photoshop to divide the image expect that I am not sure how to divide the image such that the skybox and the length are perfect. Anyway I am doing the skybox sides for a square cube skybox where there are front, left, right, top and bottom facing skybox. I do not have the sides for the backfacing as I am going to create that part for myself without skybox. So, my skybox would have 5 sides.

    So, how should I divide the image into 5 parts. Currently i divide my image such as like this. My left, front, right facing has definitely no problem expect the top and bottom facing where the image looks strectched. So, likes how should I divide the image to fit the skybox.
    |top |
    | | | |
    | | | |
    |left|front| right |
    |___|___ |_______ |
    |bottom |
    	glBindTexture(GL_TEXTURE_2D, texture[FRONT].id);
    		glTexCoord2f(0,1);glVertex3f(100, 100, 100);
    		glTexCoord2f(1,1);glVertex3f(-100, 100, 100);
    		glTexCoord2f(1,0);glVertex3f(-100, -100, 100);
    		glTexCoord2f(0,0);glVertex3f(100,-100, 100);
    	glBindTexture(GL_TEXTURE_2D, texture[LEFT].id);
    		glTexCoord2f(1,1);glVertex3f(100, 100, 100);    //0, 1
    		glTexCoord2f(1,0);glVertex3f(100, -100, 100);   //0, 0
    		glTexCoord2f(0,0);glVertex3f(100, -100, -100);  //1, 0
    		glTexCoord2f(0,1);glVertex3f(100, 100, -100);   //1, 1
    	glBindTexture(GL_TEXTURE_2D, texture[RIGHT].id);
    		glTexCoord2f(0,1);glVertex3f(-100, 100, 100); 
    		glTexCoord2f(0,0);glVertex3f(-100, -100, 100);
    		glTexCoord2f(1,0);glVertex3f(-100, -100, -100);
    		glTexCoord2f(1,1);glVertex3f(-100, 100, -100);
    	glBindTexture(GL_TEXTURE_2D, texture[TOP].id);
    		glTexCoord2f(0,0);glVertex3f(100, 100, 100); //0, 0
    		glTexCoord2f(1,0);glVertex3f(-100, 100, 100);//1, 0
    		glTexCoord2f(1,1);glVertex3f(-100, 100, -100);//1, 1
    		glTexCoord2f(0,1);glVertex3f(100, 100, -100);//0, 1
    	glBindTexture(GL_TEXTURE_2D, texture[BOTTOM].id);
    		glTexCoord2f(1,0);glVertex3f(100, -100, 100);
    		glTexCoord2f(1,1);glVertex3f(-100, -100, 100);
    		glTexCoord2f(0,1);glVertex3f(-100, -100, -100);
    		glTexCoord2f(0,0);glVertex3f(100, -100, -100);
    This is my part of c++ code. All my codes are correct and what I am doing is a square skybox.

    I'm not asking for help the c++ code expect the image where how should I cut into 5 parts of skybox.
    Attached Images Attached Images openGL skybox help-livingroom-layout-jpg 

  2. #2
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    You need 6 images for the skybox to work. There is no way to get the top and bottom images from that image.

  3. #3
    Registered User
    Join Date
    Apr 2011
    No, i am doing 5 images only. The back part, i'm going to create my own skybox using openGL drawings instead of the images.

  4. #4
    Just a pushpin. bernt's Avatar
    Join Date
    May 2009
    You still need multiple images; you're basically making a panorama. There is a free tool called Hugin that can stitch the photos together for you, that's what I use (but I don't have Photoshop... use whichever). To do the skybox you need to

    -Make a 360 degree panorama
    -Get 90 degree FOV rectilinear projections for each face of the cube you want to texture, and then you end up with something like this.
    Consider this post signed

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 09-02-2010, 01:26 PM
  2. Front texture for skybox
    By VirtualAce in forum Game Programming
    Replies: 3
    Last Post: 10-04-2007, 01:22 PM
  3. OpenGL Quesiton: Does Windows XP, Vista still at OpenGL 1.1?
    By indigo0086 in forum Game Programming
    Replies: 8
    Last Post: 05-21-2007, 11:18 AM
  4. Replies: 5
    Last Post: 02-12-2006, 07:42 PM
  5. Perfect skybox tool
    By VirtualAce in forum Game Programming
    Replies: 4
    Last Post: 04-03-2005, 02:35 PM