Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
Quellcode |
|
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 |
private void selection(){ // The selection buffer IntBuffer selBuffer = BufferUtils.createIntBuffer(256); IntBuffer vpBuffer = BufferUtils.createIntBuffer(64); // The number of "hits" (objects within the pick area). int hits=0; // Get the viewport info GL11.glGetInteger(GL11.GL_VIEWPORT, vpBuffer); // Set the buffer that OpenGL uses for selection to our buffer GL11.glSelectBuffer(selBuffer); // Change to selection mode GL11.glRenderMode(GL11.GL_SELECT); // Initialize the name stack (used for identifying which object was selected) GL11.glInitNames(); GL11.glPushName(0); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPushMatrix(); GL11.glLoadIdentity(); // create 5x5 pixel picking region near cursor location System.out.println("x: "+mouse_x + " y:" + (vpBuffer.get(3) - mouse_y)); GLU.gluPickMatrix(mouse_x, (vpBuffer.get(3) - mouse_y), 1.0f, 1.0f, vpBuffer); GL11.glOrtho(0.0, 8.0, 0.0, 8.0, -0.5, 2.5); // loadEnvironment(GL11.GL_SELECT); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPopMatrix(); GL11.glFlush(); hits = GL11.glRenderMode(GL11.GL_RENDER); System.out.println("Number: " + hits); } |
Quellcode |
|
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 |
private int createDL(){ //Displayliste erstellen int sphereDL; // parameter = anzahl displaylisten sphereDL = GL11.glGenLists(1); GL11.glNewList(sphereDL, GL11.GL_COMPILE); //zeichne spheres nodes.draw(0.2f, 16, 16); GL11.glEndList(); return (sphereDL); } // method draws all sphere objects on screen ( private void loadEnvironment(int mode){ //GL11.glInitNames(); //GL11.glRenderMode(GL11.GL_SELECT); // Draw A Sphere With A Radius Of 1 And 32 Longitude And 32 Latitude Segments for(int i = 0; i < numSpheres; i++) { if (mode == GL11.GL_SELECT) GL11.glLoadName(i); GL11.glPushMatrix(); //objekt auf namestack GL11.glPushName(i); xPos = randomFloat[i]; yPos = randomFloat[i+1]; zPos = randomFloat[i+2]; GL11.glVertex3f(xPos,yPos,zPos); GL11.glTranslatef(xPos, yPos, zPos); //displayliste ausfuehren GL11.glCallList(DLsphere); GL11.glTranslatef(-xPos, -yPos, -zPos); GL11.glPopName(); GL11.glPopMatrix(); } GL11.glRenderMode(GL11.GL_RENDER); } |
Quellcode |
|
1 |
nodes.draw(0.2f, 16, 16); |
Quellcode |
|
1 |
GL11.glRenderMode(GL11.GL_RENDER); |
Werbeanzeige