glut

Background object is drawn in front of foreground object in OpenGL?

依然范特西╮ 提交于 2019-12-06 05:55:58
For testing purposes let's assume I've draw 2 teapots with glutSolidTeapot() , like this: glColor3f(1.0f, 0.0f, 0.0f); // Red teapot glutWireTeapot(1.0f); glColor3f(0.0f, 1.0f, 0.0f); // Green teapot glTranslatef(0.0f, 0.0f, 3.0f); glutWireTeapot(1.0f); The camera is initially located at (x,y,z) = (0.0f, 0.0f, 5.0f) and I'm looking at z = -1 (this is camera position #1). I'm sure you understand that the green teapot is the closest object to the camera and the red one is behind it. The problem is that the red one is drawn like it's in front of the green one, which doesn't look right: Example:

Drawing a rectangle on press and release of mouse, opengl

一笑奈何 提交于 2019-12-06 05:52:17
I'm trying to draw a rectangle from user input that collects x1,y1 coordinates from left click, and then specifies x2,y2 from release of the left click. I save the coordinates based on this mouse action successfully (based on cout<< statements confirming the coords are saved) but nothing is displayed after the left button is released. Here is what I've tried: (keep in mind, nothing crashes, so there is a logic error) void display(void) { glClear(GL_COLOR_BUFFER_BIT); glPushMatrix(); glColor3f(1,1,0); glBegin(GL_POLYGON); glVertex2f(clip_start.x_coord,clip_start.y_coord); glVertex2f(clip_finish

How can I change the position of the mouse cursor in OpenGL/Glut?

流过昼夜 提交于 2019-12-06 03:58:17
问题 I'm writing a simple game and I'm going to have the mouse control the camera (using GlutPassiveMotionFunc). I'm going to pitch and yaw based off the mouse difference between callbacks, however I think it would be a good idea to "force" the mouse back to the center of the screen every time they tried to move it. This way their cursor won't be at the edge of the screen and they can't move any further in that direction. What Glut / OpenGL command can I use to force the position of the mouse to

Why is GLUT so bad?

蹲街弑〆低调 提交于 2019-12-06 01:06:14
问题 I've seen a lot of bad comments about GLUT, although openFrameworks uses it. Cinder developers have stated that they want to stay as far away from GLUT as possible... So what's so bad about it? 回答1: You should never use the actual GLUT. It hasn't been updated since 2001 or so. FreeGLUT on the other hand is just fine; it is 100% backwards compatible with the original and is still in semi-active development. You may assume that any further references in this answer to "GLUT" to mean "FreeGLUT".

Drawing a solid sphere with transparency in openGL

情到浓时终转凉″ 提交于 2019-12-05 23:48:50
I want to draw a glutSolidSphere with some transparency, but it doesn't seem to work. glColor4f(1, 0, 0, 0); // should be completely invisible glPushMatrix(); glTranslatef(position.x, position.y, position.z); glutSolidSphere(3, 5, 5); glPopMatrix(); In my main function, I initialize with the following display mode: glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA | GLUT_ALPHA); What am I missing here? You need to explicitely setup alpha blending . Another example . glEnable (GL_BLEND); glBlendFunc (GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); 来源: https://stackoverflow.com/questions/4451399

How can I increase distance (zfar/gluPerspective) where openGL stops drawing objects?

倾然丶 夕夏残阳落幕 提交于 2019-12-05 20:54:11
I am learning OpenGL and having a problem with gluPerspective. Here is the code I use in Init() // Calculate The Aspect Ratio Of The Window // The parameters are: // (view angle, aspect ration of the width to the height, // The closest distance to the camera before it clips, // FOV, Ratio, The farthest distance before it stops drawing) gluPerspective(45.0f,(GLfloat)width/(GLfloat)height, 0.5f, 3000.0f); My scene works right.. but as soon as I go a little bit away from my objects they dissapear (As the red balls in image). : Web where I took graph from I understand that red balls are outside of

OpenGL buffers,glFlush and glutSwapBuffers()

杀马特。学长 韩版系。学妹 提交于 2019-12-05 19:43:37
Is there any difference between using, glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB); with glFlush() and glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB); with glutSwapBuffers() ? By difference, I imply difference in the execution or display of code ? There is a huge difference on modern platforms, in the sense that compositing window mangers (e.g. Aero on Windows Vista+) effectively own the front-buffer. If you draw single buffered, a buffer swap never occurs, and the end result is that nothing will ever be displayed on the screen. This also affects some implementations of hybrid GPUs (e.g. Intel

How to do stereoscopic 3D with OpenGL on GTX 560 and later?

不羁的心 提交于 2019-12-05 19:22:30
I am using the open source haptics and 3D graphics library Chai3D running on Windows 7. I have rewritten the library to do stereoscopic 3D with Nvidia nvision. I am using OpenGL with GLUT, and using glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE | GLUT_STEREO) to initialize the display mode. It works great on Quadro cards, but on GTX 560m and GTX 580 cards it says the pixel format is unsupported. I know the monitors are capable of displaying the 3D, and I know the cards are capable of rendering it. I have tried adjusting the resolution of the screen and everything else I can think of,

How do I use GTK and glut together?

你。 提交于 2019-12-05 18:57:47
I know that in order to write a GTK application, I write a bunch of code which describes what is put in the main window, then I call: gtk_main(); Any code statements after this do not get executed. Now let's suppose I'd like my GTK app to display something I wrote with glut, which itself contains a bunch of statements about what graphics need to be set etc. then ends with the statement: glutMainLoop(); Anything after this is not executed. So my problem is that either of these two statements prevents me from calling the other. Is there a way to execute a glut main loop inside a GTK widget ? Is

Render PNG images using OpenGL in Haskell

只谈情不闲聊 提交于 2019-12-05 18:24:21
I am new to Haskell and I am building a chess game using OpenGL (using Graphics.UI.GLUT ) for UI. I am trying to render PNG images for chess pieces. I read that images can be converted to TextureObject and then rendered, but could not find any helpful resources to know how to do it. This is what my code looks like for generating the chess board drawSquare :: BoardSquare -> IO () drawSquare ((x,y,z),(r,g,b)) = preservingMatrix $ do color $ Color3 r g b translate $ Vector3 x y z drawCube -- this will draw a square of appropriate size -- Display Callback display :: IORef GameState ->