root/trunk/orca/gl/gx.h

Revision 144, 3.6 kB (checked in by krobillard, 3 years ago)

Native arguments are now kept on the stack until after the call and the
result is now always put into a1.

Line 
1#ifndef GX_H
2#define GX_H
3/*============================================================================
4    ORCA OpenGL Module
5    Copyright (C) 2005-2006  Karl Robillard
6
7    This library is free software; you can redistribute it and/or
8    modify it under the terms of the GNU Lesser General Public
9    License as published by the Free Software Foundation; either
10    version 2.1 of the License, or (at your option) any later version.
11
12    This library is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15    Lesser General Public License for more details.
16
17    You should have received a copy of the GNU Lesser General Public
18    License along with this library; if not, write to the Free Software
19    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20===========================================================================*/
21
22
23#include <glv.h>
24#include "ovalue.h"
25#include "res.h"
26#include "res_font.h"
27
28
29enum ResourceTypes
30{
31    RES_TYPE_TEXTURE = 0,
32    RES_TYPE_DRAWLIST,
33    RES_TYPE_FONT,
34    RES_TYPE_COUNT
35};
36
37
38//----------------------------------------------------------------------------
39
40
41enum OImageFormat
42{
43    OR_IMG_GRAY = 1,
44    OR_IMG_RGB,
45    OR_IMG_RGBA
46};
47
48
49typedef struct
50{
51    uint8_t  format;
52    uint8_t  depth;
53    uint16_t width;
54    uint16_t height;
55    uint16_t _pad;
56}
57OImage;
58
59
60//----------------------------------------------------------------------------
61
62
63typedef struct
64{
65    Resource res;
66    //char*    name;
67    OIndex   imgHold;
68    GLuint   glTexId;
69}
70TextureResource;
71
72
73//----------------------------------------------------------------------------
74
75
76enum RenderState
77{
78    GRS_UNSET = 0,
79    GRS_TEXT,
80    GRS_SOLID,
81    GRS_MODEL
82};
83
84
85struct GxRenderState
86{
87    int      stateId;
88    uint32_t fontKey;
89    GLfloat  penX;
90    GLfloat  penY;
91
92    GLbitfield  clear;
93
94    OValue*  vertVals;
95    OValue*  normVals;
96    OValue*  colorVals;
97    OValue*  uvVals;
98};
99
100
101struct GxEnv
102{
103    double view_wd;     // Floating-point versions of GLView width & height.
104    double view_hd;
105    double view_aspect;
106
107    OAtom atom_joystick;
108    OAtom atom_model;
109    OAtom atom_solid;
110
111    OContext input_ctx;
112    OValue*  input_values;
113
114    OIndex  widgetCtxN;
115    OIndex  drawListDialectBlkN;
116
117    int prev_mouseX;
118    int prev_mouseY;
119
120    int running;
121    struct GxRenderState state;
122
123    ResourceDict resd;
124};
125
126
127extern struct GxEnv gEnv;
128extern GLView* gView;
129extern const char* orAtomCString( OAtom atom );
130
131extern void gxInitEnv();
132extern void gxFreeEnv();
133extern Resource* gxFindResource( int type, const char* name, int len );
134extern Resource* gxFindResourceKey( int type, uint32_t key );
135extern uint32_t gxHashString( OValue* );
136extern TextureResource* gxTexture( const char* file );
137extern void gxDrawText( FontResource*, const char* it, const char* end );
138extern void gxDrawTextValue( FontResource*, OValue* );
139extern GLuint gxLoadTexture( OValue* );
140
141#define gxTexture(k)  (TextureResource*) gxFindResourceKey(RES_TYPE_TEXTURE,k)
142#define gxFont(k)     (FontResource*) gxFindResourceKey(RES_TYPE_FONT,k)
143#define gxDList(k)  (DrawListResource*) gxFindResourceKey(RES_TYPE_DRAWLIST,k)
144
145#define gxSetPen(x,y)  gEnv.state.penX = x; gEnv.state.penY = y
146
147
148#define gxResultRES(rp) \
149   {orSetTF(a1, OT_RESOURCE); \
150    a1->argc  = rp->res.resType; \
151    a1->index = rp->res.resKey;}
152
153#define gxResType(val)  val->argc
154
155
156OBinary* orMakeImage( int format, int w, int h );
157
158#define orImagePixels(bin)  (bin->byteArray + sizeof(OImage))
159
160
161#endif /*GX_H*/
Note: See TracBrowser for help on using the browser.