1 /* 2 * Copyright (C) 2009 Chia-I Wu <olv (at) 0xlab.org> 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice (including the next 12 * paragraph) shall be included in all copies or substantial portions of the 13 * Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 * DEALINGS IN THE SOFTWARE. 22 */ 23 24 #include "main/drawtex.h" 25 #include "main/state.h" 26 #include "main/imports.h" 27 #include "main/mfeatures.h" 28 #include "main/mtypes.h" 29 30 31 #if FEATURE_OES_draw_texture 32 33 34 static void 35 draw_texture(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z, 36 GLfloat width, GLfloat height) 37 { 38 if (!ctx->Extensions.OES_draw_texture) { 39 _mesa_error(ctx, GL_INVALID_OPERATION, 40 "glDrawTex(unsupported)"); 41 return; 42 } 43 if (width <= 0.0f || height <= 0.0f) { 44 _mesa_error(ctx, GL_INVALID_VALUE, "glDrawTex(width or height <= 0)"); 45 return; 46 } 47 48 _mesa_set_vp_override(ctx, GL_TRUE); 49 50 if (ctx->NewState) 51 _mesa_update_state(ctx); 52 53 ASSERT(ctx->Driver.DrawTex); 54 ctx->Driver.DrawTex(ctx, x, y, z, width, height); 55 56 _mesa_set_vp_override(ctx, GL_FALSE); 57 } 58 59 60 void GLAPIENTRY 61 _mesa_DrawTexf(GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height) 62 { 63 GET_CURRENT_CONTEXT(ctx); 64 draw_texture(ctx, x, y, z, width, height); 65 } 66 67 68 void GLAPIENTRY 69 _mesa_DrawTexfv(const GLfloat *coords) 70 { 71 GET_CURRENT_CONTEXT(ctx); 72 draw_texture(ctx, coords[0], coords[1], coords[2], coords[3], coords[4]); 73 } 74 75 76 void GLAPIENTRY 77 _mesa_DrawTexi(GLint x, GLint y, GLint z, GLint width, GLint height) 78 { 79 GET_CURRENT_CONTEXT(ctx); 80 draw_texture(ctx, (GLfloat) x, (GLfloat) y, (GLfloat) z, 81 (GLfloat) width, (GLfloat) height); 82 } 83 84 85 void GLAPIENTRY 86 _mesa_DrawTexiv(const GLint *coords) 87 { 88 GET_CURRENT_CONTEXT(ctx); 89 draw_texture(ctx, (GLfloat) coords[0], (GLfloat) coords[1], 90 (GLfloat) coords[2], (GLfloat) coords[3], (GLfloat) coords[4]); 91 } 92 93 94 void GLAPIENTRY 95 _mesa_DrawTexs(GLshort x, GLshort y, GLshort z, GLshort width, GLshort height) 96 { 97 GET_CURRENT_CONTEXT(ctx); 98 draw_texture(ctx, (GLfloat) x, (GLfloat) y, (GLfloat) z, 99 (GLfloat) width, (GLfloat) height); 100 } 101 102 103 void GLAPIENTRY 104 _mesa_DrawTexsv(const GLshort *coords) 105 { 106 GET_CURRENT_CONTEXT(ctx); 107 draw_texture(ctx, (GLfloat) coords[0], (GLfloat) coords[1], 108 (GLfloat) coords[2], (GLfloat) coords[3], (GLfloat) coords[4]); 109 } 110 111 112 void GLAPIENTRY 113 _mesa_DrawTexx(GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height) 114 { 115 GET_CURRENT_CONTEXT(ctx); 116 draw_texture(ctx, 117 (GLfloat) x / 65536.0f, 118 (GLfloat) y / 65536.0f, 119 (GLfloat) z / 65536.0f, 120 (GLfloat) width / 65536.0f, 121 (GLfloat) height / 65536.0f); 122 } 123 124 125 void GLAPIENTRY 126 _mesa_DrawTexxv(const GLfixed *coords) 127 { 128 GET_CURRENT_CONTEXT(ctx); 129 draw_texture(ctx, 130 (GLfloat) coords[0] / 65536.0f, 131 (GLfloat) coords[1] / 65536.0f, 132 (GLfloat) coords[2] / 65536.0f, 133 (GLfloat) coords[3] / 65536.0f, 134 (GLfloat) coords[4] / 65536.0f); 135 } 136 137 #endif /* FEATURE_OES_draw_texture */ 138