Porting a GLUT code to a DLL

Started by
2 comments, last by qwertyuiop23 16 years, 11 months ago
Gidday, I am trying to port a simple glut code to a DLL. The program i am using to read the dlls can only use the double type and no other. This causes problems as things need to run as voids and ints to work properly. I ahve ported the enf program part so far which is pretty simple but it works. However when i just run that nothing happens which leads me to velieve that for it to entirely work it needs to be fully ported with all functions in the DLL able to be used. If you need my code here it is: #include <gl/gl.h> // The GL Header File #include <gl/glut.h> // The GL Utility Toolkit (Glut) Header #include <windows.h> // Standard Header For Most Programs #include <stdlib.h> // For malloc() etc. #include <stdio.h> // For printf(), fopen() etc. #include <math.h> // For sin(), cos() etc. #define dll extern "C" __declspec(dllexport) double __cdecl dll end_prog() { exit(0); } void init ( GLvoid ) // Create Some Everyday Functions { glShadeModel(GL_SMOOTH); // Enable Smooth Shading glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background glClearDepth(1.0f); // Depth Buffer Setup glEnable(GL_DEPTH_TEST); // Enables Depth Testing glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do glEnable ( GL_COLOR_MATERIAL ); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); } void triangle () // Create The Display Function { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer glLoadIdentity(); // Reset The Current Modelview Matrix glTranslatef(-1.5f,0.0f,-6.0f); // Move Left 1.5 Units And Into The Screen 6.0 glBegin(GL_TRIANGLES); // Drawing Using Triangles glColor3f(1.0f,0.0f,0.0f); // Set The Color To Red glVertex3f( 0.0f, 1.0f, 0.0f); // Top glColor3f(0.0f,1.0f,0.0f); // Set The Color To Green glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left glColor3f(0.0f,0.0f,1.0f); // Set The Color To Blue glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right glEnd(); // Finished Drawing The Triangle glTranslatef(3.0f,0.0f,0.0f); // Move Right 3 Units glColor3f(0.5f,0.5f,1.0f); // Set The Color To Blue One Time Only glBegin(GL_QUADS); // Draw A Quad glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left glEnd(); // Done Drawing The Quad glutSwapBuffers ( ); // Swap The Buffers To Not Be Left With A Clear Screen } void reshape ( int w, int h ) // Create The Reshape Function (the viewport) { glViewport ( 0, 0, w, h ); glMatrixMode ( GL_PROJECTION ); // Select The Projection Matrix glLoadIdentity ( ); // Reset The Projection Matrix if ( h==0 ) // Calculate The Aspect Ratio Of The Window gluPerspective ( 80, ( float ) w, 1.0, 5000.0 ); else gluPerspective ( 80, ( float ) w / ( float ) h, 1.0, 5000.0 ); glMatrixMode ( GL_MODELVIEW ); // Select The Model View Matrix glLoadIdentity ( ); // Reset The Model View Matrix } int main( int argc, char** argv ) // Create Main Function For Bringing It All Together { glutInit ( &argc, argv ); // Erm Just Write It =) init (); glutInitDisplayMode ( GLUT_RGB | GLUT_DOUBLE ); // Display Mode glutInitWindowSize ( 500, 500 ); // If glutFullScreen wasn't called this is the window size glutCreateWindow ( "NeHe's OpenGL Framework" ); // Window Title (argv[0] for current directory as title) glutFullScreen ( ); // Put Into Full Screen glutDisplayFunc ( triangle ); // Matching Earlier Functions To Their Counterparts glutReshapeFunc ( reshape ); glutMainLoop ( ); // Initialize The Main Loop return EXIT_SUCCESS; } Cheers Qwertyuiop23
Advertisement
Define "Nothing happens". Are you calling hte functions from your exe? Does it link? Are you sure the functions are being called? Does it work when the functions are inside the DLL? Are you linking at runtime or compile time (GetProcAddress, or using a .lib)? How can the program you're using only support doubles? Is it a program you've written? If not, what program is it? If it is, why not change it to support other types?
Thanks for replying:

Define "Nothing happens". Are you calling the functions from your exe?
Nothing happens as in nothing is displayed when it is called. I am not calling any functions apart from the end_prog one.

Does it link?
Ok i am not too sure about what you mean here. If you are meaning linking things like glut32 libraries then yes it does. I use DEV C++ which is also a debugger so that code is bug free and links properly.

Are you sure the functions are being called?
NO only the end_prog one is being called. I can't call others as the are not doubles.

Does it work when the functions are inside the DLL?
What do you mean by this?

Are you linking at runtime or compile time (GetProcAddress, or using a .lib)?
Again i can't be sure what you mean by linking. But i use a lib when i compile the code into a DLL.

How can the program you're using only support doubles?
I don't know but the program creator (not me) made an example saying that is can only use doubles.

Is it a program you've written?
No

If not, what program is it?
Game Maker 7.0, Written by Mark Overmars. Written in Delphi. It is like an easy to use compiler with all pre-built in functions. IT is really good to use because it has not actually programming code in it.

Tell me if you need more info.

Cheers
Qwertyuiop23
Cmon anyone can help me here?

This topic is closed to new replies.

Advertisement