5 #include "../gfxdevice.h"
6 #include "../gfxtools.h"
14 typedef struct _fontlist {
17 struct _fontlist*next;
20 typedef struct _internal {
26 int opengl_setparameter(struct _gfxdevice*dev, const char*key, const char*value)
36 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
42 void opengl_startpage(struct _gfxdevice*dev, int width, int height)
44 glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
45 glutInitWindowSize(width,height);
46 glutInitWindowPosition(100,100);
47 glutCreateWindow("gfxdevice_opengl");
48 glutDisplayFunc(display);
50 glClearColor(1.0,0.0,0.0,0.0);
51 glShadeModel(GL_FLAT);
52 glEnable(GL_DEPTH_TEST);
53 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
55 glViewport(0,0, width, height);
57 glMatrixMode(GL_PROJECTION);
59 //gluPerspective(/*angle*/60.0, (GLfloat)width/(GLfloat)height, /*nearclip*/1.0, /*farclip*/30.0);
61 glMatrixMode(GL_MODELVIEW);
63 glScalef(1.0/width,1.0/height,1.0);
65 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
74 void opengl_startclip(struct _gfxdevice*dev, gfxline_t*line)
78 glColor3f(1.0,1.0,1.0);
80 glVertex3f(-t*10,-t*10,0);
81 glVertex3f(-t*10,t*10,0);
82 glVertex3f(t*10,t*10,0);
83 glVertex3f(t*10,-t*10,0);
86 //glRectf(-50,-50,0.0,0.0);
89 void opengl_endclip(struct _gfxdevice*dev)
93 void opengl_stroke(struct _gfxdevice*dev, gfxline_t*line, gfxcoord_t width, gfxcolor_t*color, gfx_capType cap_style, gfx_joinType joint_style, gfxcoord_t miterLimit)
97 void opengl_fill(struct _gfxdevice*dev, gfxline_t*line, gfxcolor_t*color)
101 void opengl_fillbitmap(struct _gfxdevice*dev, gfxline_t*line, gfximage_t*img, gfxmatrix_t*matrix, gfxcxform_t*cxform)
105 void opengl_fillgradient(struct _gfxdevice*dev, gfxline_t*line, gfxgradient_t*gradient, gfxgradienttype_t type, gfxmatrix_t*matrix)
109 void opengl_addfont(struct _gfxdevice*dev, char*fontid, gfxfont_t*font)
113 void opengl_drawchar(struct _gfxdevice*dev, char*fontid, int glyph, gfxcolor_t*color, gfxmatrix_t*matrix)
117 void opengl_drawlink(struct _gfxdevice*dev, gfxline_t*line, char*action)
121 void opengl_endpage(struct _gfxdevice*dev)
129 int opengl_result_save(struct _gfxresult*gfx, char*filename)
133 void* opengl_result_get(struct _gfxresult*gfx, char*name)
137 void opengl_result_destroy(struct _gfxresult*gfx)
142 gfxresult_t*opengl_finish(struct _gfxdevice*dev)
144 internal_t*i = (internal_t*)dev->internal;
145 gfxresult_t*result = (gfxresult_t*)malloc(sizeof(gfxresult_t));
146 memset(result, 0, sizeof(gfxresult_t));
147 result->save = opengl_result_save;
148 result->get = opengl_result_get;
149 result->destroy = opengl_result_destroy;
153 void gfxdevice_opengl_init(gfxdevice_t*dev)
155 internal_t*i = (internal_t*)rfx_calloc(sizeof(internal_t));
157 char*argv[]={"gfxdevice_opengl", 0};
158 glutInit(&argc, argv);
160 memset(dev, 0, sizeof(gfxdevice_t));
164 dev->setparameter = opengl_setparameter;
165 dev->startpage = opengl_startpage;
166 dev->startclip = opengl_startclip;
167 dev->endclip = opengl_endclip;
168 dev->stroke = opengl_stroke;
169 dev->fill = opengl_fill;
170 dev->fillbitmap = opengl_fillbitmap;
171 dev->fillgradient = opengl_fillgradient;
172 dev->addfont = opengl_addfont;
173 dev->drawchar = opengl_drawchar;
174 dev->drawlink = opengl_drawlink;
175 dev->endpage = opengl_endpage;
176 dev->finish = opengl_finish;