Installing freeglut and OpenGL

This is a simple tutorial to show a new linux user (such as myself) how to setup freeglut and OpenGl.

System used IBM T22 ThinkPad:
mobile pentium 3 900mhz
256mb ram
20GB hd
S3 Inc. 86C270-294 Savage/IX-MV (rev 13) video card

OS: xubuntu 6.10

I have just recently become a linux user and wanted to install freeglut to do my graphics assignments on my laptop. Although the install did not turn out to be very difficult it took me a while to do. So I have written this tutorial in case another young linux user comes along and decides he/she wants to install freeglut and OpenGL.

**This tutorial assumes that you have your operating system installed and you have access to the internet**

Steps:

From a terminal

1) sudo apt-get update

-This will update your apt database to the most recent available packages.

2) sudo apt-get install build-essential

- This installs the necessary development tools for building source code.

3) sudo apt-get install freeglut3-dev

- This installs the development libraries and headers for freeglut.

Your done! Extremely simple! However you must remember that when compiling you must add a '-lglut' as a comand line argument to gcc. If you don't it cannot find the library's and you will get undefined reference errors.

example command line: gcc simple.c -lglut

At this point if your program compiles and runs then you are finished. However the first time I tried to run mine I received a 'libGL warning: 3D driver claims to not support visual 0x42'. This error means I cannot display the required colors to run the program. In my case I had the most recent drivers for my video card. So I did some research on my monitor and found out it can display a color depth of 24 instead of the 16 it was set at. To fix this problem you must edit the /etc/X11/xorg.conf file as root and set the 'DefaultDepth 24'. Reboot and the problem is solved.

This is my first post (and tutorial) on the ubuntuforums. If people feel that this tutorial is not needed they can feel free to remove it. If anyone wants to add anything related to freeglut or OpenGl please feel free.











The first thing to do is install the OpenGL libraries. I recommend:

freeglut3
freeglut3-dev
libglew1.5
libglew1.5-dev
libglu1-mesa
libglu1-mesa-dev
libgl1-mesa-glx
libgl1-mesa-dev

Once you have them installed, link to them when you compile:

g++ -lglut -lGL -lGLU -lGLEW example.cpp -o example

In example.cpp, include the OpenGL libraries like so:

#include < GL/glew.h >
#include < GL/glut.h >
#include < GL/gl.h >
#include < GL/glu.h >
#include < GL/glext.h >

Then, to enable the more advanced opengl options like shaders, place this after your glutCreateWindow Call:

GLenum err = glewInit();
if (GLEW_OK != err)
{
    fprintf(stderr, "Error %s\n", glewGetErrorString(err));
    exit(1);
}
fprintf(stdout, "Status: Using GLEW %s\n", glewGetString(GLEW_VERSION));

if (GLEW_ARB_vertex_program)
    fprintf(stdout, "Status: ARB vertex programs available.\n");

if (glewGetExtension("GL_ARB_fragment_program"))
    fprintf(stdout, "Status: ARB fragment programs available.\n");

if (glewIsSupported("GL_VERSION_1_4  GL_ARB_point_sprite"))
    fprintf(stdout, "Status: ARB point sprites available.\n");

That should enable all OpenGL functionality, and if it doesn't, then it should tell you the problems.






  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值