i am trying to build an app using c# to make the GUI and c++ to do the job especially the openGl functions ,however i build the dll and i tried to use a normal function and it works
but when i create another fucntions that summon another function who use glut instruction when i run the code i get this error ,here is the c# code:
<code> public class Program
{
public const string CppFunctions = @"......DebugProject2.dll";
[DllImport(CppFunctions, CallingConvention = CallingConvention.Cdecl)]
public static extern void nS();
#pragma warning restore CS0626 // Method, operator, or accessor is marked external and has no attributes on it
[STAThread]
static void Main()
{
nS();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
</code>
<code> public class Program
{
public const string CppFunctions = @"......DebugProject2.dll";
[DllImport(CppFunctions, CallingConvention = CallingConvention.Cdecl)]
public static extern void nS();
#pragma warning restore CS0626 // Method, operator, or accessor is marked external and has no attributes on it
[STAThread]
static void Main()
{
nS();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
</code>
public class Program
{
public const string CppFunctions = @"......DebugProject2.dll";
[DllImport(CppFunctions, CallingConvention = CallingConvention.Cdecl)]
public static extern void nS();
#pragma warning restore CS0626 // Method, operator, or accessor is marked external and has no attributes on it
[STAThread]
static void Main()
{
nS();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
and the c++ code:
<code>#include <GL/glut.h>
#define func _declspec(dllexport)
void draw() {
glClearColor(1, 1, 1, 0);
glClear(GL_COLOR_BUFFER_BIT);
glFlush();
}
void sheet() {
glutInit(0, NULL);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowPosition(80, 80);
glutInitWindowSize(640, 480);
glutCreateWindow("program");
gluOrtho2D(0, 640, 0, 480);
glutDisplayFunc(draw);
glutMainLoop();
}
extern "C" {
func void nS() {
sheet();
}
}
</code>
<code>#include <GL/glut.h>
#define func _declspec(dllexport)
void draw() {
glClearColor(1, 1, 1, 0);
glClear(GL_COLOR_BUFFER_BIT);
glFlush();
}
void sheet() {
glutInit(0, NULL);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowPosition(80, 80);
glutInitWindowSize(640, 480);
glutCreateWindow("program");
gluOrtho2D(0, 640, 0, 480);
glutDisplayFunc(draw);
glutMainLoop();
}
extern "C" {
func void nS() {
sheet();
}
}
</code>
#include <GL/glut.h>
#define func _declspec(dllexport)
void draw() {
glClearColor(1, 1, 1, 0);
glClear(GL_COLOR_BUFFER_BIT);
glFlush();
}
void sheet() {
glutInit(0, NULL);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowPosition(80, 80);
glutInitWindowSize(640, 480);
glutCreateWindow("program");
gluOrtho2D(0, 640, 0, 480);
glutDisplayFunc(draw);
glutMainLoop();
}
extern "C" {
func void nS() {
sheet();
}
}
when i run it it jumps to glut.h and show an arow on:
<code>static void APIENTRY glutInit_ATEXIT_HACK(int *argcp, char **argv) { __glutInitWithExit(argcp, argv, exit); }
</code>
<code>static void APIENTRY glutInit_ATEXIT_HACK(int *argcp, char **argv) { __glutInitWithExit(argcp, argv, exit); }
</code>
static void APIENTRY glutInit_ATEXIT_HACK(int *argcp, char **argv) { __glutInitWithExit(argcp, argv, exit); }
i know that there is opentk i just fell like i am way stronger in c++ opengl than anything else that the reason why i don’t want to switch to opentk