create VBO

$ nvcc projecto.cu -I/home/pinto/NVIDIA_CUDA_SDK/common/inc/ -L/home/pinto/NVIDIA_CUDA_SDK/lib -lglut -lcudart

/tmp/tmpxft_0000591e_00000000-12_projecto.o: In function `createVBO(unsigned int*)':

tmpxft_0000591e_00000000-11_projecto.ii:(.text+0x9dc0): undefined reference to `__glewGenBuffers'

tmpxft_0000591e_00000000-11_projecto.ii:(.text+0x9dd6): undefined reference to `__glewBindBuffer'

tmpxft_0000591e_00000000-11_projecto.ii:(.text+0x9df9): undefined reference to `__glewBufferData'

tmpxft_0000591e_00000000-11_projecto.ii:(.text+0x9e1e): undefined reference to `__glewBindBuffer'

collect2: ld returned 1 exit status

anyone knows why this happens? i have the same includes of simpleGL.

i’m using ubuntu 9.04 with cuda sdk and cuda toolkit 2.1

kernel: 2.6.28-13-generic

gcc version: 4.2.4

Link again the GLEW library.

how do I do this?

i found the answer XD

i don’t had the libglew-dev installed, because it could not use -lGLEW linker :(

one more time thanks for the precious help :)

#ifdef _WIN32

#  define WINDOWS_LEAN_AND_MEAN

#  define NOMINMAX

#  include <windows.h>

#endif

// includes, system

#include <stdlib.h>

#include <stdio.h>

#include <string.h>

#include <math.h>

// includes, GL

#include <GL/glew.h>

#if defined (__APPLE__) || defined(MACOSX)

#include <GLUT/glut.h>

#else

#include <GL/glut.h>

#endif

// includes

#include <cuda_runtime.h>

#include <cutil_inline.h>

#include <cutil_gl_error.h>

#include <cuda_gl_interop.h>

#include <vector_types.h>

//#include <GL/GLee.h>

// declaration, forward

CUTBoolean initGL();

void createVBO(GLuint* vbo);

void deleteVBO(GLuint* vbo);

// vbo variables

GLuint vbo;

////////////////////////////////////////////////////////////////////////////////

// constants

const unsigned int window_width = 512;

const unsigned int window_height = 512;

const unsigned int mesh_width = 256;

const unsigned int mesh_height = 256;

int main(int argc, char **argv) {

	createVBO(&vbo);

	cudaThreadExit();

								

	return 0;

}

// create VBO

void createVBO(GLuint* vbo)

{

	// create buffer object 

	glGenBuffers(1, vbo);											   // Segmentation fault

	glBindBuffer(GL_ARRAY_BUFFER, *vbo);

	

	// initialize buffer object

	unsigned int size = mesh_width * mesh_height * 4 * sizeof(float);

	glBufferData(GL_ARRAY_BUFFER, size, 0, GL_DYNAMIC_DRAW);

	glBindBuffer(GL_ARRAY_BUFFER, 0);

	// register buffer object with CUDA

	cutilSafeCall(cudaGLRegisterBufferObject(*vbo));

	CUT_CHECK_ERROR_GL();

}

now i have one problem, i have a Segmentation fault when create a vbo :S

anyone knows the problem?

You have a conflict with the variable vbo. It is both a static global variable and an argument in createVBO(), and I am guessing the global definition takes precedence in the compilation unit, resulting in an attempt to deference an integer as a pointer.