opengl

Better to create new VBOs or just swap the data? (OpenGL)

So in a OpenGL rendering application, is it usually better to create and maintain a vertex buffer throughout the life of an application and just swap out the data every frame with glBufferData, or is it better to just delete the VBO and recreate it every frame? Intuition tells me it's better to swap out data, but a few sample programs I...

How do I set up OpenGL with SDL?

I have been tinkering with SDL for a few days now and I have hit a roadblock. It seems that rotating 2D sprites is very costly and, in a practical sense impossible with just plain SDL. After a great deal of reading, it seems that OpenGL, utilizing the hardware (as opposed to just a pure software solution) is the correct tool for the job....

Opening Images into OpenGL textures and saving textures as PNGs with Cocoa

Hello. There is a lot of conflicting information on how to open images with Cocoa for use with OpenGL. I want to open JPG and PNG files and save PNG files for my program which uses Cocoa on the Mac version. What is the best way to do these two tasks? Thank you. ...

Point doesn't show in OpenGL

Hi all I am trying to draw a point using OpenGL like below, but it only displays a black window. Can someone tell me what's the error? #include "stdafx.h" #include <gl/GL.h> #include <gl/GLU.h> #include <gl/glut.h> void init(void) { glClearColor(0.0,0.0,0.0,0.0); glColor3f(1.0,0,1.0); glPointSize(10); //glShadeModel(...

Bus error when using GLUT.

I am trying to create a GLUT application. Currently, I have this code: void init ( GLvoid ) // Create Some Everyday Functions { glShadeModel(GL_SMOOTH); // Enable Smooth Shading glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background glClearDepth(1.0f); ...

GPU Render onto sphere

Hello, I am trying to write an optimized code that renders a 3D scene using OpenGL onto a sphere and then displays the unwrapped sphere on the screen ie producing a planar map of a purely reflective sphere. In math terms, I would like to produce a projection map where the x axis is the polar angle and y axis is the azimuth. I am trying ...

How do I use gluLookAt properly?

I don't want to get into complex trigonometry to calculate rotations and things like that for my 3D world so gluLookAt seems like a nice alternative. According to the documentation all I need to do is place 3 coordinates for the cameras position, three for what I should be looking at and an "up" position. The last made no sense until I a...

GLCanvas and other JOGL classes missing from NetBeans OpenGL Pack?

Hey, I'm have horrendous problems trying to get a JOGL program compiling using Netbeans 6.9. I can't seem to find an up to date explanation as to how to do this. When I install the NetBeans OpenGL pack I can't compile the examples. I get a compile error stating it can't find some methods such as GLCanvas(). When I go to the library to s...

Haskell or Ocaml with OpenGL and SDL precompiled distribution for Windows

I want to learn Ocaml or Haskell and I want to do it by writing a simple game. Apparently, there's one small problem: nobody cares about Windows and I want to do it on Windows, natively. Haskell has Cabal, which has SDL, but it doesn't build due to a trivial problem with no workarounds (order of parameters passed to gcc). Ocaml doesn't ...

Help with Try Catch

I'm using the GLUTesselator and every once in a while EndContour() fails so I did this: try { PolygonTesselator.End_Contour(); } catch (int e) { renderShape = false; return; } Why would it still crash, it should perform the catch code right? How could...

Advice on cross-platform OpenGL image loader for textures.

Hello. I need to load PNGs and JPGs to textures. I also need to save textures to PNGs. When an image exceeds GL_MAX_TEXTURE_SIZE I need to split the image into separate textures. I want to do this with C++. What could I do? Thank you. ...

OpenGL equivalent of SetROP2(R2_NOT)

Considering QGLWidget (or OpenGL in general), what can be the easiest solution to draw pixels in the inverse color of the screen / frame buffer? In Win32 / MFC environment, I used to use the SetROP2(R2_NOT) with zero pain. ...

A way of debugging GLU with Visual Studio?

I'm using GLUTess to tesselate polygons. Sometimes it crashes with a null pointer issue and I have no way of knowing why since I just link to glu32.lib . Is there a way to see the source and get the exact line it crashes on? Thanks ...

Static linking GLU?

I'm using GLUTess to tesselate polygons. After several tests, I realized glu32.lib which links to glu32.dll, crashes every once in a while. Whereas GLU which I got from the opengl sdk, is solid as a rock. Unfortunately though, by not linking to the windows dll, this means I need to drag around GLU.dll with my app instead of relying on Wi...

CUThread lnk2001 error

1>Linking... 1>main.cu.obj : error LNK2001: unresolved external symbol cutWaitForThreads 1>main.cu.obj : error LNK2001: unresolved external symbol cutStartThread I get those errors when trying to compile my project. I have included the cutil64 in linker dependencies, but I can see that's not it. I can't seem to figure out what's wrong w...

Using templates to manage glUniform functions

Hi again and welcome to another 'wouldn't it be great if we'd combine two things that i really don't understand anything about'-question ;) This Episode: OpenGL Uniforms and c++ Templates The Idea: Wouldn't it be great if you could write a single template function to set uniforms in an OpenGL shader? The Problem: Uniforms in shaders a...

How can i do perspective transformation in OpenGL?

If i have common style perspective transformation matrix like this / focus 0 cx \ | 0 focus cy | \ 0 0 1 / how can setup parameters for glFrustum or gluPerspective to get correct transformation for example: glFrustum ( -cx, screenWidth - cx, -cy, screenHeight - cy, focus, focus + 1000) gluLookAt( 0.0, 0.0, -...

Opengl Games: Do i have to know 3d related math to create good opengl games ?

Hello. I read about OpenGL and about nvidia-cg-toolkit and other shaders, all contains lots of math problems and math formulas for effects and such. I want to be able to make proper 3d games that use the GPU as much as possible. Do I have to use a 3d Engine if the math related info does not interest me ? if so, can anyone recommend of...

OpenGL - Question about the usage of glDepthMask

Hello all, I have rendered an objectA in a scene as follows. The scene has many other objects too. void Draw() { if( glIsList( displayListID ) ) { glPushAttrib( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_ENABLE_BIT ); glEnable( GL_BLEND ); glEnable( GL_DEPTH_TEST ); //glDepthMask( GL_FALSE )...

GLSL - Problem of casting and weird bug

Hi, i'm here to get help about a strange behavior of my GLSL code when i cast a float to an int and i never seen such a bug since i started GLSL Actually i'm trying to achieve mesh skinning on CPU with GLSL I use an ATI Radeon HD 4850 (Gainward) and i work with OpenGL 2.1 on Windows XP so on CPU side I gather bones indices and weights...