Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 静态链接GLU?_C++_C_Opengl_Static Linking_Glu - Fatal编程技术网

C++ 静态链接GLU?

C++ 静态链接GLU?,c++,c,opengl,static-linking,glu,C++,C,Opengl,Static Linking,Glu,我正在使用臀大肌对多边形进行镶嵌。经过几次测试,我意识到glu32.lib链接到glu32.dll,每隔一段时间就会崩溃一次。而我从OpenGLSDK中得到的GLU则像岩石一样坚固。不幸的是,由于没有链接到windows dll,这意味着我需要用我的应用程序在GLU.dll上拖动,而不是依赖windows的GLU32.dll。是否有可静态链接的GLU版本?我真的不希望他的小项目有任何dll依赖项 谢谢 我的tesselator代码: #include "StdAfx.h" #include "C

我正在使用臀大肌对多边形进行镶嵌。经过几次测试,我意识到glu32.lib链接到glu32.dll,每隔一段时间就会崩溃一次。而我从OpenGLSDK中得到的GLU则像岩石一样坚固。不幸的是,由于没有链接到windows dll,这意味着我需要用我的应用程序在GLU.dll上拖动,而不是依赖windows的GLU32.dll。是否有可静态链接的GLU版本?我真的不希望他的小项目有任何dll依赖项

谢谢

我的tesselator代码:

#include "StdAfx.h"
#include "CGlTesselator.h"
std::vector<GLdouble*> gluptrvec;
std::vector<GLfloat> tempvct;
std::vector<GLfloat> tempvcttex;
POINTFLOAT CurrentDimensions;
POINTFLOAT CurrentMinima;

void CALLBACK combineCallback(GLdouble coords[3], GLdouble *vertex_data[4],
                              GLdouble weight[4], GLdouble **dataOut)
{
    GLdouble *vertex;

    vertex = (GLdouble *) malloc(6 * sizeof(GLdouble));
    if(vertex == NULL)
    {

        MessageBox(0,0,0,0);
    }
    vertex[0] = coords[0];
    vertex[1] = coords[1];
    //vertex[2] = coords[2];




    *dataOut = vertex;
    gluptrvec.push_back(vertex);

}


void CALLBACK vertexCallback(GLvoid *vertex)
{

    GLdouble *ptr;

    ptr = (GLdouble *) vertex;

    if(ptr == NULL)
    {
        MessageBox(0,0,0,0);
    }
    double x = ptr[0];
    double y = ptr[1];

    double s = (x - CurrentMinima.x) / CurrentDimensions.x;
    double t = (y - CurrentMinima.y) / CurrentDimensions.y;
    tempvct.push_back((GLfloat)x);
    tempvct.push_back((GLfloat)y);
    tempvcttex.push_back((GLfloat)s);
    tempvcttex.push_back((GLfloat)t);
    //glTexCoord2d(s,t);

    //glVertex2dv((GLdouble *) ptr);



}

void CALLBACK edgeflags(int flag)
{

}

CGlTesselator::CGlTesselator(void)
{
    Init();
}
int CGlTesselator::Init(GLvoid)
{
    // Create a new tessellation object 
    tobj = gluNewTess(); 

    // Set callback functions
    gluTessCallback(tobj, GLU_TESS_VERTEX, (GLvoid (_stdcall *)(void) ) &vertexCallback);
    gluTessCallback(tobj, GLU_TESS_BEGIN,  (GLvoid (_stdcall *)(void) ) &glBegin);
    gluTessCallback(tobj, GLU_TESS_END,  (GLvoid (_stdcall *)(void) ) &glEnd);
    gluTessCallback(tobj, GLU_TESS_COMBINE,  (GLvoid (_stdcall *)(void) )&combineCallback);
    gluTessCallback(tobj, GLU_EDGE_FLAG,  (GLvoid (_stdcall *)(void) )&edgeflags);

    return(1);
}

