Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: can we use opengl to create *.dll and *.lib file?

  1. #1
    Intern Newbie
    Join Date
    Nov 2001
    Location
    malaysia
    Posts
    36

    can we use opengl to create *.dll and *.lib file?

    i have create a program to split window to two view using glut.. now i want to make the program as a library(.dll and .lib)... can i do that? this is my code::

    ////////////////////////////////////////////
    #include <gl\glut.h>
    #include <gl\gl.h>
    #include <gl\glu.h>
    #include <math.h>
    #include <stdlib.h>
    #include "split.h"


    void changeSize(int w1, int h1)
    {

    // elakkan devide by zero
    ratio = 1.0f * w1 / h1;

    // Reset koordinat gl_projection sebelum diubahsuai
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();

    // Set viewport kpd keseluruhan window
    glViewport(0, 0, w1, h1); //(0,0)=specifies lower-left coner of the viewport

    // Set the clipping volume
    gluPerspective(45,ratio,0.1,1000);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();


    }

    void SeparateWindow(int w1,int h1)
    {
    if(h1 == 0)
    h1 = 1;

    w = w1;
    h = h1;

    //Separate Window Sebelah Kiri
    glutSetWindow(subWindowKiri);
    glutPositionWindow(border,border);
    glutReshapeWindow(w/2-border*3/2,h-2*border);//w-2*border, h/2 - border*3/2);-devide atas bawah
    changeSize(w/2-border*3/2,h-2*border);//w-2*border, h/2 - border*3/2);-devide atas bawah

    //Separate Window Sebelah Kanan
    glutSetWindow(subWindowKanan);
    glutPositionWindow((w+border)/2,border);
    glutReshapeWindow(w/2-border*3/2,h-2*border);//w-2*border, h/2 - border*3/2);
    changeSize(w/2-border*3/2,h-2*border);//w-2*border,h/2 - border*3/2);

    }


    void DrawTriangle(int x)
    {

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glPushMatrix();

    //glRotatef(angle,0.0,1.0,0.0);
    glColor3f(0.0,0.0,1.0);
    //glScalef(10.0,0.0,0.0);
    //glTranslatef(0.0f, 0.0f, -2.0f);
    //draw triangle
    glBegin(GL_TRIANGLES);
    glVertex3f(-2.0,1.0,0.0);
    glVertex3f(3.0,1.0,0.0);
    glVertex3f(0.0,3.0,0.0);
    glEnd();


    glPopMatrix();
    angle++;

    glutSwapBuffers();
    }

    void renderScene()
    {
    glutSetWindow(mainWindow);
    glClear(GL_COLOR_BUFFER_BIT);
    glutSwapBuffers();
    }

    void renderSceneKiri()
    {
    glutSetWindow(subWindowKiri);
    glLoadIdentity();
    gluLookAt(x, y, z,
    0.11285,y+ly,0.222,//x + lx,y + ly,z + lz,
    0.0f,1.0f,0.0f);


    DrawTriangle(subWindowKiri);
    }

    void renderSceneKanan()
    {
    glutSetWindow(subWindowKanan);
    glLoadIdentity();

    gluLookAt(x, y, z, //lokasi kamera - nilai (0,0,0)= asalan
    -0.11285,y+ly,0.222,//x + lx,y + ly,z + lz, //dimana camera halakan/point = line of sight
    0.0f,1.0f,0.0f); //vektor yg menerangkan arah atas
    DrawTriangle(subWindowKanan);
    }

    void renderSceneAll()
    {

    renderSceneKiri();
    renderSceneKanan();
    }

    int main(int argc, char **argv)
    {
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
    glutInitWindowPosition(100,100);
    glutInitWindowSize(w,h);
    mainWindow = glutCreateWindow("Two View");
    glutReshapeFunc(SeparateWindow);
    glutDisplayFunc(renderScene);
    glutIdleFunc(renderSceneAll);

    //Separate Window Sebelah Kiri
    //identifier |window |window |width in |height
    //sub window |x location |y location |pixel |in pixel
    subWindowKiri = glutCreateSubWindow(mainWindow, border ,border ,w/2-border*3/2,h-2*border);//w-2*border, h/2 - border*3/2);
    glutDisplayFunc(renderSceneKiri);

    //Separate Window Sebelah Kanan
    subWindowKanan = glutCreateSubWindow(mainWindow, (w+border)/2,border,w/2-border*3/2,h-2*border);//w-2*border, h/2 - border*3/2);
    glutDisplayFunc(renderSceneKanan);
    glutMainLoop();

    return(0);
    }
    ////////////////////////////////////////////
    apit

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Aug 2000
    Location
    Cardiff University
    Posts
    668

    Re: can we use opengl to create *.dll and *.lib file?

    whats your api?

  3. #3
    Intern Newbie
    Join Date
    Nov 2001
    Location
    malaysia
    Posts
    36

    Re: can we use opengl to create *.dll and *.lib file?

    sorry...i don't really understand your question... what do you mean by api? i'm using glut as a library.. mvcpp as editor..
    apit

  4. #4
    Junior Member Regular Contributor
    Join Date
    Sep 2002
    Location
    Nanjing,China
    Posts
    118

    Re: can we use opengl to create *.dll and *.lib file?

    First i am not sure you can use glut to generate lib/dll,more likely you can't.
    you have to select "Win32 Dynamic-Link Library" when you create a new project in vc6.
    then in your program
    the dll entry point is dllMain unlike common entry point which is winmain.

    And your global function will be callbacked.so you should export functions
    like this EXPORT VOID CALLBACK yourfunction()

    <Windows Programming> has one chapter deal with how to make a dll/lib. look it up yourselves when necessary.


    [This message has been edited by RunningRabbit (edited 08-12-2003).]

  5. #5
    Intern Newbie
    Join Date
    Nov 2001
    Location
    malaysia
    Posts
    36

    Re: can we use opengl to create *.dll and *.lib file?

    so that mean i cannot use glut to generate *.dll and *.lib file? do you have any idea to separate two view and make it as a library?
    apit

  6. #6
    Junior Member Regular Contributor
    Join Date
    Sep 2002
    Location
    Nanjing,China
    Posts
    118

    Re: can we use opengl to create *.dll and *.lib file?

    yes,you got my point. But i can not understand why you have to put the split window into another libary. this is not way of doing.Usually we use child window or glScssior to split window. and these split window codes is un-seperated part of the whole GL application.Maybe i am arbitary a bit,correct me if i am wrong.

  7. #7
    Senior Member OpenGL Pro
    Join Date
    Oct 2000
    Location
    Fargo, ND
    Posts
    1,797

    Re: can we use opengl to create *.dll and *.lib file?

    Yes, you can put stuff into a library. Glut won't generate a library for you, though. You have to generate the library with your compiler. How you do this, and what you put in the library is up to you. It all depends on what exactly you want, which is pretty vague in your post.
    Deiussum
    Software Engineer and OpenGL enthusiast

  8. #8
    Intern Newbie
    Join Date
    Nov 2001
    Location
    malaysia
    Posts
    36

    Re: can we use opengl to create *.dll and *.lib file?

    i got your point guys..
    thanks a lot..
    so i don't have to split the two view coding with the main code... just combain it together..

    question 2
    --------------
    maybe this not related with this topic but it is very nice if you all can help me..
    how can i make my program in stereoview..
    i have split the screen and the program running well both ringht anf left view.. the problem now is to make it look stereoviewing.. how can i do that..
    can i just modify the gluLookat value to make it stereoview.. or i should calculate the stereo ?
    apit

  9. #9
    Senior Member OpenGL Pro
    Join Date
    Feb 2002
    Location
    Bonn, Germany
    Posts
    1,652

    Re: can we use opengl to create *.dll and *.lib file?

    Your eyes should be a couple of inches or so apart from each other (I assume).
    If you know what 'a couple of inches' is in your world coords, you can seperate the viewpoints of your stereo views by this amount. Or better yet, make it configurable and play around with it until it starts looking convincing

  10. #10
    Junior Member Newbie
    Join Date
    Aug 2005
    Posts
    2

    Re: can we use opengl to create *.dll and *.lib file?

    Originally posted by apit:
    [B]i have create a program to split window to two view using glut.. now i want to make the program as a library(.dll and .lib)... can i do that? this is my code::
    Yes you can. But it has nothing to do with OpenGL or GLUT. Read docs for your OS/Compiler(Visual C++ I assume) on how to create DLL/LIB's

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •