Files |  Tutorials |  Articles |  Links |  Home |  Team |  Forum |  Wiki |  Impressum

Aktuelle Zeit: Mi Jul 16, 2025 19:14

Foren-Übersicht » Programmierung » Allgemein
Unbeantwortete Themen | Aktive Themen



Ein neues Thema erstellen Auf das Thema antworten  [ 3 Beiträge ] 
Autor Nachricht
BeitragVerfasst: Mi Apr 12, 2006 18:14 
Offline
DGL Member

Registriert: Fr Dez 19, 2003 14:27
Beiträge: 107
Wohnort: Indianapolis, USA
Ich baue mir gerade ein Windows Forms Control dass einem erlaubt Gebaeude zu skizzieren. Da man auch konkave Polygone eingeben koennen soll habe ich die glu Klasse mit den benoetigten Tesselations Funktionen erweitert. Hier der Code falls du es in den Header uebernehmen moechtest:

Code:
  1.     public class glu
  2.     {
  3.         private const string GLUDLLName="GLU32.DLL";
  4.         public const int TESS_BEGIN = 100100;
  5.         public const int TESS_VERTEX = 100101;
  6.         public const int TESS_END = 100102;
  7.         public const int TESS_ERROR = 100103;
  8.         public const int TESS_COMBINE = 100105;
  9.         public const int TESS_WINDING_RULE = 100140;
  10.         public const int TESS_WINDING_ODD = 100130;
  11.         public const int TESS_WINDING_NONZERO = 100131;
  12.         public const int TESS_WINDING_POSITIVE = 100132;
  13.         public const int TESS_WINDING_NEGATIVE = 100133;
  14.         public const int TESS_WINDING_ABS_GEQ_TWO = 100134;
  15.  
  16.         [StructLayout(LayoutKind.Sequential)]
  17.         public struct Tesselator
  18.         {
  19.             /// Keeps the struct from being garbage collected prematurely.
  20.             private IntPtr Data;
  21.         }
  22.  
  23.         public delegate void TessBeginCallback(int type);
  24.         public delegate void TessEndCallback();
  25.         public delegate void TessVertexCallback([MarshalAs(UnmanagedType.LPArray, SizeConst = 3)] double[] vertexData);
  26.         public delegate void TessErrorCallback(int errorCode);
  27.         public delegate void TessCombineCallback([In, MarshalAs(UnmanagedType.LPArray, SizeConst = 3)] double[] coordinates, [In, MarshalAs(UnmanagedType.LPArray, SizeConst = 4)] double[] vertexData, [In, MarshalAs(UnmanagedType.LPArray, SizeConst = 4)] float[] weight, ref double[] outData);
  28.  
  29.         /// local copy of the degates, prevents the GC from collecting them
  30.         private static TessBeginCallback _tessBeginCallback;
  31.         private static TessEndCallback _tessEndCallback;
  32.         private static TessVertexCallback _tessVertexCallback;
  33.         private static TessErrorCallback _tessErrorCallback;
  34.         private static TessCombineCallback _tessCombineCallback;
  35.  
  36.        
  37.         [DllImport(GLUDLLName, EntryPoint = "gluErrorString")]        
  38.         private static extern IntPtr ErrorString_(int errCode);
  39.  
  40.         [DllImport(GLUDLLName, EntryPoint = "gluGetString")]
  41.         private static extern IntPtr GetString_(int errCode);
  42.                      
  43.         [DllImport(GLUDLLName, EntryPoint = "gluOrtho2D")]
  44.         public static extern void Ortho2D(double left, double right, double bottom,double top);
  45.        
  46.         [DllImport(GLUDLLName, EntryPoint = "gluPerspective")]
  47.         public static extern void Perspective(double fovy, double aspect, double zNear,double zFar);
  48.  
  49.         [DllImport(GLUDLLName, EntryPoint = "gluPickMatrix")]
  50.         public static extern void PickMatrix(double x, double y, double width,double height, int[] viewport);
  51.        
  52.         [DllImport(GLUDLLName, EntryPoint = "gluLookAt")]
  53.         public static extern void LookAt(double eyex, double eyey, double eyez,double centerx,double centery,double centerz,double upx, double upy, double upz);
  54.        
  55.         [DllImport(GLUDLLName, EntryPoint = "gluProject")]
  56.         public static extern void Project(double objx, double objy, double objz, double[] modelMatrix, double[] projMatrix, int[] viewport, out double winx, out double winy, out double winz);
  57.  
  58.         [DllImport(GLUDLLName, EntryPoint = "gluUnProject")]
  59.         public static extern void UnProject(double winx, double winy, double winz, double[] modelMatrix, double[] projMatrix, int[] viewport, out double objx, out double objy, out double objz);
  60.  
  61.         [DllImport(GLUDLLName, EntryPoint = "ScaleImage")]
  62.         public static extern void ScaleImage(int format, int widthin, int heightin,int typein, IntPtr datain, int widthout, int heightout, int typeout, IntPtr dataout);
  63.        
  64.         [DllImport(GLUDLLName, EntryPoint = "gluBuild1DMipmaps")]
  65.         public static extern int Build1DMipmaps(int target, int components, int width, int format, int type, IntPtr data);
  66.  
  67.         [DllImport(GLUDLLName, EntryPoint = "gluBuild2DMipmaps")]
  68.         public static extern int Build2DMipmaps(int target, int components, int width, int height, int format, int type, IntPtr data);
  69.  
  70.         [DllImport(GLUDLLName, EntryPoint = "gluNewTess")]
  71.         public static extern Tesselator NewTess();
  72.  
  73.         [DllImport(GLUDLLName, EntryPoint = "gluTessCallback")]
  74.         private static extern void _TessCallback(Tesselator tess, int which, TessBeginCallback func);
  75.  
  76.         public static void TessCallback(Tesselator tess, int which, TessBeginCallback func)
  77.         {
  78.             _tessBeginCallback = func;
  79.             _TessCallback(tess, which, _tessBeginCallback);
  80.         }
  81.  
  82.         [DllImport(GLUDLLName, EntryPoint = "gluTessCallback")]
  83.         private static extern void _TessCallback(Tesselator tess, int which, TessEndCallback func);
  84.  
  85.         public static void TessCallback(Tesselator tess, int which, TessEndCallback func)
  86.         {
  87.             _tessEndCallback = func;
  88.             _TessCallback(tess, which, _tessEndCallback);
  89.         }
  90.  
  91.         [DllImport(GLUDLLName, EntryPoint = "gluTessCallback")]
  92.         private static extern void _TessCallback(Tesselator tess, int which, TessVertexCallback func);
  93.  
  94.         public static void TessCallback(Tesselator tess, int which, TessVertexCallback func)
  95.         {
  96.             _tessVertexCallback = func;
  97.             _TessCallback(tess, which, _tessVertexCallback);
  98.         }
  99.  
  100.         [DllImport(GLUDLLName, EntryPoint = "gluTessCallback")]
  101.         private static extern void _TessCallback(Tesselator tess, int which, TessErrorCallback func);
  102.  
  103.         public static void TessCallback(Tesselator tess, int which, TessErrorCallback func)
  104.         {
  105.             _tessErrorCallback = func;
  106.             _TessCallback(tess, which, _tessErrorCallback);
  107.         }
  108.  
  109.         [DllImport(GLUDLLName, EntryPoint = "gluTessCallback")]
  110.         private static extern void _TessCallback(Tesselator tess, int which, TessCombineCallback func);
  111.  
  112.         public static void TessCallback(Tesselator tess, int which, TessCombineCallback func)
  113.         {
  114.             _tessCombineCallback = func;
  115.             _TessCallback(tess, which, _tessCombineCallback);
  116.         }
  117.  
  118.         [DllImport(GLUDLLName, EntryPoint = "gluTessBeginPolygon")]
  119.         public static extern void TessBeginPolygon(Tesselator tess, double[] data);
  120.  
  121.         [DllImport(GLUDLLName, EntryPoint = "gluTessEndPolygon")]
  122.         public static extern void TessEndPolygon(Tesselator tess);
  123.  
  124.         [DllImport(GLUDLLName, EntryPoint = "gluTessBeginContour")]
  125.         public static extern void TessBeginContour(Tesselator tess);
  126.  
  127.         [DllImport(GLUDLLName, EntryPoint = "gluTessEndContour")]
  128.         public static extern void TessEndContour(Tesselator tess);
  129.  
  130.         [DllImport(GLUDLLName, EntryPoint = "gluTessVertex")]
  131.         public static extern void TessVertex(Tesselator tess, double[] location,  double[] data);
  132.  
  133.         [DllImport(GLUDLLName, EntryPoint = "gluTessProperty")]
  134.         public static extern void TessProperty(Tesselator tess, int which, double data);
  135.  
  136.  
  137.         public static string GetString(int name)
  138.         {
  139.             IntPtr i = GetString_(name);
  140.             return Marshal.PtrToStringAnsi(i);
  141.         }
  142.         public static string ErrorString(int name)
  143.         {
  144.             IntPtr i = ErrorString_(name);
  145.             return Marshal.PtrToStringAnsi(i);
  146.         }
  147.    
  148.     }


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Do Apr 13, 2006 20:47 
Offline
DGL Member
Benutzeravatar

