Permalink
Browse files

Abstract SkyBox. Remove every reference to culling, ever.

The whole backface culling thing has caused so many irritating errors.
  • Loading branch information...
1 parent 1179b92 commit 38a64b8ecb6608e121caff33db866ca28d70a258 @johnfn committed Mar 20, 2012
Showing with 7 additions and 14 deletions.
  1. +1 −1 src/main/scala/Block.scala
  2. +1 −3 src/main/scala/Game.scala
  3. +5 −10 src/main/scala/SkyBox.scala
View
2 src/main/scala/Block.scala
@@ -107,7 +107,7 @@ class Block(block_x: Float, block_y: Float, block_z: Float) extends VBOModelEnti
y = block_y
z = block_z + 1.0f
- val model = new CubeModel(x, y, z)
+ val model = new SkyModel(x, y, z, 1.0f, "/textures/skybox.jpg")
override def update(m: EntityManager) = {
if (!selected) {
View
4 src/main/scala/Game.scala
@@ -66,7 +66,7 @@ object Main {
val finalShader = new Shader("minimal", "final")
var curLevel : Level = null
- var currentLevelNum = 1
+ var currentLevelNum = 4
def main(args:Array[String]) = {
var fullscreen = false
@@ -121,8 +121,6 @@ object Main {
glViewport(0, 0, WIDTH, HEIGHT)
glEnable(GL_DEPTH_TEST)
- glEnable(GL_CULL_FACE)
- glCullFace(GL_BACK)
}
def addObjects() = {
View
15 src/main/scala/SkyBox.scala
@@ -16,11 +16,11 @@ import com.threed.jpct._
import com.threed.jpct.util._
import math._
-class SkyModel(val x: Float, val y: Float, val z: Float)
- extends TexturedVBOModel(new ImageTexture("/textures/skybox.jpg"),
+class SkyModel(val x: Float, val y: Float, val z: Float, val size: Float, val texture: String)
+ extends TexturedVBOModel(new ImageTexture(texture),
new ColorTexture(0, 0, 0)) {
val name = "skybox"
- val WIDTH = 800.0f
+ val WIDTH = size
def offset(lists: List[List[Int]], offx: Float, offy: Float) = {
lists.map { case List(x, y) => List(x.toFloat * 0.25f + offx, y.toFloat * 0.33f + offy)}
@@ -81,7 +81,7 @@ val vertices = List(
)
vertices.zipWithIndex.map({ case (vertex, i) =>
- Vertex(vertex(0) * WIDTH + 5.0f, vertex(1) * WIDTH + 5.0f, vertex(2) * WIDTH + 5.0f,
+ Vertex(vertex(0) * WIDTH, vertex(1) * WIDTH, vertex(2) * WIDTH - 0.5f,
0.0f, 0.0f, 1.0f,
//normals(i / 4)(0), normals(i / 4)(1), normals(i / 4)(2),
texcoords(i)(0),texcoords(i)(1))
@@ -105,7 +105,6 @@ class SkyBox() extends VBOModelEntity {
glPushMatrix()
glPushAttrib(GL_ENABLE_BIT)
glEnable(GL_TEXTURE_2D)
- glDisable(GL_CULL_FACE)
glDisable(GL_DEPTH_TEST)
glDisable(GL_LIGHTING)
glDisable(GL_BLEND)
@@ -119,11 +118,7 @@ class SkyBox() extends VBOModelEntity {
renderGL(shader)
glPopAttrib()
glPopMatrix()
-
- glEnable(GL_CULL_FACE)
- glCullFace(GL_BACK)
-
}
- val model = new SkyModel(x, y, z)
+ val model = new SkyModel(x, y, z, 800.0f, "/textures/skybox.jpg")
}

0 comments on commit 38a64b8

Please sign in to comment.