gpt4 book ai didi

c++ - 在 FLTK 中使用 GLUT

转载 作者:行者123 更新时间:2023-11-28 02:36:48 25 4
gpt4 key购买 nike

<分区>

我的应用程序由常规的 FLTK 小部件(按钮等)和一个 OpenGL 窗口组成。我的意图是使用 GLUT 在这个 OpenGL 窗口中绘制。按照说明 here :

You should be able to compile existing GLUT source code by including instead of . This can be done by editing the source, by changing the -I switches to the compiler, or by providing a symbolic link from GL/glut.h to FL/glut.H.

我也做了同样的事情,但出现以下链接错误:

1>Main.obj : error LNK2001: unresolved external symbol __imp__glClear@4
1>fltkgl.lib(Fl_Gl_Window.obj) : error LNK2001: unresolved external symbol __imp__glClear@4
1>Main.obj : error LNK2001: unresolved external symbol __imp__glClearColor@16
1>Main.obj : error LNK2001: unresolved external symbol __imp__glFlush@0
1>fltkgl.lib(Fl_Gl_Window.obj) : error LNK2001: unresolved external symbol __imp__glFlush@0
1>Main.obj : error LNK2001: unresolved external symbol __imp__glLoadIdentity@0
1>fltkgl.lib(Fl_Gl_Window.obj) : error LNK2001: unresolved external symbol __imp__glLoadIdentity@0
1>fltkgl.lib(Fl_Gl_Window.obj) : error LNK2001: unresolved external symbol __imp__glReadBuffer@4
1>fltkgl.lib(Fl_Gl_Window.obj) : error LNK2001: unresolved external symbol __imp__glDrawBuffer@4
1>fltkgl.lib(Fl_Gl_Window.obj) : error LNK2001: unresolved external symbol __imp__glOrtho@48
1>fltkgl.lib(Fl_Gl_Window.obj) : error LNK2001: unresolved external symbol __imp__glViewport@16
1>fltkgl.lib(Fl_Gl_Window.obj) : error LNK2001: unresolved external symbol __imp__glGetIntegerv@8
1>fltkgl.lib(Fl_Gl_Window.obj) : error LNK2001: unresolved external symbol __imp__wglSwapLayerBuffers@8
1>fltkgl.lib(Fl_Gl_Window.obj) : error LNK2001: unresolved external symbol __imp__glCopyPixels@20
1>fltkgl.lib(Fl_Gl_Window.obj) : error LNK2001: unresolved external symbol __imp__glRasterPos2i@8
1>fltkgl.lib(gl_draw.obj) : error LNK2001: unresolved external symbol __imp__glRasterPos2i@8
1>fltkgl.lib(Fl_Gl_Window.obj) : error LNK2001: unresolved external symbol __imp__glDisable@4
1>fltkgl.lib(Fl_Gl_Window.obj) : error LNK2001: unresolved external symbol __imp__wglRealizeLayerPalette@12
1>fltkgl.lib(Fl_Gl_Choice.obj) : error LNK2001: unresolved external symbol __imp__wglShareLists@8
1>fltkgl.lib(Fl_Gl_Choice.obj) : error LNK2001: unresolved external symbol __imp__wglCreateContext@4
1>fltkgl.lib(Fl_Gl_Choice.obj) : error LNK2001: unresolved external symbol __imp__wglCreateLayerContext@8
1>fltkgl.lib(Fl_Gl_Choice.obj) : error LNK2001: unresolved external symbol __imp__wglMakeCurrent@8
1>fltkgl.lib(Fl_Gl_Choice.obj) : error LNK2001: unresolved external symbol __imp__wglDeleteContext@4
1>fltkgl.lib(Fl_Gl_Device_Plugin.obj) : error LNK2001: unresolved external symbol __imp__glPopClientAttrib@0
1>fltkgl.lib(Fl_Gl_Device_Plugin.obj) : error LNK2001: unresolved external symbol __imp__glReadPixels@28
1>fltkgl.lib(Fl_Gl_Device_Plugin.obj) : error LNK2001: unresolved external symbol __imp__glPixelStorei@8
1>fltkgl.lib(gl_draw.obj) : error LNK2001: unresolved external symbol __imp__glPixelStorei@8
1>fltkgl.lib(Fl_Gl_Device_Plugin.obj) : error LNK2001: unresolved external symbol __imp__glPushClientAttrib@4
1>fltkgl.lib(gl_draw.obj) : error LNK2001: unresolved external symbol __imp__glListBase@4
1>fltkgl.lib(gl_draw.obj) : error LNK2001: unresolved external symbol __imp__glGenLists@4
1>fltkgl.lib(gl_draw.obj) : error LNK2001: unresolved external symbol __imp__glDeleteLists@8
1>fltkgl.lib(gl_draw.obj) : error LNK2001: unresolved external symbol __imp__glCallLists@12
1>fltkgl.lib(gl_draw.obj) : error LNK2001: unresolved external symbol __imp__wglUseFontBitmapsW@16
1>fltkgl.lib(gl_draw.obj) : error LNK2001: unresolved external symbol __imp__glRasterPos2f@8
1>fltkgl.lib(gl_draw.obj) : error LNK2001: unresolved external symbol __imp__glEnd@0
1>fltkgl.lib(gl_draw.obj) : error LNK2001: unresolved external symbol __imp__glVertex2i@8
1>fltkgl.lib(gl_draw.obj) : error LNK2001: unresolved external symbol __imp__glBegin@4
1>fltkgl.lib(gl_draw.obj) : error LNK2001: unresolved external symbol __imp__glColor3ub@12
1>fltkgl.lib(gl_draw.obj) : error LNK2001: unresolved external symbol __imp__glIndexi@4
1>fltkgl.lib(gl_draw.obj) : error LNK2001: unresolved external symbol __imp__glDrawPixels@20
1>D:\Skunkworks\Snake3D\Snake3D\Release\Snake3D.exe : fatal error LNK1120: 35 unresolved externals