int CGlTesselator::Set_Winding_Rule(GLenum winding_rule)
{
    // Set the winding rule
    gluTessProperty(tobj, GLU_TESS_WINDING_RULE, winding_rule); 

    return(1);
}


int CGlTesselator::Render_Contour(GLdouble obj_data[][6], int num_vertices)

{

    for (int x = 0; x < num_vertices; ++x) //loop through the vertices
    {

        gluTessVertex(tobj, obj_data[x], obj_data[x]); //store the vertex


    }


    return(1);
}


int CGlTesselator::Begin_Polygon(GLvoid)
{
    gluTessBeginPolygon(tobj, NULL);

    return(1);
}

int CGlTesselator::End_Polygon(GLvoid)
{
    try
    {
        gluTessEndPolygon(tobj);
    }
    catch (int ix)
    {

    }



    if(gluptrvec.size() > 0)
    {
        for(unsigned int i = 0; i < gluptrvec.size(); i++)
        {

            free(gluptrvec[i]);
        }
    }
        gluptrvec.clear();

    return(1);
}


int CGlTesselator::Begin_Contour(GLvoid)
{
    gluTessBeginContour(tobj);

    return(1);
}


int CGlTesselator::End_Contour(GLvoid)
{   
    try
    {
        if(tobj == NULL)
        {
            MessageBox(0,0,0,0);
        }
        gluTessEndContour(tobj);
    }
    catch (...)
    {

    }


    return(1);
}


int CGlTesselator::End(GLvoid)
{
    gluDeleteTess(tobj);

    return(1);
}

void CGlTesselator::SetDimensions(POINTFLOAT dims, POINTFLOAT min)
{
    CurrentDimensions = dims;
    CurrentMinima = min;
}

CGlTesselator::~CGlTesselator(void)
{
    End();
}

void CGlTesselator::TransferVerticies(GLuint &polyvbo, GLuint &texvbo,UINT &vbocount, UINT &texcount)
{

    if (tempvct.size() > 0)
    {
        glBindBufferARB(GL_ARRAY_BUFFER_ARB,polyvbo);
        glBufferDataARB(GL_ARRAY_BUFFER_ARB,sizeof(GLfloat) * tempvct.size(),&tempvct[0],GL_STATIC_COPY);

        glBindBufferARB(GL_ARRAY_BUFFER_ARB,texvbo);

        glBufferDataARB(GL_ARRAY_BUFFER_ARB,sizeof(GLfloat) * 
            tempvcttex.size(),&tempvcttex[0],GL_STATIC_COPY);
    }


    vbocount = tempvct.size();
    texcount = tempvcttex.size();

    tempvct.clear();
    tempvcttex.clear();

}

这里有什么问题吗?< /P> < P>我建议您只使用C++的东西,不要在C MalOC/FLUX中混合。


SGI将其tesselator赠送给了Mesa3D.org,因此只需从mesa下载glu,编译并链接即可。但是您必须将项目设置从DLL更改为LIB。

Windows glu32.DLL是所有Windows OpenGL应用程序的标准依赖项。如果它崩溃,最有可能的问题是您的代码。如果其他版本没有崩溃,并不意味着你的代码是正确的。是否有可静态链接的GLU版本?检查glu或mesa3d的linux版本。如果它是LGPL-它将是静态链接的。不过,这将是一个坏主意,您应该真正使用系统提供的组件。此外,我建议您至少自己做一些事情,而不是在每次出现问题时向其他人寻求帮助。做一点研究,谷歌一点,阅读如何以聪明的方式提问等等。哇,5k经验和所有问题。。。我认为@SigTerm在这里可能有道理。?很抱歉,我真的看不出这个问题和你的答案之间的联系?我猜他遇到问题的原因是他引用了stl容器中的malloced内存块“vertex”。当一个向量可以完成这项工作时,没有真正的理由在这里使用malloc/free