Win32: Moved getGammaRampLength to java side
This commit is contained in:
parent
ad1987d748
commit
07da99cd7d
|
@ -47,6 +47,8 @@ import org.lwjgl.LWJGLUtil;
|
|||
import org.lwjgl.input.Cursor;
|
||||
|
||||
final class Win32Display implements DisplayImplementation {
|
||||
private final static int GAMMA_LENGTH = 256;
|
||||
|
||||
private static Win32DisplayPeerInfo peer_info;
|
||||
|
||||
public void createWindow(DisplayMode mode, boolean fullscreen, int x, int y) throws LWJGLException {
|
||||
|
@ -57,7 +59,11 @@ final class Win32Display implements DisplayImplementation {
|
|||
public native void destroyWindow();
|
||||
public native void switchDisplayMode(DisplayMode mode) throws LWJGLException;
|
||||
public native void resetDisplayMode();
|
||||
public native int getGammaRampLength();
|
||||
|
||||
public int getGammaRampLength() {
|
||||
return GAMMA_LENGTH;
|
||||
}
|
||||
|
||||
public native void setGammaRamp(FloatBuffer gammaRamp) throws LWJGLException;
|
||||
public String getAdapter() {
|
||||
try {
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
|
||||
#include <windows.h>
|
||||
#include <jni.h>
|
||||
#include "extgl.h"
|
||||
#include "common_tools.h"
|
||||
|
||||
#ifdef _PRIVATE_WINDOW_H_
|
||||
#define WINDOW_H_API
|
||||
|
|
|
@ -45,14 +45,13 @@
|
|||
#define COMPILE_MULTIMON_STUBS
|
||||
#include <Multimon.h>
|
||||
#include <jni.h>
|
||||
#include "org_lwjgl_opengl_Win32Display.h"
|
||||
#include "display.h"
|
||||
#include "common_tools.h"
|
||||
|
||||
#define GAMMA_SIZE 256
|
||||
|
||||
static bool modeSet = false; // Whether we've done a display mode change
|
||||
static WORD originalGamma[3*GAMMA_SIZE]; // Original gamma settings
|
||||
static WORD currentGamma[3*GAMMA_SIZE]; // Current gamma settings
|
||||
static WORD originalGamma[3*org_lwjgl_opengl_Win32Display_GAMMA_LENGTH]; // Original gamma settings
|
||||
static WORD currentGamma[3*org_lwjgl_opengl_Win32Display_GAMMA_LENGTH]; // Current gamma settings
|
||||
static DEVMODE devmode; // Now we'll remember this value for the future
|
||||
|
||||
static jobject createDisplayMode(JNIEnv *env, DEVMODE *devmode) {
|
||||
|
@ -169,11 +168,6 @@ void switchDisplayMode(JNIEnv * env, jobject mode)
|
|||
modeSet = true;
|
||||
}
|
||||
|
||||
int getGammaRampLength(void)
|
||||
{
|
||||
return GAMMA_SIZE;
|
||||
}
|
||||
|
||||
void setGammaRamp(JNIEnv * env, jobject gammaRampBuffer)
|
||||
{
|
||||
int i;
|
||||
|
@ -183,12 +177,12 @@ void setGammaRamp(JNIEnv * env, jobject gammaRampBuffer)
|
|||
const float *gammaRamp = (const float *)(*env)->GetDirectBufferAddress(env, gammaRampBuffer);
|
||||
// Turn array of floats into array of RGB WORDs
|
||||
|
||||
for (i = 0; i < GAMMA_SIZE; i ++) {
|
||||
for (i = 0; i < org_lwjgl_opengl_Win32Display_GAMMA_LENGTH; i ++) {
|
||||
scaledRampEntry = gammaRamp[i]*0xffff;
|
||||
rampEntry = (WORD)scaledRampEntry;
|
||||
currentGamma[i] = rampEntry;
|
||||
currentGamma[i + GAMMA_SIZE] = rampEntry;
|
||||
currentGamma[i + 2*GAMMA_SIZE] = rampEntry;
|
||||
currentGamma[i + org_lwjgl_opengl_Win32Display_GAMMA_LENGTH] = rampEntry;
|
||||
currentGamma[i + 2*org_lwjgl_opengl_Win32Display_GAMMA_LENGTH] = rampEntry;
|
||||
}
|
||||
screenDC = GetDC(NULL);
|
||||
if (SetDeviceGammaRamp(screenDC, currentGamma) == FALSE) {
|
||||
|
@ -214,7 +208,7 @@ jobject initDisplay(JNIEnv * env)
|
|||
if (GetDeviceGammaRamp(screenDC, originalGamma) == FALSE) {
|
||||
printfDebugJava(env, "Failed to get initial device gamma");
|
||||
}
|
||||
memcpy(currentGamma, originalGamma, sizeof(WORD)*3*GAMMA_SIZE);
|
||||
memcpy(currentGamma, originalGamma, sizeof(WORD)*3*org_lwjgl_opengl_Win32Display_GAMMA_LENGTH);
|
||||
ReleaseDC(NULL, screenDC);
|
||||
|
||||
if (!EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &devmode)) {
|
||||
|
|
|
@ -48,7 +48,6 @@ extern jobjectArray getAvailableDisplayModes(JNIEnv *env);
|
|||
extern void switchDisplayMode(JNIEnv * env, jobject mode);
|
||||
extern void resetDisplayMode(JNIEnv * env);
|
||||
extern void restoreDisplayMode(void);
|
||||
extern int getGammaRampLength(void);
|
||||
extern void setGammaRamp(JNIEnv * env, jobject gammaRampBuffer);
|
||||
extern jobject initDisplay(JNIEnv * env);
|
||||
extern jstring getAdapter(JNIEnv * env);
|
||||
|
|
|
@ -354,10 +354,6 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_resetDisplayMode(JNIEn
|
|||
resetDisplayModeAndClipping(env);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Win32Display_getGammaRampLength(JNIEnv *env, jobject self) {
|
||||
return getGammaRampLength();
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_setGammaRamp(JNIEnv *env, jobject self, jobject gamma_buffer) {
|
||||
setGammaRamp(env, gamma_buffer);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue