1 package org.newdawn.slick.opengl.renderer; 2 3 import java.nio.ByteBuffer; 4 import java.nio.DoubleBuffer; 5 import java.nio.FloatBuffer; 6 import java.nio.IntBuffer; 7 8 import org.lwjgl.opengl.EXTSecondaryColor; 9 import org.lwjgl.opengl.EXTTextureMirrorClamp; 10 import org.lwjgl.opengl.GL11; 11 import org.lwjgl.opengl.GL12; 12 13 /** 14 * The description of the OpenGL functions used Slick. Any other rendering method will 15 * need to emulate these. 16 * 17 * @author kevin 18 */ 19 public interface SGL { 20 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 21 public static final int GL_TEXTURE_2D = GL11.GL_TEXTURE_2D; 22 23 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 24 public static final int GL_RGBA = GL11.GL_RGBA; 25 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 26 public static final int GL_ALPHA = GL11.GL_ALPHA; 27 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 28 public static final int GL_RGB = GL11.GL_RGB; 29 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 30 public static final int GL_LUMINANCE = GL11.GL_LUMINANCE; 31 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 32 public static final int GL_LUMINANCE_ALPHA = GL11.GL_LUMINANCE_ALPHA; 33 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 34 public static final int GL_UNSIGNED_BYTE = GL11.GL_UNSIGNED_BYTE; 35 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 36 public static final int GL_LINEAR = GL11.GL_LINEAR; 37 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 38 public static final int GL_NEAREST = GL11.GL_NEAREST; 39 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 40 public static final int GL_TEXTURE_MIN_FILTER = GL11.GL_TEXTURE_MIN_FILTER; 41 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 42 public static final int GL_TEXTURE_MAG_FILTER = GL11.GL_TEXTURE_MAG_FILTER; 43 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 44 public static final int GL_POINT_SMOOTH = GL11.GL_POINT_SMOOTH; 45 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 46 public static final int GL_POLYGON_SMOOTH = GL11.GL_POLYGON_SMOOTH; 47 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 48 public static final int GL_LINE_SMOOTH = GL11.GL_LINE_SMOOTH; 49 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 50 public static final int GL_SCISSOR_TEST = GL11.GL_SCISSOR_TEST; 51 52 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 53 public static final int GL_MODULATE = GL11.GL_MODULATE; 54 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 55 public static final int GL_TEXTURE_ENV = GL11.GL_TEXTURE_ENV; 56 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 57 public static final int GL_TEXTURE_ENV_MODE = GL11.GL_TEXTURE_ENV_MODE; 58 59 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 60 public static final int GL_QUADS = GL11.GL_QUADS; 61 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 62 public static final int GL_POINTS = GL11.GL_POINTS; 63 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 64 public static final int GL_LINES = GL11.GL_LINES; 65 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 66 public static final int GL_LINE_STRIP = GL11.GL_LINE_STRIP; 67 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 68 public static final int GL_TRIANGLES = GL11.GL_TRIANGLES; 69 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 70 public static final int GL_TRIANGLE_FAN = GL11.GL_TRIANGLE_FAN; 71 72 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 73 public static final int GL_SRC_ALPHA = GL11.GL_SRC_ALPHA; 74 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 75 public static final int GL_ONE = GL11.GL_ONE; 76 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 77 public static final int GL_ONE_MINUS_DST_ALPHA = GL11.GL_ONE_MINUS_DST_ALPHA; 78 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 79 public static final int GL_DST_ALPHA = GL11.GL_DST_ALPHA; 80 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 81 public static final int GL_ONE_MINUS_SRC_ALPHA = GL11.GL_ONE_MINUS_SRC_ALPHA; 82 83 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 84 public static final int GL_COMPILE = GL11.GL_COMPILE; 85 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 86 public static final int GL_MAX_TEXTURE_SIZE = GL11.GL_MAX_TEXTURE_SIZE; 87 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 88 public static final int GL_COLOR_BUFFER_BIT = GL11.GL_COLOR_BUFFER_BIT; 89 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 90 public static final int GL_DEPTH_BUFFER_BIT = GL11.GL_DEPTH_BUFFER_BIT; 91 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 92 public static final int GL_BLEND = GL11.GL_BLEND; 93 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 94 public static final int GL_COLOR_CLEAR_VALUE = GL11.GL_COLOR_CLEAR_VALUE; 95 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 96 public static final int GL_LINE_WIDTH = GL11.GL_LINE_WIDTH; 97 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 98 public static final int GL_CLIP_PLANE0 = GL11.GL_CLIP_PLANE0; 99 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 100 public static final int GL_CLIP_PLANE1 = GL11.GL_CLIP_PLANE1; 101 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 102 public static final int GL_CLIP_PLANE2 = GL11.GL_CLIP_PLANE2; 103 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 104 public static final int GL_CLIP_PLANE3 = GL11.GL_CLIP_PLANE3; 105 106 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 107 public static final int GL_COMPILE_AND_EXECUTE = GL11.GL_COMPILE_AND_EXECUTE; 108 109 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 110 public static final int GL_RGBA8 = GL11.GL_RGBA; 111 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 112 public static final int GL_RGBA16 = GL11.GL_RGBA16; 113 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 114 public static final int GL_BGRA = GL12.GL_BGRA; 115 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 116 public static final int GL_MIRROR_CLAMP_TO_EDGE_EXT = EXTTextureMirrorClamp.GL_MIRROR_CLAMP_TO_EDGE_EXT; 117 118 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 119 public static final int GL_TEXTURE_WRAP_S = GL11.GL_TEXTURE_WRAP_S; 120 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 121 public static final int GL_TEXTURE_WRAP_T = GL11.GL_TEXTURE_WRAP_T; 122 123 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 124 public static final int GL_CLAMP = GL11.GL_CLAMP; 125 126 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 127 public static final int GL_COLOR_SUM_EXT = EXTSecondaryColor.GL_COLOR_SUM_EXT; 128 129 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 130 public static final int GL_ALWAYS = GL11.GL_ALWAYS; 131 132 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 133 public static final int GL_DEPTH_TEST = GL11.GL_DEPTH_TEST; 134 135 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 136 public static final int GL_NOTEQUAL = GL11.GL_NOTEQUAL; 137 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 138 public static final int GL_EQUAL = GL11.GL_EQUAL; 139 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 140 public static final int GL_SRC_COLOR = GL11.GL_SRC_COLOR; 141 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 142 public static final int GL_ONE_MINUS_SRC_COLOR = GL11.GL_ONE_MINUS_SRC_COLOR; 143 /** OpenGL Enum - @url http://www.opengl.org/documentation */ 144 public static final int GL_MODELVIEW_MATRIX = GL11.GL_MODELVIEW_MATRIX; 145 146 /** 147 * Flush the current state of the renderer down to GL 148 */ 149 public void flush(); 150 151 /** 152 * Initialise the display 153 * 154 * @param width The width of the display 155 * @param height The height of the display 156 */ 157 public void initDisplay(int width, int height); 158 159 /** 160 * Enter orthographic mode 161 * 162 * @param xsize The size of the ortho display 163 * @param ysize The size of the ortho display 164 */ 165 public void enterOrtho(int xsize, int ysize); 166 167 /** 168 * OpenGL Method - @url http://www.opengl.org/documentation/ 169 * 170 * @param red red 171 * @param green green 172 * @param blue blue 173 * @param alpha alpha 174 */ 175 public void glClearColor(float red, float green, float blue, float alpha); 176 177 /** 178 * OpenGL Method - @url http://www.opengl.org/documentation/ 179 * 180 * @param plane plane 181 * @param buffer buffer 182 */ 183 public void glClipPlane(int plane, DoubleBuffer buffer); 184 185 /** 186 * OpenGL Method - @url http://www.opengl.org/documentation/ 187 * 188 * @param x x 189 * @param y y 190 * @param width width 191 * @param height height 192 */ 193 public void glScissor(int x, int y, int width, int height); 194 195 /** 196 * OpenGL Method - @url http://www.opengl.org/documentation/ 197 * 198 * @param width width 199 */ 200 public void glLineWidth(float width); 201 202 /** 203 * OpenGL Method - @url http://www.opengl.org/documentation/ 204 * 205 * @param value value 206 */ 207 public void glClear(int value); 208 209 /** 210 * OpenGL Method - @url http://www.opengl.org/documentation/ 211 * 212 * @param red red 213 * @param green green 214 * @param blue blue 215 * @param alpha alpha 216 */ 217 public void glColorMask(boolean red, boolean green, boolean blue, boolean alpha); 218 219 /** 220 * OpenGL Method - @url http://www.opengl.org/documentation/ 221 */ 222 public void glLoadIdentity(); 223 224 /** 225 * OpenGL Method - @url http://www.opengl.org/documentation/ 226 * 227 * @param id 228 * @param ret 229 */ 230 public void glGetInteger(int id, IntBuffer ret); 231 232 /** 233 * OpenGL Method - @url http://www.opengl.org/documentation/ 234 * 235 * @param id 236 * @param ret 237 */ 238 public void glGetFloat(int id, FloatBuffer ret); 239 240 /** 241 * OpenGL Method - @url http://www.opengl.org/documentation/ 242 * 243 * @param item 244 */ 245 public void glEnable(int item); 246 247 /** 248 * OpenGL Method - @url http://www.opengl.org/documentation/ 249 * 250 * @param item 251 */ 252 public void glDisable(int item); 253 254 /** 255 * OpenGL Method - @url http://www.opengl.org/documentation/ 256 * 257 * @param target 258 * @param id 259 */ 260 public void glBindTexture(int target, int id); 261 262 /** 263 * OpenGL Method - @url http://www.opengl.org/documentation/ 264 * 265 * @param target 266 * @param level 267 * @param format 268 * @param type 269 * @param pixels 270 */ 271 public void glGetTexImage(int target, int level, int format, int type, ByteBuffer pixels); 272 273 /** 274 * OpenGL Method - @url http://www.opengl.org/documentation/ 275 * 276 * @param buffer 277 */ 278 public void glDeleteTextures(IntBuffer buffer); 279 280 /** 281 * OpenGL Method - @url http://www.opengl.org/documentation/ 282 * 283 * @param r 284 * @param g 285 * @param b 286 * @param a 287 */ 288 public void glColor4f(float r, float g, float b, float a); 289 290 /** 291 * OpenGL Method - @url http://www.opengl.org/documentation/ 292 * 293 * @param u 294 * @param v 295 */ 296 public void glTexCoord2f(float u, float v); 297 298 /** 299 * OpenGL Method - @url http://www.opengl.org/documentation/ 300 * 301 * @param x 302 * @param y 303 * @param z 304 */ 305 public void glVertex3f(float x, float y, float z); 306 307 /** 308 * OpenGL Method - @url http://www.opengl.org/documentation/ 309 * 310 * @param x 311 * @param y 312 */ 313 public void glVertex2f(float x, float y); 314 315 /** 316 * OpenGL Method - @url http://www.opengl.org/documentation/ 317 * 318 * @param angle 319 * @param x 320 * @param y 321 * @param z 322 */ 323 public void glRotatef(float angle, float x, float y, float z); 324 325 /** 326 * OpenGL Method - @url http://www.opengl.org/documentation/ 327 * 328 * @param x 329 * @param y 330 * @param z 331 */ 332 public void glTranslatef(float x, float y, float z); 333 334 /** 335 * OpenGL Method - @url http://www.opengl.org/documentation/ 336 * 337 * @param geomType 338 */ 339 public void glBegin(int geomType); 340 341 /** 342 * OpenGL Method - @url http://www.opengl.org/documentation/ 343 */ 344 public void glEnd(); 345 346 /** 347 * OpenGL Method - @url http://www.opengl.org/documentation/ 348 * 349 * @param target 350 * @param mode 351 * @param value 352 */ 353 public void glTexEnvi(int target, int mode, int value); 354 355 /** 356 * OpenGL Method - @url http://www.opengl.org/documentation/ 357 * 358 * @param size 359 */ 360 public void glPointSize(float size); 361 362 /** 363 * OpenGL Method - @url http://www.opengl.org/documentation/ 364 * 365 * @param x 366 * @param y 367 * @param z 368 */ 369 public void glScalef(float x, float y, float z); 370 371 /** 372 * OpenGL Method - @url http://www.opengl.org/documentation/ 373 */ 374 public void glPushMatrix(); 375 376 /** 377 * OpenGL Method - @url http://www.opengl.org/documentation/ 378 */ 379 public void glPopMatrix(); 380 381 /** 382 * OpenGL Method - @url http://www.opengl.org/documentation/ 383 * 384 * @param src 385 * @param dest 386 */ 387 public void glBlendFunc(int src, int dest); 388 389 /** 390 * OpenGL Method - @url http://www.opengl.org/documentation/ 391 * 392 * @param count 393 * @return The index of the lists 394 */ 395 public int glGenLists(int count); 396 397 /** 398 * OpenGL Method - @url http://www.opengl.org/documentation/ 399 * 400 * @param id 401 * @param option 402 */ 403 public void glNewList(int id, int option); 404 405 /** 406 * OpenGL Method - @url http://www.opengl.org/documentation/ 407 */ 408 public void glEndList(); 409 410 /** 411 * OpenGL Method - @url http://www.opengl.org/documentation/ 412 * 413 * @param id 414 */ 415 public void glCallList(int id); 416 417 /** 418 * OpenGL Method - @url http://www.opengl.org/documentation/ 419 * 420 * @param target 421 * @param level 422 * @param internalFormat 423 * @param x 424 * @param y 425 * @param width 426 * @param height 427 * @param border 428 */ 429 public void glCopyTexImage2D(int target, int level, int internalFormat, 430 int x, int y, int width, int height, int border); 431 432 /** 433 * OpenGL Method - @url http://www.opengl.org/documentation/ 434 * 435 * @param x 436 * @param y 437 * @param width 438 * @param height 439 * @param format 440 * @param type 441 * @param pixels 442 */ 443 public void glReadPixels(int x, int y, int width, int height, int format, int type, 444 ByteBuffer pixels); 445 446 /** 447 * OpenGL Method - @url http://www.opengl.org/documentation/ 448 * 449 * @param target 450 * @param param 451 * @param value 452 */ 453 public void glTexParameteri(int target, int param, int value); 454 455 /** 456 * Get the current colour being rendered 457 * 458 * @return The current colour being rendered 459 */ 460 public float[] getCurrentColor(); 461 462 /** 463 * OpenGL Method - @url http://www.opengl.org/documentation/ 464 * 465 * @param list 466 * @param count 467 */ 468 public void glDeleteLists(int list, int count); 469 470 /** 471 * OpenGL Method - @url http://www.opengl.org/documentation/ 472 * 473 * @param mask 474 */ 475 public void glDepthMask(boolean mask); 476 477 /** 478 * OpenGL Method - @url http://www.opengl.org/documentation/ 479 * 480 * @param value 481 */ 482 public void glClearDepth(float value); 483 484 /** 485 * OpenGL Method - @url http://www.opengl.org/documentation/ 486 * 487 * @param func 488 */ 489 public void glDepthFunc(int func); 490 491 /** 492 * Set the scaling we'll apply to any colour binds in this renderer 493 * 494 * @param alphaScale The scale to apply to any colour binds 495 */ 496 public void setGlobalAlphaScale(float alphaScale); 497 498 /** 499 * OpenGL Method - @url http://www.opengl.org/documentation/ 500 * 501 * @param buffer buffer 502 */ 503 public void glLoadMatrix(FloatBuffer buffer); 504 505 /** 506 * OpenGL Method - @url http://www.opengl.org/documentation/ 507 * 508 * @param ids ids 509 */ 510 public void glGenTextures(IntBuffer ids); 511 512 /** 513 * OpenGL Method - @url http://www.opengl.org/documentation/ 514 */ 515 public void glGetError(); 516 517 /** 518 * OpenGL Method - @url http://www.opengl.org/documentation/ 519 * 520 * @param target 521 * @param i 522 * @param dstPixelFormat 523 * @param get2Fold 524 * @param get2Fold2 525 * @param j 526 * @param srcPixelFormat 527 * @param glUnsignedByte 528 * @param textureBuffer 529 */ 530 public void glTexImage2D(int target, int i, int dstPixelFormat, 531 int get2Fold, int get2Fold2, int j, int srcPixelFormat, 532 int glUnsignedByte, ByteBuffer textureBuffer); 533 534 535 /** 536 * OpenGL Method - @url http://www.opengl.org/documentation/ 537 * 538 * @param glTexture2d 539 * @param i 540 * @param pageX 541 * @param pageY 542 * @param width 543 * @param height 544 * @param glBgra 545 * @param glUnsignedByte 546 * @param scratchByteBuffer 547 */ 548 public void glTexSubImage2D(int glTexture2d, int i, int pageX, int pageY, 549 int width, int height, int glBgra, int glUnsignedByte, 550 ByteBuffer scratchByteBuffer); 551 552 /** 553 * Check if the mirror clamp extension is available 554 * 555 * @return True if the mirro clamp extension is available 556 */ 557 public boolean canTextureMirrorClamp(); 558 559 /** 560 * 561 * @return canSecondaryColor 562 */ 563 public boolean canSecondaryColor(); 564 565 /** 566 * 567 * @param b b 568 * @param c c 569 * @param d d 570 */ 571 public void glSecondaryColor3ubEXT(byte b, byte c, byte d); 572 }