当我使用 FreeGLUT 时,程序编译正确。在更改 header 以使用 FLTK 的 GLUT 版本后,我遇到了这些问题。我正在使用 Microsoft Visual Studio 10 并添加了以下静态库作为“附加依赖项”:

freeglut.lib glew32.lib fltk.lib fltkgl.lib

我做错了什么?另外,如何使用 GLUT 在我的 Fl_Gl_Window 中绘制?

这是我的程序:

// Make the GUI here
#define WIN32
#include <GL/glew.h>
#include <FL/glut.H>
#include <FL/glu.h>
#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Color_Chooser.H>
#include <FL/Fl_Gl_Window.H>
#include <FL/Fl_Menu_Bar.H>
#include <FL/fl_draw.H>
#include <FL/Fl_Button.H>

class Block
{
public:
Block(int x, int y, int z)
{
xyz[0] = x;
xyz[1] = y;
xyz[2] = z;
}

int getX(){ return xyz[0];}
int getY(){ return xyz[1];}
int getZ(){ return xyz[2];}

void setX(int x){ xyz[0]=x;}
void setY(int y){ xyz[1]=y;}
void setZ(int z){ xyz[2]=z;}

private:
int xyz[3];
};

// Snake is an array blocks.
Block* snake;
// Mouse is a single block
Block* mouse;

class GlWindow : public Fl_Gl_Window
{
public:
// Call back for draw
void draw()
{
// Get the current state of the universe and draw it
glClearColor(1.0f, 1.0f, 1.0f, 1.0f); // Clear the background of our window to red
glClear(GL_COLOR_BUFFER_BIT); //Clear the colour buffer (more buffers later on)
glLoadIdentity(); // Load the Identity Matrix to reset our drawing locations

//glutSolidCube(5);
glFlush(); // Flush the OpenGL buffers to the window
}

// To handle key-events
void handle()
{
}

// Constructor
GlWindow(int X, int Y, int W, int H, const char* L=0): Fl_Gl_Window(X,Y,W,H,L)
{
}

};

void buildGUI(int argc, char** argv)
{
// Main Window
Fl_Double_Window *window = new Fl_Double_Window(800,500);
window->label("Snake3D");
window->color(FL_LIGHT3);
window->begin();

// Menu Bar
Fl_Menu_Bar* menubar = new Fl_Menu_Bar(0,0,800,30);
menubar->color(FL_LIGHT3);
menubar->down_color(fl_rgb_color(0,145,255));
menubar->box(FL_THIN_UP_BOX);
menubar->add("File/Exit");
menubar->add("Help/About");

// OpenGL Window
GlWindow* gameWindow = new GlWindow(200,30,600,470);

// Start Button
Fl_Button* startButton = new Fl_Button(50,200,100,30,"Start");
Fl_Button* pauseButton = new Fl_Button(50,300,100,30,"Pause");
window->show();
window->end();
Fl::run();
}

int main(int argc, char ** argv)
{
// Build GUI
buildGUI(argc,argv);
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com