Registriert: Sa Dez 28, 2002 11:13
Beiträge: 2244
Ja gut, dass können wir noch mit reinpacken. Ich wollte aber darauf hinweisen, dass es mittlerweile noch einen vollständigeren OpenGL Header gibt.

http://www.opengl.org/cgi-bin/ubb/ultim ... 3;t=014233
http://wwwstud.uni-leipzig.de/~phi04daw/gl.zip


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Fr Apr 14, 2006 14:37 
Offline
DGL Member

Registriert: Fr Dez 19, 2003 14:27
Beiträge: 107
Wohnort: Indianapolis, USA
OK danke, kannte nur deinen :-)


Nach oben
 Profil  
Mit Zitat antworten  
Beiträge der letzten Zeit anzeigen:  Sortiere nach  
Ein neues Thema erstellen Auf das Thema antworten  [ 3 Beiträge ] 
Foren-Übersicht » Programmierung » Allgemein


Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 7 Gäste


Du darfst keine neuen Themen in diesem Forum erstellen.
Du darfst keine Antworten zu Themen in diesem Forum erstellen.
Du darfst deine Beiträge in diesem Forum nicht ändern.
Du darfst deine Beiträge in diesem Forum nicht löschen.
Du darfst keine Dateianhänge in diesem Forum erstellen.

Suche nach:
Gehe zu:  
cron
  Powered by phpBB® Forum Software © phpBB Group
Deutsche Übersetzung durch phpBB.de
[ Time : 0.007s | 14 Queries | GZIP : On ]