Author Topic: Dll Allergy  (Read 3522 times)

0 Members and 1 Guest are viewing this topic.

Peter

  • Guest
Dll Allergy
« on: April 01, 2013, 03:59:30 AM »
Deleted.
« Last Edit: May 05, 2015, 11:38:34 AM by Peter »

Charles Pegge

  • Guest
Re: Dll Allergy
« Reply #1 on: April 01, 2013, 01:51:01 PM »
Hi Peter,

The DLL appears to be well formed. Could you try recompiling with my latest Oxygen. Make sure the new RTLs go into the inc folder. I produce many DLLs daily, but I have not encountered this problem before.

Charles Pegge

  • Guest
Re: Dll Allergy
« Reply #2 on: April 02, 2013, 05:25:23 AM »
No Peter, I have most of them for dinner :)

I have created DLLs with opengl, so I don't think there is a problem there.

Something has corrupted somewhere. You could deconstruct your library to see if the problem can be isolated.

This 2 line program will tell you whether your DLL is good or not.

a= loadlibrary "gl.dll"
print a '0==not working




JRS

  • Guest
Re: Dll Allergy
« Reply #3 on: April 02, 2013, 08:59:49 AM »
Peter,

I'm sure you are having fun getting OpenGL working under Windows. I spent a couple hours getting the IUP OpenGL example to compile and run under Ubuntu. Once I got it working there, I tried to do the same under Windows with MinGW gcc and never could find the right combination of libraries to get it to work so I gave up.

Code: [Select]
#define _CRT_SECURE_NO_WARNINGS
/**
 *     @file IUP3DGL.c Simple exemple of use of 3D OpenGL and IUP.
 *
 *  Creates a dialog with one canvas and draws a rotating cube in it.
 *  
 *  Autheor:  Marcelo Gattass, Nov09,2009.
 *
 */
/*- Include lib interfaces: ANSI C, IUP and OpenGL ------*/
#include <stdio.h>
#include <stdlib.h>
#include <iup.h>        /* IUP functions*/
#include <iupgl.h>      /* IUP functions related to OpenGL (IupGLCanvasOpen,IupGLMakeCurrent and IupGLSwapBuffers) */

#ifdef WIN32
#include <windows.h>    /* includes only in MSWindows not in UNIX */
#endif

#include <GL/gl.h>     /* OpenGL functions */
#include <GL/glu.h>    /* OpenGL utilitarian functions */
#include "glut.h"

/*- Program context: -------------------------------------------------*/
Ihandle *canvas;                    /* canvas handle */
int width=640,height=480;           /* width and height of the canvas  */
float t=0;                          /* animation time */

/*------------------------------------------*/
/* Auxiliary functions to draw a color cube */
/*------------------------------------------*/

static void polygon(int a, int b, int c, int d)
{
double vertices[][3]={{-1,-1, 1}, {-1, 1, 1}, { 1, 1, 1}, { 1,-1, 1},
                      {-1,-1,-1}, {-1, 1,-1}, { 1, 1,-1}, { 1,-1,-1}};
   glBegin(GL_POLYGON);
      glVertex3dv(vertices[a]);
      glVertex3dv(vertices[b]);
      glVertex3dv(vertices[c]);
      glVertex3dv(vertices[d]);
   glEnd();
}

static void colorCube( void)  
{
   glColor3f(1,0,0);
   glNormal3f(1,0,0);
   polygon(2,3,7,6);

   glColor3f(0,1,0);
   glNormal3f(0,1,0);
   polygon(1,2,6,5);

   glColor3f(0,0,1);
   glNormal3f(0,0,1);
   polygon(0,3,2,1);


   glColor3f(1,0,1);
   glNormal3f(0,-1,0);
   polygon(3,0,4,7);


   glColor3f(1,1,0);
   glNormal3f(0,0,-1);
   polygon(4,5,6,7);

   glColor3f(0,1,1);
   glNormal3f(-1,0,0);
   polygon(5,4,0,1);
}


/* function called when the canvas is exposed in the screen */
int repaint_cb(Ihandle *self)
{
  IupGLMakeCurrent(self);
  glClearColor(0.3f, 0.3f, 0.3f, 1.0f);  /* White */
  glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
  glEnable(GL_DEPTH_TEST);

  glMatrixMode(GL_MODELVIEW);
  glPushMatrix();  /* saves current model view in a stack */
glTranslatef( 0.0f, 0.0f , 0.0f );
glScalef( 1.0f, 1.0f, 1.0f );
glRotatef(t,0,0,1);
colorCube();

   glPopMatrix();
 
  IupGLSwapBuffers(self);  /* change the back buffer with the front buffer */

  return IUP_DEFAULT; /* returns the control to the main loop */
}




/* function called in the event of changes in the width or in the height of the canvas */
int resize_cb(Ihandle *self, int new_width, int new_height)
{
 IupGLMakeCurrent(self);  /* Make the canvas current in OpenGL */

 /* define the entire canvas as the viewport  */
 glViewport(0,0,new_width,new_height);

 /* transformation applied to each vertex */
 glMatrixMode(GL_MODELVIEW);
 glLoadIdentity();           /* identity, i. e. no transformation */

 /* projection transformation (orthographic in the xy plane) */
 glMatrixMode(GL_PROJECTION);
 glLoadIdentity();
 gluPerspective(60,4./3.,1.,15);
 gluLookAt(3,3,3, 0,0,0, 0,0,1);

 /* update canvas size and repaint */
 width=new_width;
 height=new_height;
 repaint_cb(canvas);

 return IUP_DEFAULT; /* return to the IUP main loop */
}


