pcb 4.1.1
An interactive printed circuit board layout editor.

hidgl.h

Go to the documentation of this file.
00001 /*
00002  *                            COPYRIGHT
00003  *
00004  *  PCB, interactive printed circuit board design
00005  *  Copyright (C) 2009-2011 PCB Contributors (See ChangeLog for details).
00006  *
00007  *  This program is free software; you can redistribute it and/or modify
00008  *  it under the terms of the GNU General Public License as published by
00009  *  the Free Software Foundation; either version 2 of the License, or
00010  *  (at your option) any later version.
00011  *
00012  *  This program is distributed in the hope that it will be useful,
00013  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *  GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License along
00018  * with this program; if not, write to the Free Software Foundation, Inc.,
00019  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00020  *
00021  */
00022 
00023 #ifndef PCB_HID_COMMON_HIDGL_H
00024 #define PCB_HID_COMMON_HIDGL_H
00025 
00026 #ifdef WIN32
00027 #define _GLUfuncptr void *
00028 #endif
00029 
00030 #define TRIANGLE_ARRAY_SIZE 5461
00031 typedef struct {
00032   GLfloat triangle_array [3 * 3 * TRIANGLE_ARRAY_SIZE];
00033   unsigned int triangle_count;
00034   unsigned int coord_comp_count;
00035 } triangle_buffer;
00036 
00037 extern triangle_buffer buffer;
00038 extern float global_depth;
00039 
00040 void hidgl_flush_triangles (triangle_buffer *buffer);
00041 void hidgl_ensure_triangle_space (triangle_buffer *buffer, int count);
00042 
00043 static inline void
00044 hidgl_add_triangle_3D (triangle_buffer *buffer,
00045                        GLfloat x1, GLfloat y1, GLfloat z1,
00046                        GLfloat x2, GLfloat y2, GLfloat z2,
00047                        GLfloat x3, GLfloat y3, GLfloat z3)
00048 {
00049   buffer->triangle_array [buffer->coord_comp_count++] = x1;
00050   buffer->triangle_array [buffer->coord_comp_count++] = y1;
00051   buffer->triangle_array [buffer->coord_comp_count++] = z1;
00052   buffer->triangle_array [buffer->coord_comp_count++] = x2;
00053   buffer->triangle_array [buffer->coord_comp_count++] = y2;
00054   buffer->triangle_array [buffer->coord_comp_count++] = z2;
00055   buffer->triangle_array [buffer->coord_comp_count++] = x3;
00056   buffer->triangle_array [buffer->coord_comp_count++] = y3;
00057   buffer->triangle_array [buffer->coord_comp_count++] = z3;
00058   buffer->triangle_count++;
00059 }
00060 
00061 static inline void
00062 hidgl_add_triangle (triangle_buffer *buffer,
00063                     GLfloat x1, GLfloat y1,
00064                     GLfloat x2, GLfloat y2,
00065                     GLfloat x3, GLfloat y3)
00066 {
00067   hidgl_add_triangle_3D (buffer, x1, y1, global_depth,
00068                                  x2, y2, global_depth,
00069                                  x3, y3, global_depth);
00070 }
00071 
00072 void hidgl_draw_grid (BoxType *drawn_area);
00073 void hidgl_set_depth (float depth);
00074 void hidgl_draw_line (int cap, Coord width, Coord x1, Coord y1, Coord x2, Coord y2, double scale);
00075 void hidgl_draw_arc (Coord width, Coord vx, Coord vy, Coord vrx, Coord vry, Angle start_angle, Angle delta_angle, double scale);
00076 void hidgl_draw_rect (Coord x1, Coord y1, Coord x2, Coord y2);
00077 void hidgl_fill_circle (Coord vx, Coord vy, Coord vr, double scale);
00078 void hidgl_fill_polygon (int n_coords, Coord *x, Coord *y);
00079 void hidgl_fill_pcb_polygon (PolygonType *poly, const BoxType *clip_box, double scale);
00080 void hidgl_fill_rect (Coord x1, Coord y1, Coord x2, Coord y2);
00081 
00082 void hidgl_init (void);
00083 void hidgl_start_render (void);
00084 void hidgl_finish_render (void);
00085 int hidgl_stencil_bits (void);
00086 int hidgl_assign_clear_stencil_bit (void);
00087 void hidgl_return_stencil_bit (int bit);
00088 void hidgl_reset_stencil_usage (void);
00089 
00090 #endif /* PCB_HID_COMMON_HIDGL_H  */