glut

glutBitmapCharacter positions text wrong

元气小坏坏 提交于 2019-12-01 23:53:23
问题 I'm trying to draw a simple string (overlay) on the screen. From what I've found over the internet, I'm using it this way: void write(string text, int x, int y){ glRasterPos2i(x,y); for(int i = 0; i < text.length(); i++){ glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, text.data()[i]); } } But it draws the string according to the world coordinates. Say, if x and y are set to 10, they are drawn at (10,10,0) coordinates in the world. But I simple need this string at window's (10,10) coordinates

glutBitmapCharacter positions text wrong

陌路散爱 提交于 2019-12-01 21:19:58
I'm trying to draw a simple string (overlay) on the screen. From what I've found over the internet, I'm using it this way: void write(string text, int x, int y){ glRasterPos2i(x,y); for(int i = 0; i < text.length(); i++){ glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, text.data()[i]); } } But it draws the string according to the world coordinates. Say, if x and y are set to 10, they are drawn at (10,10,0) coordinates in the world. But I simple need this string at window's (10,10) coordinates in 2D. This is part of a small project, and the draw method is given as below. I don't want to change it

GLUT key down and key up on CTRL key

狂风中的少年 提交于 2019-12-01 18:43:32
I've found a lot of information about using GLUT to detect whether the Ctrl key is pressed using the GLUT_ACTIVE_CTRL macro. This macro only works, apparently, within a keyboard or mouse callback function. I need to know whether or not the Ctrl key is pressed at a point in my main loop, but GLUT_ACTIVE_CTRL doesn't seem to work in this context. So, is there a way to detect key up and key down events on the Ctrl key (without any other keys being typed) in a platform independent GLUT-ish way? EDIT: The keyboard callback is not fired (at least for a default setup) when the Ctrl key is pressed.

GLUT key down and key up on CTRL key

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-01 18:40:16
问题 I've found a lot of information about using GLUT to detect whether the Ctrl key is pressed using the GLUT_ACTIVE_CTRL macro. This macro only works, apparently, within a keyboard or mouse callback function. I need to know whether or not the Ctrl key is pressed at a point in my main loop, but GLUT_ACTIVE_CTRL doesn't seem to work in this context. So, is there a way to detect key up and key down events on the Ctrl key (without any other keys being typed) in a platform independent GLUT-ish way?

OpenGL offscreen render

穿精又带淫゛_ 提交于 2019-12-01 14:39:00
I have an application that creates a 3D model and exports an image from that. I use this example to do it: #include <windows.h> #include <GL\GL.h> #include <GL\glu.h> #include <GL\glut.h> #include <opencv2\highgui.hpp> GLfloat light_diffuse[] = { 1.0, 0.0, 0.0, 1.0 }; /* Red diffuse light. */ GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 }; /* Infinite light location. */ GLfloat n[6][3] = { /* Normals for the 6 faces of a cube. */ { -1.0, 0.0, 0.0 },{ 0.0, 1.0, 0.0 },{ 1.0, 0.0, 0.0 }, { 0.0, -1.0, 0.0 },{ 0.0, 0.0, 1.0 },{ 0.0, 0.0, -1.0 } }; GLint faces[6][4] = { /* Vertex indices for the

Faces missing when drawing icosahedron in OpenGL following code in redBook

独自空忆成欢 提交于 2019-12-01 14:31:01
I am attempting to draw an icosahedron following this popular OpenGl tutorial in the redBook. I am using GLUT to handle windowing. Here is my complete code. It is mostly the code from the tutorial plus some clerical work using GLUT #include <stdio.h> #include <GL/glut.h> #define X .525731112119133606 #define Z .850650808352039932 void mouseEventHandler(int button, int state, int x, int y){ } void display() { glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); static GLfloat vdata[12][3] = { {-X,0.0,Z}, {X,0.0,Z}, {-X,0.0,-Z}, {X,0.0,-Z}, {0.0,Z,X}, {0.0,Z,-X}, {0.0,-Z,X}, {0.0,-Z,-X}, {Z,X,0.0}, {-Z,X

Image loading using openGL, SOIL

孤街醉人 提交于 2019-12-01 13:09:26
I tried a lot of examples for loading and displaying images in openGL using SOIL. while running the source code below, it displays just a wite quad without an image. I tried to open an image called: foto. I placed the image-file in the folder of the program. bool* keyStates = new bool[256]; GLuint texture[0]; void resize(int height, int width) { const float ar = (float) width / (float) height; glViewport(0, 10, width, height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glFrustum(-ar, ar, -1.0, 1.0, 2.0, 90.0); //gluLookAt(0, 2, 0, -1, 1, -3, 0, 1, 0); glMatrixMode(GL_MODELVIEW);

OpenGL offscreen render

让人想犯罪 __ 提交于 2019-12-01 12:19:19
问题 I have an application that creates a 3D model and exports an image from that. I use this example to do it: #include <windows.h> #include <GL\GL.h> #include <GL\glu.h> #include <GL\glut.h> #include <opencv2\highgui.hpp> GLfloat light_diffuse[] = { 1.0, 0.0, 0.0, 1.0 }; /* Red diffuse light. */ GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 }; /* Infinite light location. */ GLfloat n[6][3] = { /* Normals for the 6 faces of a cube. */ { -1.0, 0.0, 0.0 },{ 0.0, 1.0, 0.0 },{ 1.0, 0.0, 0.0 }, { 0

GLUT screen capture in C

亡梦爱人 提交于 2019-12-01 12:12:08
I'm trying to do a screen capture in GLUT and I'm having a bit of an issue. glReadPixels() seems to crash my program with an Access violoation writing location 0x00000000 The thing that is weird is the file is created in the root of the project, and is obviously empty. I set up some printf commands quickly and it appears that the code crashes each time during the glReadPixels() method. I feel the issue maybe the variable 'pixels'. Im having trouble figuring out the correct way to define this so that the RGB values are written to it. Any tips would be appreciated. void savePPM(char ppmFileName[

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

▼魔方 西西 提交于 2019-12-01 10:58:38
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 void render(void) { glClearColor(1.0f, 1.0f, 1.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); glutSwapBuffers(