Bugzilla – Attachment 22 Details for
Bug 81
Incorporate Mojang's ScoreCapabilitiesChooser
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
Log In
[x]
|
Forgot Password
Login:
[x]
Mojang's ScoreCapabilitiesChooser
ScoreCapabilitiesChooser.java (text/plain), 6.41 KB, created by
Sven Gothel
on 2005-01-14 14:04:00 CET
(
hide
)
Description:
Mojang's ScoreCapabilitiesChooser
Filename:
MIME Type:
Creator:
Sven Gothel
Created:
2005-01-14 14:04:00 CET
Size:
6.41 KB
patch
obsolete
>package com.wurmonline.client; > >import java.util.*; > >import net.java.games.jogl.GLCapabilities; >import net.java.games.jogl.GLCapabilitiesChooser; > > >public class ScoreCapabilitiesChooser implements GLCapabilitiesChooser, Comparator >{ > public int requiredAccumAlphaBits = 0; > public int requiredAccumBlueBits = 0; > public int requiredAccumGreenBits = 0; > public int requiredAccumRedBits = 0; > public int requiredAlphaBits = 0; > public int requiredBlueBits = 0; > public int requiredDepthBits = 0; > public boolean requiredDoubleBuffered = false; > public int requiredGreenBits = 0; > public boolean requiredHardwareAccelerated = false; > public int requiredNumSamples = 0; > public boolean requiredOffscreenFloatingPointBuffers = false; > public boolean requiredOffscreenRenderToTexture = false; > public boolean requiredOffscreenRenderToTextureRectangle = false; > public int requiredRedBits = 0; > public boolean requiredSampleBuffers = false; > public int requiredStencilBits = 0; > public boolean requiredStereo = false; > > public float accumAlphaBitsScore = 0; > public float accumBlueBitsScore = 0; > public float accumGreenBitsScore = 0; > public float accumRedBitsScore = 0; > public float alphaBitsScore = 0.1f; > public float blueBitsScore = 1; > public float depthBitsScore = 1; > public float doubleBufferedScore = 500; > public float greenBitsScore = 1; > public float hardwareAcceleratedScore = 10000; > public float numSamplesScore = 0; > public float offscreenFloatingPointBuffersScore = 0; > public float offscreenRenderToTextureScore = 0; > public float offscreenRenderToTextureRectangleScore = 0; > public float redBitsScore = 1; > public float sampleBuffersScore = 100; > public float stencilBitsScore = 0.4f; > public float stereoScore = 0; > private float bestScore; > > public boolean verbose = false; > >// public int chooseCapabilities(GLCapabilities min, GLCapabilities[] caps) > public int chooseCapabilities(GLCapabilities min, GLCapabilities[] caps, int reccomended) > { > List unsortedCaps = new ArrayList(Arrays.asList(caps)); > List sortedCaps = new ArrayList(Arrays.asList(caps)); > > Collections.sort(sortedCaps, this); > > int selection = unsortedCaps.indexOf(sortedCaps.get(0)); > bestScore = getScore((GLCapabilities)sortedCaps.get(0)); > > if (verbose) > { > System.out.println("Highest score: "+getScore((GLCapabilities)sortedCaps.get(0))); > System.out.println("Lowest score: "+getScore((GLCapabilities)sortedCaps.get(sortedCaps.size()-1))); > System.out.println(); > System.out.println("Selection: "+selection+", reccomended: "+reccomended); >// System.out.println("Selection: "+selection); > } > > // Return the index of the best capabilities. > return selection; > } > > public int compare(Object o1, Object o2) > { > GLCapabilities c1 = (GLCapabilities)o1; > GLCapabilities c2 = (GLCapabilities)o2; > > float score1 = getScore(c1); > float score2 = getScore(c2); > > if (score1 > score2) > { > return -1; > } > else if (score1 < score2) > { > return 1; > } > else > { > return 0; > } > } > > private float getScore(GLCapabilities caps) > { > if (caps==null) return -9999999; > > int accumAlphaBits = caps.getAccumAlphaBits(); > int accumBlueBits = caps.getAccumBlueBits(); > int accumGreenBits = caps.getAccumGreenBits(); > int accumRedBits = caps.getAccumRedBits(); > int alphaBits = caps.getAlphaBits(); > int blueBits = caps.getBlueBits(); > int depthBits = caps.getDepthBits(); > boolean doubleBuffered = caps.getDoubleBuffered(); > int greenBits = caps.getGreenBits(); > boolean hardwareAccelerated = caps.getHardwareAccelerated(); > int numSamples = caps.getNumSamples(); > boolean offscreenFloatingPointBuffers = caps.getOffscreenFloatingPointBuffers(); > boolean offscreenRenderToTexture = caps.getOffscreenRenderToTexture(); > boolean offscreenRenderToTextureRectangle = caps.getOffscreenRenderToTextureRectangle(); > int redBits = caps.getRedBits(); > boolean sampleBuffers = caps.getSampleBuffers(); > int stencilBits = caps.getStencilBits(); > boolean stereo = caps.getStereo(); > > // Reject (ie set as very low score) if it fails any requirements > if (accumAlphaBits<requiredAccumAlphaBits) return -9999999; > if (accumBlueBits<requiredAccumBlueBits) return -9999999; > if (accumGreenBits<requiredAccumGreenBits) return -9999999; > if (accumRedBits<requiredAccumRedBits) return -9999999; > if (alphaBits<requiredAlphaBits) return -9999999; > if (blueBits<requiredBlueBits) return -9999999; > if (depthBits<requiredDepthBits) return -9999999; > if (!doubleBuffered && requiredDoubleBuffered) return -9999999; > if (greenBits<requiredGreenBits) return -9999999; > if (!hardwareAccelerated && requiredHardwareAccelerated) return -9999999; > if (numSamples<requiredNumSamples) return -9999999; > if (!offscreenFloatingPointBuffers && requiredOffscreenFloatingPointBuffers) return -9999999; > if (!offscreenRenderToTexture && requiredOffscreenRenderToTexture) return -9999999; > if (!offscreenRenderToTextureRectangle && requiredOffscreenRenderToTextureRectangle) return -9999999; > if (redBits<requiredRedBits) return -9999999; > if (!sampleBuffers && requiredSampleBuffers) return -9999999; > if (stencilBits<requiredStencilBits) return -9999999; > if (!stereo && requiredStereo) return -9999999; > > // Calculate the score > float score = 0; > score+=accumAlphaBits*accumAlphaBitsScore; > score+=accumBlueBits*accumBlueBitsScore; > score+=accumGreenBits*accumGreenBitsScore; > score+=accumRedBits*accumRedBitsScore; > score+=alphaBits*alphaBitsScore; > score+=blueBits*blueBitsScore; > score+=depthBits*depthBitsScore; > if (doubleBuffered) score+=doubleBufferedScore; > score+=greenBits*greenBitsScore; > if (hardwareAccelerated) score+=hardwareAcceleratedScore; > score+=numSamples*numSamplesScore; > if (offscreenFloatingPointBuffers) score+=offscreenFloatingPointBuffersScore; > if (offscreenRenderToTexture) score+=offscreenRenderToTextureScore; > if (offscreenRenderToTextureRectangle) score+=offscreenRenderToTextureRectangleScore; > score+=redBits*redBitsScore; > if (sampleBuffers) score+=sampleBuffersScore; > score+=stencilBits*stencilBitsScore; > if (stereo) score+=stereoScore; > > return score; > } > > public float getBestScore() > { > return bestScore; > } >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 81
: 22