public void init(GLAutoDrawable drawable) { drawable.setGL(new DebugGL2(drawable.getGL().getGL2())); final GL2 gl = drawable.getGL().getGL2(); // drawable.getGL().getGL2(); gl.glViewport(0, 0, SCREENW, SCREENH); // Clear color buffer with black // gl.glClearColor(1.0f, 0.5f, 1.0f, 1.0f); gl.glClearColor(.0f, .0f, .0f, 1.0f); gl.glClearDepth(1.0f); gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); gl.glEnable(GL2.GL_DEPTH_TEST); gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1); gl.glCreateShader(GL2GL3.GL_VERTEX_SHADER); shader.init(gl); int programName = shader.getID(); gl.glBindAttribLocation(programName, Object3D.VERTEXPOSITION, "inposition"); gl.glBindAttribLocation(programName, Object3D.VERTEXCOLOR, "incolor"); gl.glBindAttribLocation(programName, Object3D.VERTEXNORMAL, "innormal"); gl.glBindAttribLocation(programName, Object3D.VERTEXTEXCOORD0, "intexcoord0"); shader.link(gl); uniformMat = gl.glGetUniformLocation(programName, "mat"); uniformLight = gl.glGetUniformLocation(programName, "lightdir"); gl.glUseProgram(programName); gl.glUniform3f(uniformLight, 0f, 10f, -10f); obj.init(gl, mats, programName); gl.glUseProgram(0); }
public void init(GLAutoDrawable drawable) { GL2 gl = drawable.getGL().getGL2(); glut = new GLUT(); // gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); makeStripeImage(); gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1); gl.glGenTextures(1, texName, 0); gl.glBindTexture(GL2.GL_TEXTURE_1D, texName[0]); gl.glTexParameterf(GL2.GL_TEXTURE_1D, GL2.GL_TEXTURE_WRAP_S, GL2.GL_REPEAT); gl.glTexParameterf( GL2.GL_TEXTURE_1D, // GL2.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR); gl.glTexParameterf( GL2.GL_TEXTURE_1D, // GL2.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR); gl.glTexImage1D( GL2.GL_TEXTURE_1D, 0, GL2.GL_RGBA, stripeImageWidth, // 0, GL2.GL_RGB, GL.GL_UNSIGNED_BYTE, stripeImageBuf); gl.glTexEnvf(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_MODULATE); currentCoeff = xequalzero; currentGenMode = GL2.GL_OBJECT_LINEAR; currentPlane = GL2.GL_OBJECT_PLANE; gl.glTexGeni(GL2.GL_S, GL2.GL_TEXTURE_GEN_MODE, GL2.GL_OBJECT_LINEAR); gl.glTexGendv(GL2.GL_S, GL2.GL_OBJECT_PLANE, currentCoeff, 0); // gl.glEnable(GL.GL_DEPTH_TEST); gl.glDepthFunc(GL.GL_LESS); gl.glEnable(GL2.GL_TEXTURE_GEN_S); gl.glEnable(GL2.GL_TEXTURE_1D); gl.glEnable(GL.GL_CULL_FACE); gl.glEnable(GL2.GL_LIGHTING); gl.glEnable(GL2.GL_LIGHT0); gl.glEnable(GL2.GL_AUTO_NORMAL); gl.glEnable(GL2.GL_NORMALIZE); gl.glFrontFace(GL.GL_CW); gl.glCullFace(GL.GL_BACK); gl.glMaterialf(GL.GL_FRONT, GL2.GL_SHININESS, 64.0f); }