opengl

How to draw a text (write on the screen) using standard OpenGL functions?

I know I can do it with GLUT. But, I have a big project and I had problem adding GLUT (I am using Delphi) to it. So, what other options do I have? ...

OpenGL Line Width

In my OpenGL app, it won't let me draw a line greater then ten pixels wide. Is there a way to make it draw more than ten pixels? void OGL_Renderer::drawLine(int x, int y, int x2, int y2, int r, int g, int b, int a, int line_width) { glColor4ub(r, g, b, a); glLineWidth((GLfloat)line_width); glBegin(GL_LINES); glVertex2i(x, y); glVe...

Convert triangle strips to triangles?

I'm using the GPC tessellation library and it outputs triangle strips. The example shows rendering like this: for (s= 0; s < tri.num_strips; s++) { glBegin(GL_TRIANGLE_STRIP); for (v= 0; v < tri.strip[s].num_vertices; v++) glVertex2d(tri.strip[s].vertex[v].x, tri.strip[s].vertex[v].y); glEnd(); } The issue is...

Xcode (Snow Leopard) project works differently based on declaration of a single variable.

OK, I'm still quite new to Xcode/Cocoa etc, so please forgive me if this issue is something totally obvious, but it seems to me to completely defy any logical software behaviour that I have ever seen. I have a project which uses OpenGL in Snow Leopard. I have created a very basic solid teapot (using glut, obviously) and have shone a lig...

OpenGL/D3D: How do I get a screen grab of a game running full screen in Windows?

Suppose I have an OpenGL game running full screen (Left 4 Dead 2). I'd like to programmatically get a screen grab of it and then write it to a video file. I've tried GDI, D3D, and OpenGL methods (eg glReadPixels) and either receive a blank screen or flickering in the capture stream. Any ideas? For what it's worth, a canonical example...

How to plot two equidistant moving points?

Imagine a surface which has got 2 points which are moving over the surface (resulting into various lines and curves) while adhering to the following conditions. These two points are always and always at a constant C distance from each other. Each point has it's own velocity and direction vector. Of course both these parameters will be...

How to handle "switch from" and "switch to" events in X11?

I'm making a fullscreen OpenGL application, and I want it to restore original desktop mode when user switches away from it, and to restore mode back when user switches to it. This looks like "FocusIn" and "FocusOut" events, but they are not suitable for this. Window will get "FocusOut" as soon as user presses Alt+Tab and window selector ...

OpenGL Superbible linear algebra - is this correct?

I recently started reading OpenGL Superbible 5th edition and noticed the following: Having just taken linear algebra this seemed odd to me. The column vector is of dimension 4x1 and the matrix is 4x4, how is it possible to multiply them together? If the vector were a row-vector and the output were a row vector I agree that it would ...

If I have an array of vertices, how can I sort them in a fashion that would make it suitable to loop through and draw a triangle strip?

I started learning about reading the data packed in a Collada file (.dae). I'm to the point where I have the vertices of a specific mesh. Right now, I'm just looping through them between calls to glBegin and glEnd, and I noticed that not all of the faces were being rendered. I think it might be because the vertices aren't in the correct ...

What's so different about OpenGL 3.x?

I've been looking for an OpenGL book lately and noticed that the OpenGL programming guide (2010) is deprecated. What's so different about OpenGL 3.x from 2.x? ...

Camera rotation (OpenGL)

I am having trouble with a camera class I am trying to use in my program. When I change the camera_target of the gluLookAt call, my whole terrain is rotating instead of just the camera rotating like it should. Here is some code from my render method: camera->Place(); ofSetColor(255, 255, 255, 255); //draw axis lines //x-axis g...

C++ How to replace a function but still use the original function in it?

I want to modify the glBindTexture() function to keep track of the previously binded texture ID's. At the moment i just created new function for it, but then i realised that if i use other codes that use glBindTexture: then my whole system might go down to toilet. So how do i do it? Edit: Now when i thought it, checking if i should bin...

Image loading in OpenGL for use in GIS appliation.

I am currently working on an in house GIS app. Background images are loaded in OpenGL by breaking the image down into what I guess are termed texels and mipmapped, after which a display list is built to texture map each texel onto rectangles. This sounds pretty standard, but the issue is that currently for images that do not divide nea...

Problem with CreateDC and wglMakeCurrent

PIXELFORMATDESCRIPTOR pfd = { /* otherwise fine for a window with 32-bit color */ }; HDC hDC = CreateDC(TEXT("Display"),NULL,NULL,NULL); // always OK int ipf = ChoosePixelFormat(hDC, // always OK SetPixelFormat(hDC,ipf, // always OK HGLRC hRC = wglCreateContext(hDC); // always OK wglMakeCurrent(hDC,hRC); // ! read error: 0xbaadf03...

OpenGL gluBuild2DMipmaps giving me problems. Help!

Edit: Updated code. Now works well enough. Foreword. I am an OpenGL newb tasked with maintaining an app that, among other things, uses wxWidgets and OpenGL to display a variety of image formats as backgrounds for reference in overlaying user items. The original code for displaying images broke up the image into 512x512 chunks and ma...

In OpenGL, what is the simplest way to create a perspective view using only OpenGL3+ methods?

This might sound lazy at first, but I've been researching it for 2 days. I have an SDL+GLEW app that draws a primitive. I wanted to make a few viewports in different perspectives. I see the four viewports but I can't change the the perspectives. Assume you have draw(); swapbuffers(); What is the simplest way - in OpenGL3+ spec - to...

GLM + STL: operator == missing

Hi there, I try to use GLM vector classes in STL containers. No big deal as long as I don't try to use <algorithm>. Most algorithms rely on the == operator which is not implemented for GLM classes. Anyone knows an easy way to work around this? Without (re-)implementing STL algorithms :( Kind Regards, Florian GLM is a great math libra...

SVG interaction in python with cairo, opengl and rsvg

Hi, I render a huge SVG file with a lot of elements with Cairo, OpenGL and rsvg. I draw svg on cairo surface via rsvg and create an OpenGL texture to draw it. Everything is fine. And now I have to interact with elements from SVG. For example, I want to guess an element by coordinates. And I want to change the background of some path in S...

How to redraw a view? (OpenGl)

Hi, I want to create a kind of a simulation. It should display the certain position of a fish/shark/orca (not real ones, they are set up randomly). My Simulation can display the starting situation: glOrtho(0, breite, 0, hoehe, 0, 1); glClearColor(0, 0, 1, 0); glClear(GL_COLOR_BUFFER_BIT); //Besetzen der Felder srand(time(0)); NSMutable...

How do I convert a photo from color to black and white using OpenGL?

Lets say we see an image of people watching tv in color and when I add the OpenGL code it turns into this: http://i.dailymail.co.uk/i/pix/2008/10/18/article-1078627-02281598000005DC-210_468x382.jpg What is the code to convert the photo from color to black and white? ...