Пример #1
0
static int Color(lua_State *L) 
    {
    int color = luaL_checkinteger(L, 1);
    GLfloat red, green, blue;
    if(!lua_isnoneornil(L, 2)) /* set */
        {
        red = luaL_checknumber(L, 2);
        green = luaL_checknumber(L, 3);
        blue = luaL_checknumber(L, 4);
        glutSetColor(color, red, green, blue);
        }
    lua_pushnumber(L, glutGetColor(color, GLUT_RED));
    lua_pushnumber(L, glutGetColor(color, GLUT_GREEN));
    lua_pushnumber(L, glutGetColor(color, GLUT_BLUE));
    return 3;
    }
Пример #2
0
void
key(unsigned char c, int w, int h)
{
  int transP;

  printf("c=%d  w=%d h=%d\n", c, w, h);
  switch (c) {
  case 'e':
    glutEstablishOverlay();
    independent = 0;
    transP = glutLayerGet(GLUT_TRANSPARENT_INDEX);
    glClearIndex(transP);
    glutSetColor((transP + 1) % 2, 1.0, 1.0, 0.0);
    glIndexi((transP + 1) % 2);
    on = 1;
    break;
  case 'r':
    glutRemoveOverlay();
    on = 0;
    break;
  case 'm':
    if (glutLayerGet(GLUT_HAS_OVERLAY)) {
      int pixel;
      GLfloat red, green, blue;

      transP = glutLayerGet(GLUT_TRANSPARENT_INDEX);
      pixel = (transP + 1) % 2;
      red = glutGetColor(pixel, GLUT_RED) + 0.2;
      if (red > 1.0)
        red = red - 1.0;
      green = glutGetColor(pixel, GLUT_GREEN) - 0.1;
      if (green > 1.0)
        green = green - 1.0;
      blue = glutGetColor(pixel, GLUT_BLUE) + 0.1;
      if (blue > 1.0)
        blue = blue - 1.0;
      glutSetColor(pixel, red, green, blue);
    }
    break;
  case 'h':
    glutSetWindow(hidden_w);
    glutHideWindow();
    glutSetWindow(s2);
    glutHideWindow();
    break;
  case 's':
    glutSetWindow(hidden_w);
    glutShowWindow();
    glutSetWindow(s2);
    glutShowWindow();
    break;
  case 'H':
    glutHideOverlay();
    break;
  case 'S':
    glutShowOverlay();
    break;
  case 'D':
    glutDestroyWindow(main_w);
    exit(0);
    break;
  case ' ':
    printf("overlay possible: %d\n", glutLayerGet(GLUT_OVERLAY_POSSIBLE));
    printf("layer in  use: %d\n", glutLayerGet(GLUT_LAYER_IN_USE));
    printf("has overlay: %d\n", glutLayerGet(GLUT_HAS_OVERLAY));
    printf("transparent index: %d\n", glutLayerGet(GLUT_TRANSPARENT_INDEX));
    break;
  }
}
Пример #3
0
int
main(int argc, char **argv)
{
  int win1, win2, size;
  GLint isIndex;

  glutInit(&argc, argv);
  glutInitDisplayMode(GLUT_INDEX);
  if (!glutGet(GLUT_DISPLAY_MODE_POSSIBLE)) {
    printf("UNRESOLVED: test5 (your OpenGL lacks color index support)\n");
    exit(0);
  }
  glutInitWindowPosition(45, 45);
  win1 = glutCreateWindow("CI test 1");
  glGetIntegerv(GL_INDEX_MODE, &isIndex);
  if (isIndex == 0) {
    printf("FAIL: test5\n");
    exit(1);
  }
  size = glutGet(GLUT_WINDOW_COLORMAP_SIZE);
  if (size <= 1 || size > (1 << glutGet(GLUT_WINDOW_BUFFER_SIZE))) {
    printf("FAIL: test5\n");
    exit(1);
  }
  glutSetColor(2, 1.0, 3.4, 0.5);
  comp = glutGetColor(2, GLUT_RED);
  if (comp != 1.0) {
    printf("FAIL: test5\n");
    exit(1);
  }
  comp = glutGetColor(2, GLUT_GREEN);
  if (comp != 1.0) {
    printf("FAIL: test5\n");
    exit(1);
  }
  comp = glutGetColor(2, GLUT_BLUE);
  if (comp != 0.5) {
    printf("FAIL: test5\n");
    exit(1);
  }
  glutInitWindowPosition(450, 450);
  win2 = glutCreateWindow("CI test 2");
  glutCopyColormap(win1);
  if (glutGetColor(2, GLUT_RED) != 1.0) {
    printf("FAIL: test5\n");
    exit(1);
  }
  if (glutGetColor(2, GLUT_GREEN) != 1.0) {
    printf("FAIL: test5\n");
    exit(1);
  }
  if (glutGetColor(2, GLUT_BLUE) != 0.5) {
    printf("FAIL: test5\n");
    exit(1);
  }
  glutSetColor(2, -1.0, 0.25, 0.75);
  glutSetWindow(win1);
  if (win1 != glutGetWindow()) {
    printf("FAIL: test5\n");
    exit(1);
  }
  glutDisplayFunc(display);
  if (glutGetColor(2, GLUT_RED) != 1.0) {
    printf("FAIL: test5\n");
    exit(1);
  }
  if (glutGetColor(2, GLUT_GREEN) != 1.0) {
    printf("FAIL: test5\n");
    exit(1);
  }
  if (glutGetColor(2, GLUT_BLUE) != 0.5) {
    printf("FAIL: test5\n");
    exit(1);
  }
  glutSetWindow(win2);
  if (win2 != glutGetWindow()) {
    printf("FAIL: test5\n");
    exit(1);
  }
  if (glutGetColor(2, GLUT_RED) != 0.0) {
    printf("FAIL: test5\n");
    exit(1);
  }
  if (glutGetColor(2, GLUT_GREEN) != 0.25) {
    printf("FAIL: test5\n");
    exit(1);
  }
  if (glutGetColor(2, GLUT_BLUE) != 0.75) {
    printf("FAIL: test5\n");
    exit(1);
  }
  glutTimerFunc(1500, timeout, 1);
  glutDisplayFunc(display);
  glutMainLoop();
  return 0;             /* ANSI C requires main to return int. */
}
Пример #4
0
/*
 * Class:     gruenewa_opengl_GLUT__
 * Method:    glutGetColor
 * Signature: (II)F
 */
JNIEXPORT jfloat JNICALL Java_gruenewa_opengl_GLUT_00024_glutGetColor
  (JNIEnv * jenv, jobject jobj, jint arg1, jint arg2) {
  return glutGetColor(arg1, arg2); 
}