glut

Callback to non-static method

大城市里の小女人 提交于 2019-12-01 10:57:02
Think of your basic GLUT programs. They simply run from a main method and contain callbacks like `glutMouseFunc(MouseButton) where MouseButton is the name of a method. What I have done is I have encapsulated the main file into a class, so that MouseButton is no longer a static function but has an instance. But doing this gives me a compilation error : Error 2 error C3867: 'StartHand::MouseButton': function call missing argument list; use '&StartHand::MouseButton' to create a pointer to member c:\users\angeleyes\documents\visual studio 2008\projects\capstone ver 4\starthand.cpp 388 IK Engine It

GLUT program link error

爱⌒轻易说出口 提交于 2019-12-01 10:48:06
I want to compile a GLUT program #include <GL/glut.h> int main(int argc, char **argv) { // init GLUT and create Window glutInit(&argc, argv); glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA); glutInitWindowPosition(100,100); glutInitWindowSize(320,320); glutCreateWindow("Lighthouse3D- GLUT Tutorial"); return 1; } Compile and link command: gcc -o main.exe main.c -lglut32 Result: main.o:main.c:(.text.startup+0x1c): undefined reference to `glutInit' main.o:main.c:(.text.startup+0x28): undefined reference to `glutInitDisplayMode' main.o:main.c:(.text.startup+0x3c): undefined reference to

Glut Mouse Coordinates

北慕城南 提交于 2019-12-01 10:40:35
I am trying to obtain the Cartesian coordinates of a point for that I am using a simple function the devolves a window coordinates, something like (100,200). I want to convert this to Cartesian coordinates, the problems is that the window size is variable so I really don't know how to implement this. Edit: Op: I tried to use the guUnPorject by doing something like this GLdouble modelMatrix[16]; glGetDoublev(GL_MODELVIEW_MATRIX,modelMatrix); GLdouble projMatrix[16]; glGetDoublev(GL_PROJECTION_MATRIX,projMatrix); double position[3]; gluUnProject( x, y, 1, modelMatrix, projMatrix, viewport,

opengl: how to keep objects in window when it's resized

天涯浪子 提交于 2019-12-01 09:14:00
问题 I'm working a MS paint-like application on OpenGL using Bresenham's midpoint algorithm as homework. So far I can draw lines and ellipses. I lose them all when resizing the window. How can I keep them drawn? Full code: #include "GL/glut.h" #include <stdio.h> #include <math.h> int i; //int mainWindow, subWindow; int X1, Y1, X2, Y2; int modoDeDibujo; int W = 1000, H = 1000; /*void menuApp (int value) { if (value == 1) printf("Linea\n"); if (value == 2) printf("Circulo\n"); if (value == 3) printf

Why won't this GLUT program compile? Am I missing libraries or headers?

萝らか妹 提交于 2019-12-01 07:32:48
问题 I've just started using Linux (Mint 11), and recently, I decided to take up OpenGL programming as a hobby. I'm finding the code and techniques relatively simple enough, however, I'm having a hard time trying to get all the resources in the right place. The code is: #include <stdlib.h> #include <stdio.h> #include <GL/glew.h> #ifdef __APPLE__ # include <GLUT/glut.h> #else # include <GL/glut.h> #endif static int make_resources(void) { return 1; } static void update_fade_factor(void) { } static

配置VC++2010的glut库

安稳与你 提交于 2019-12-01 07:28:33
VC++2010是一个成熟稳定的版本,微软的编译工具Visual Studio系列从VC6到如今的VC2019,功能非常强大,我们在开始学习C++和计算机图形学的时候,一般入手<<C++Primer>><<OpenGL编程指南>>一般例子并不会详细讲解开发环境,这是因为C++和C语言还有OpenGL不是某一家公司的产物,而是开放标准,即成立标准委员会由多方协商参与制定,这样才有开源的实现,而在windows上研究相关技术开发商业产品,久而久之形成了惯例即采用微软出品的IDE,也的确很优秀,曾经宝兰也败下阵来,原因很多,但是我们觉得操作系统类似商城租房给商家销售差不多。当然在Linux环境下有它自身的一套C/C++编译器GCC/G++,相应的采用code::blocks或者Qt Creator或者KDeveloper等IDE。所以我们很多例子,笔记等不做特别说明都是在VC++2010或者其他版本上编译通过的。下面就是配置glut的步骤: 1.安装VS2010旗舰版,这个在百度下搜索VS2010旗舰版可以找到很多,还有安装步骤,安装完后记得填写KEY 2.glut还是<<配置code::blocks下glut>中下载的glut库,下面打开VC2010 粘屏幕其实不太必要,特别是多试几次后,步骤就几步,下面就文字罗列步骤 在菜单 文件->新建->项目 弹出的新建项目对话框中

配置code::blocks的glut环境

时光怂恿深爱的人放手 提交于 2019-12-01 05:07:20
code::blocks很小,特别适合小型项目及家用旧电脑上MingW下编程,当然windows还是安装的Visual Studio办公用的,现把配置过程记录一遍。 1.在百度搜code::blocks到官网下载,地址为 https://www.fosshub.com/Code-Blocks.html?dwl=codeblocks-17.12-setup.exe 安装时候全选,网上也有详细安装步骤,这个是自带MingW编译器的。安装后打开Code::Blocks 2.下载glut,现在opengl.org上的glut推荐的freeglut,习惯性的找个预编译包,就用Nate的Glut3.7.6预编译包,nate地址 http://user.xmission.com/~nate/glut.html , glut3.7.6 bin地址 http://user.xmission.com/~nate/glut/glut-3.7.6-bin.zip 下载后,创建D:\mclib\glut37目录,下面是include和lib子目录,include中创建gl文件夹,然后gl中放glut.h lib中放glut32.dll glut32.lib glut32.def 3.打开code::blocks,设置全局变量glut, 打开Global Variable Editor 后new

To pass a pointer to a member function

家住魔仙堡 提交于 2019-12-01 03:43:12
问题 I have an class with instance functions (or methods?). From within an instance, I try to pass pointers to those functions to a library. The library expects static functions. When I pass my pointers to the callback functions, the compiler complains that my functions are not static. I tried to put make them static, but if I do so, then I can't access the instance fields from within the functions. How could I go around this? Similar question is : Using a C++ class member function as a C callback

How to calculate look at point to move the camera with the mouse in OpenGL/GLUT?

送分小仙女□ 提交于 2019-12-01 01:47:36
This will be confusing for me to explain so please bear with me. I've already implemented most type of movements and rotations in my camera class, everything is working with the keyboard, now I want to implement the mouse. I capture the mouse movement like this: #define SENSITIVITY 25.0f void main(void) { (...) glutPassiveMotionFunc(processPassiveMotion); glutWarpPointer(WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2); glutSetCursor(GLUT_CURSOR_NONE); (...) } void processPassiveMotion(int x, int y) { int centerX = WINDOW_WIDTH / 2; int centerY = WINDOW_HEIGHT / 2; int deltaX = -1 * (x - centerX); int

Passing 1 argument (pointer) to glutDisplayFunc?

好久不见. 提交于 2019-11-30 21:10:03
I have created a virtual class with a basic draw() method which doesn't do anything. The purpose of this is that other classes, shapes and other stuff, which will be able to draw themselves in OpenGL, will inherit this virtual class, allowing me to create an array of pointers to many different classes. The idea behind this was that I was hoping I would be able to pass a pointer to this array into my glutDisplayFunc callback. (This happens to be named drawScene(). Unfortunately I don't seem to be able to pass anything to it, as glutDisplayFunc is designed to take a method which takes no