Ejemplo n.º 1
0
CVertexArrayRange::CVertexArrayRange(float* mem,int size) {
    delete[] drawArray;

    drawArray=mem;
    drawArraySize=mem+size;

    glGenFencesNV(1, &fence);
    glEnableClientState(GL_VERTEX_ARRAY_RANGE_NV);
}
Ejemplo n.º 2
0
Milestone::Milestone(const std::string& n) : _name(n), isSet(false) {

    if (glGenFencesNV) {
        if (factory.size() == 0) {
            int num = 10;
            factory.resize(num, DONT_SHRINK_UNDERLYING_ARRAY);
            glGenFencesNV(num, factory.getCArray());
        }
        
        // Grab a preallocated fence
        glfence = factory.pop();
    }
}
Ejemplo n.º 3
0
	void	gen_fences(int count, unsigned int* fence_array)
	// Wrapper for glGenFencesNV.
	{
		if (glGenFencesNV) {
			glGenFencesNV(count, (GLuint*)fence_array);
		}
		else
		{
			// set all fences to 0.
			for (int i = 0; i < count; i++) {
				fence_array[i] = 0;
			}
		}
	}
Ejemplo n.º 4
0
static void initialize_opengl_sync() {
    check_opengl_sync_capabilities();
    decide_opengl_sync_method();
#ifdef USE_GLES

#else
    if (g_has_nv_fence) {
        glGenFencesNV(1, &g_fence);
        CHECK_GL_ERROR_MSG("glGenFencesNV(1, &g_fence)");
    }
    else if (g_has_apple_fence) {
        glGenFencesAPPLE(1, &g_fence);
        CHECK_GL_ERROR_MSG("glGenFencesAPPLE(1, &g_fence)");
    }
#endif
}
Ejemplo n.º 5
0
void init_display()
{
   int surface_type_id, result, i, value, scrn, num_fbconfigs;
   GLXFBConfig *fbconfigs;
   XVisualInfo *visInfo;
   XSetWindowAttributes attributes;
   Window root;
   int attrib_pbuffer[6] = {GLX_PBUFFER_WIDTH, 0, 
                            GLX_PBUFFER_HEIGHT, 0,
                            GLX_PRESERVED_CONTENTS,
                            0};

   width = horizontal_size;
   height = vertical_size;

   if(chroma_format != CHROMA420)
      error("we only support 4:2:0 chroma formats\n");

   display = XOpenDisplay(NULL);
   root = XDefaultRootWindow(display);
   scrn = XDefaultScreen(display);

   if(!GetPortId(display, &portNum, &surface_type_id))
      error("couldn't find a suitable port\n");



#ifdef USE_DLOPEN
   if(!ResolveFunctions(DLFILENAME))
      error("couldn't resolve necessary functions\n");
#endif

   result = XvMCCreateContext(display, portNum, surface_type_id, 
                              coded_picture_width, coded_picture_height,
                              XVMC_DIRECT, &context);

   if(result != Success)
      error("couldn't create XvMCContext\n");

   for(i = 0; i < numsurfaces; i++) {
      result = XvMCCreateSurface(display, &context, &surfaces[i]);
      if(result != Success) {
          if(i < 4) {
             XvMCDestroyContext(display, &context);
             error("couldn't create enough XvMCSurfaces\n");
          } else {
             numsurfaces = i;
             printf("could only allocate %i surfaces\n", numsurfaces);
          }
      } 
      surface_info[i].reference = 0;
      surface_info[i].sequence_number = 0;      
   }

   slices = slices * mb_width;

   XvMCCreateBlocks(display, &context, slices * 6, &blocks);
   XvMCCreateMacroBlocks(display, &context, slices, &macro_blocks);

   fbconfigs = glXChooseFBConfig(display, scrn, attr_fbconfig, &num_fbconfigs);

   gl_fbconfig = *fbconfigs;

   /* find the first one with no depth buffer */
   for(i = 0; i < num_fbconfigs; i++) {
      glXGetFBConfigAttrib(display, fbconfigs[i], GLX_DEPTH_SIZE, &value);
      if(value == 0) {
         gl_fbconfig = fbconfigs[i];
         break;
      }
   }

   PrintVisual();
 
   visInfo = glXGetVisualFromFBConfig(display, gl_fbconfig);

   attrib_pbuffer[1] = width;
   attrib_pbuffer[3] = bob ? (height/2) : height;
   gl_pbuffer = glXCreatePbuffer(display, gl_fbconfig, attrib_pbuffer);

   gl_context = glXCreateNewContext(display, gl_fbconfig, GLX_RGBA_TYPE, 
                                    NULL, 1);

   attributes.colormap = XCreateColormap(display, root, visInfo->visual,
                                         AllocNone);

   window = XCreateWindow(display, root, 0, 0, width, height, 0,
                          visInfo->depth, InputOutput,
                          visInfo->visual, CWColormap, &attributes);

   gl_window = glXCreateWindow(display, gl_fbconfig, window, NULL);

   XSelectInput(display, window, KeyPressMask | StructureNotifyMask |
                                 Button1MotionMask | ButtonPressMask);
   XMapWindow(display, window);

   glXMakeContextCurrent(display, gl_window, gl_pbuffer, gl_context);
   glDrawBuffer(GL_BACK);
   glReadBuffer(GL_FRONT_LEFT);

   tex_w =  1 << PowerOfTwo(width);
   tex_h = 1 << PowerOfTwo(bob ? (height/2) : height);

   printf("%i x %i texture\n", tex_w, tex_h);

   glClearColor (0.0, 0.0, 0.0, 0.0);

   glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
   glTexImage2D(GL_TEXTURE_2D, 0, 3, tex_w, tex_h,
                0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
   glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
   glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
   glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
   glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
   glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
   glEnable(GL_TEXTURE_2D);
   glShadeModel(GL_FLAT);

   glViewport(0, 0, width, height);
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
   glFrustum(-1.0, 1.0, -1.0, 1.0, 2, 18.0);
   glMatrixMode(GL_MODELVIEW);
   glLoadIdentity();
   glTranslatef(0.0, 0.0, -8);

#ifdef USE_NV_FENCE
   glGenFencesNV(1, &nvFence);
   glSetFenceNV(&nvFence, GL_ALL_COMPLETED_NV);
#endif

   XSync(display, 0);

   uiclp = uiclip+512;
   for (i= -512; i<512; i++)
      uiclp[i] = (i<-128) ? 0 : ((i>127) ? 255 : i+128);

   iclp = iclip+512;
   for (i= -512; i<512; i++)
      iclp[i] = (i<-128) ? -128 : ((i>127) ? 127 : i);

   niclp = niclip+512;
   for (i= -512; i<512; i++)
   niclp[i] = (i<-256) ? -256 : ((i>255) ? 255 : i);

}