Hey everyone, i am trying to use multitexture in JOGL and keep getting a compilation error. For some reason the program doesnt not understand what GL.GL_MAX_TEXTURE_UNITS_ARB and what GL.GL_TEXTURE0_ARB are. I have had no other issues with my program except these. I have the following imports and my code is also below. I really appreciate the help and what to thank everyone in advance.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| import javax.media.opengl.GL; import javax.vecmath.Point3f;
public void draw (GL gl) { gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); for(int i = 0; i < getNumFaces(); i++) { LevelFace face = getLevelFace(i); if(face.getType() != 1) continue;
gl.glActiveTextureARB(GL.GL_TEXTURE0_ARB); gl.glEnable(gl.GL_TEXTURE_2D); gl.glBindTexture(gl.GL_TEXTURE_2D, m_textures[pFace->texID].ID); gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_LINE); gl.glBegin(gl.GL_TRIANGLE_FAN);
for(int j = face.getStartVertexIndex(); j < face.getStartVertexIndex() + face.getTotalVertices(); j++) { Point3f vertex = getVertex(j); gl.glVertex3f(vertex.x, vertex.y, vertex.z); } gl.glEnd(); gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_FILL); } } |
The other file
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
| import java.awt.*; import java.awt.event.*;
import javax.media.opengl.*; import javax.media.opengl.glu.GLU;
import Level.*; import LevelLoader.LevelLoader;
import com.sun.opengl.util.*;
public static void main(String[] args) { Frame frame = new Frame("Counter Strike"); GLCanvas canvas = new GLCanvas(); canvas.addGLEventListener(new WarthogStrike()); frame.add(canvas); frame.setSize(800, 600); final Animator animator = new Animator(canvas);
... }
public void init(GLAutoDrawable drawable) { fpsDisplay = new DisplayFPS (drawable); GL gl = drawable.getGL(); String extensions = gl.glGetString(GL.GL_EXTENSIONS); boolean bMultiTexturing = (extensions.indexOf("GL_ARB_multitexture") !=-1); if (!bMultiTexturing) System.err.println("MultiTexturing Disabled"); int[] maxTextureUnits = new int[1]; gl.glGetIntegerv(gl.GL_MAX_TEXTURE_UNITS_ARB, maxTextureUnits); int nbTextureUnits = maxTextureUnits[0]; System.out.println("Texture Units available = " + nbTextureUnits);
System.err.println("INIT GL IS: " + gl.getClass().getName()); System.err.println("Chosen GLCapabilities: " + drawable.getChosenGLCapabilities()); gl.setSwapInterval(1);
gl.glEnable(GL.GL_DEPTH_TEST); drawable.addMouseListener(mouseEvents); drawable.addMouseMotionListener(mouseEvents); drawable.addKeyListener(keyEvents); LevelLoader loader = new LevelLoader(); loader.loadLevel("src/LevelFiles/level2.bsp"); currentLevel = loader.getLevel(); camera = new Camera(); camera.setCamera(0, 800, -150, 0, 150, -149, 0, 1, 0); } |