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