int idle_cd(void)
{
t+=1;
repaint_cb(canvas);
    return IUP_DEFAULT; /* return to the IUP main loop */
}



int exit_cb(void)
{
     printf("Function to free memory and do finalizations...\n");

     return IUP_CLOSE;
}


/*-------------------------------------------------------------------------*/
/* Incializa o programa.                                                   */
/*-------------------------------------------------------------------------*/



Ihandle* initDialog(void)
{
  Ihandle* dialog;   /* dialog containing the canvas */

  canvas = IupGLCanvas("repaint_cb"); /* create _canvas and define its repaint callback */
  IupSetFunction("repaint_cb", (Icallback) repaint_cb);  

  IupSetAttribute(canvas,IUP_RASTERSIZE,"640x480");   /* define the size in pixels */
  IupSetAttribute(canvas,IUP_BUFFER,IUP_DOUBLE);      /* define that this OpenGL _canvas has double buffer (front and back) */


   /* bind callback actions with callback functions */
   IupSetCallback(canvas, "RESIZE_CB",(Icallback) resize_cb);

  /* create the dialog and set its attributes */
  dialog = IupDialog(canvas);
  IupSetAttribute(dialog, "TITLE", "IUP_3D_OpenGL");

  IupSetCallback(dialog, "CLOSE_CB", (Icallback) exit_cb);
  IupSetFunction (IUP_IDLE_ACTION, (Icallback) idle_cd);

  return dialog;
}

/*-----------------------*/
/* Main function.        */
/*-----------------------*/
int main(int argc, char* argv[])
{
     Ihandle* dialog;

IupOpen(&argc, &argv);                       /* opens the IUP lib */
   
IupGLCanvasOpen();                          /* enable the use of OpenGL to draw in canvas */

dialog = initDialog();                      /* local function to create a dialog with buttons and canvas */
IupShowXY(dialog, IUP_CENTER, IUP_CENTER);  /* shows dialog in the center of screen */

IupMainLoop();                              /* handle the program control to the IUP lib until a return IUP_CLOSE */

 IupClose();                               /* closes the IUP lib */
}

gcc iupcube.c -I/usr/include/iup -I/usr/include/GL -liupgl -liup -lGLU -lGL -o iupcube



X

Charles Pegge

  • Guest
Re: Dll Allergy
« Reply #4 on: April 02, 2013, 10:23:06 AM »
Peter, if you want me to crack this for you, without disclosing source, you can send it to cevpegge at oxygenbasic org. I will keep it confidential.

JRS

  • Guest
Re: Dll Allergy
« Reply #5 on: April 02, 2013, 10:24:51 AM »
Quote
The author has lost the oversight, and is only thinking about his dll supper.

I think you would be hard pressed finding ANYONE more helpful and generous than Charles.

Please try to be more supportive and work out the first problem you report before moving on to something else.


Charles Pegge

  • Guest
Re: Dll Allergy
« Reply #6 on: April 02, 2013, 11:35:53 AM »
It may be a clash of names, many symbols can be redefined in Oxygen, though I try to protect the essential ones.

JRS

  • Guest
Re: Dll Allergy
« Reply #7 on: April 02, 2013, 11:39:44 AM »


Quote
Say what you wish, it works for me!

Frankolinox

  • Guest
Re: Dll Allergy
« Reply #8 on: April 03, 2013, 02:37:24 AM »
hello peter, I've tested your "gl.DLL" with powerbasic, it doesn't work (result: "0").
the "bass.dll" however works fine.

I suppose it's a dll problem. perhaps you can find another source for that dll from website or other compiler/interpreter software programming language.

two years ago I have had a similiar problem with "freeimage.dll". One DLL was working another one doesn't run, although I can read (pe extract) all functions correctly. I think it's a simple DLL error and not problem of Oxygenbasic ;) I am sure it's not an oxygen loading library problem.

Code: [Select]
'DECLARE FUNCTION LoadLibraryA LIB "KERNEL32.DLL" ALIAS "LoadLibraryA" ( _
'   BYREF lpLibFileName AS ASCIIZ _                      ' __in LPCSTR lpLibFileName
' ) AS SYS

#include "gl.inc"

sys hlib, hlib2
'
'one: gl.dll
'
'hLib  = LoadLibraryA("gl.dll") 'powerbasic
hLib  = LoadLibrary("gl.dll")

'
'two: gl.dll
'
'hLib2 = LoadLibraryA("bass.dll") 'powerbasic
hLib2 = LoadLibrary("bass.dll")


print "mytest glDLL: "  & str(hLib)
'result for glDLL: 0 'not correct
'print hLib '0==not working

print "mytest bassDLL: " & str(hLib2)
'result for bassDLL: 3735552 (correct) !

best regards, frank

X

Charles Pegge

  • Guest
Re: Dll Allergy
« Reply #9 on: April 03, 2013, 04:29:28 AM »
My theory is that Peter has redefined an Oxygen symbol, and tried to use it elsewhere in the program.

There is a switch available to prevent existing symbols from being redefined, so you can detect when and where this occurs.

#unique

sys float 'error!