Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ OS X CAOpenGLLayer how to enable OpenGL 3.2 core profile     - Android Studio and Git Git configuration file status (Linux)

- Redhat Close SELinux correct step (Linux)

- Expand an existing RAID arrays and remove the failed disk in a RAID (Linux)

- JDK installation and configuration environment variable under linuxb (Linux)

- LinSSID: a graphical Wi-Fi scanner under Linux (Linux)

- Bad name two variables (Linux)

- S5PV210 development board for embedded development environment to build under Ubuntu (Linux)

- Security Knowledge: redirection command application security (Linux)

- CentOS6.3 build a Python 3.3 environment to access Oracle 11gR2 (Database)

- Linux installation JDK1.6 rpm.bin assembly (Linux)

- Sublime Text 3 practical functions and shortcut keys used to collect (Linux)

- Docker use Dockerfile created since the launch of the service support SSH container mirror (Server)

- With screenfetch linux logo and basic hardware information display with cool Linux logo (Linux)

- CentOS 6.4 installation and configuration LNMP build PHP server runtime environment (Server)

- Linux Variable content removal and replacement (Linux)

- Ubuntu Apache virtual host configuration (Server)

- Ubuntu will be written in a command file, executable file, source command (Linux)

- RHEL5 establish a local yum source (Linux)

- Linux, how to filter, split, and merge pcap file (Linux)

- Linux install Maven and SVN client (Linux)

 
         
  OS X CAOpenGLLayer how to enable OpenGL 3.2 core profile
     
  Add Date : 2018-11-21      
         
         
         
  In openGL programming OS X, we sometimes want to on their own OpenGL add more layers of certain coatings, have to use CAOpenGLLayer instead NSOpenGLView, because the children are being added on NSOpenGLView view will become invalid.

In fact, CAOpenGLLayer custom subclasses to additional support OpenGL Core Profile is very simple, it just needs to be rewritten

- (CGLPixelFormatObj) copyCGLPixelFormatForDisplayMask: (uint32_t) mask

The method can be. As shown in the following code:

// Override the parent class method, provide their own CGLPixelFormatObj
- (CGLPixelFormatObj) copyCGLPixelFormatForDisplayMask: (uint32_t) mask
{
    CGLPixelFormatAttribute attribs [] = {
        
        kCGLPFADisplayMask, 0,
        kCGLPFAColorSize, 24,
        kCGLPFAAccelerated,
        kCGLPFADoubleBuffer,
        
        // Use OpenGL 3.2 Core Profile
        kCGLPFAOpenGLProfile, (CGLPixelFormatAttribute) kCGLOGLPVersion_3_2_Core,
        
        // Use multi-sample
        kCGLPFAMultisample,
        kCGLPFASampleBuffers, (CGLPixelFormatAttribute) 1,
        kCGLPFASamples, (CGLPixelFormatAttribute) 4,
        
        0
    };
    // Set the kCGLPFADisplayMask passed over the display mask. This step is a must!
    attribs [1] = mask;
    
    CGLPixelFormatObj pixFormatObj = NULL;
    GLint numPixFormats = 0;
    CGLChoosePixelFormat (attribs, & pixFormatObj, & numPixFormats);
    
    return pixFormatObj;
}


Then we can add a reference to the object to do some CGLContextObj mark in your subclass. In addition, we must rewrite CAOpenGLLayer this method:

- (Void) drawInCGLContext: (CGLContextObj) glContext

            pixelFormat: (CGLPixelFormatObj) pixelFormat

            forLayerTime: (CFTimeInterval) timeInterval

            displayTime: (const CVTimeStamp *) timeStamp

.

For example, as shown in the following code:

- (Void) drawInCGLContext: (CGLContextObj) glContext
            pixelFormat: (CGLPixelFormatObj) pixelFormat
            forLayerTime: (CFTimeInterval) timeInterval
            displayTime: (const CVTimeStamp *) timeStamp
{
    // Here must first be passed in the context of the implementation as the current OpenGL context object, otherwise follow the status of the OpenGL settings will be invalid
    CGLSetCurrentContext (glContext);
    
    [Self setupContext];
    
    // MContext mainly used for determining whether the current OpenGL context has been set up, as well as references in the render method
    mContext = glContext;
    
    [Self render];
}

 

- (Void) setupContext custom methods, which do vertex set global enable certain OpenGL functional status, and set the viewport and so on.

- (Void) render custom method is used to do the real graphics rendering.

As shown in the following code:

- (Void) render
{
    // Render
    glClear (GL_COLOR_BUFFER_BIT);
    
    glDrawArrays (GL_LINE_STRIP, 0, 721);
    
    glFlush ();
    
    CGLFlushDrawable (mContext);
}

We then provide their own shader code, and can be loaded. These can be placed setupContext implement a custom method.

Of course, to be used in OS X OpenGL core profile must be introduced < OpenGL / gl3.h> header file. Currently, 3.2 core profile and a 4.1 core profile is the header files.
     
         
         
         
  More:      
 
- Log4j configuration file Explanation (Linux)
- Linux System shutdown procedures (Linux)
- Redis performance test (Database)
- C ++ function object (Programming)
- How to find an IP address through the command line (Linux)
- Import and export myloader accelerate mydumper (Database)
- Linux non-graphical interface to install Oracle Database (Database)
- Deployment Kubernetes manage Docker example cluster on Ubuntu (Server)
- Linux system started to learn: the Linux syslog (Linux)
- Linux operating system, the internal and external security overview (Linux)
- In-depth understanding of capture Node.js garbage collection and memory leaks (Programming)
- Oracle 10g after the failure to start the upgrade (Oracle instance terminated. Disconnection forced) (Database)
- Linux Network Security: nmap port scanning software (Linux)
- VirtualBox install Windows 8.1 has encountered an error 0x000000C4 solutions (Linux)
- Parts of the partition is not recognized after Debian mount mobile hard disk (Linux)
- Oracle 11g contraction table space error ORA-03297: file contains used data beyondrequested RESIZE value (Database)
- B-tree - ideas and implementation of C language code (Programming)
- 8 Docker knowledge you may not know (Server)
- C data types is how it is supported by most computer systems (Programming)
- Monitoring services are running properly and will email alert (Server)
     
           
     
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.