Note that there are some explanatory texts on larger screens.

plurals
  1. POuse opengl in thread
    primarykey
    data
    text
    <p>I have a library, which is engaged in rendering on opengl and prinimaet streams from the network.</p> <p>I write under a poppy, but plans to use on linux</p> <p>so the window is created for objective c I start drawing in a separate thread in the other receiving and decoding the data.</p> <p>I crash bug (EXT_BAD_ACCESS) on methods of opengl, even if I use them only in a single thread.</p> <p>my code main glut:</p> <pre><code>int main(int argc, const char * argv[]){ glutInit(&amp;argc, argv); glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGBA); int win = glutGetWindow(); glutInitWindowSize(800, 600); glutCreateWindow("OpenGL lesson 1"); client_init(1280, 720, win, "192.168.0.98", 8000, 2222); return 0; </code></pre> <p>}</p> <p>or objective c</p> <pre><code>- (id)initWithFrame:(NSRect)frameRect pixelFormat:(NSOpenGLPixelFormat*)format{ self = [super initWithFrame:frameRect]; if (self != nil) { NSOpenGLPixelFormatAttribute attributes[] = { NSOpenGLPFANoRecovery, NSOpenGLPFAFullScreen, NSOpenGLPFAScreenMask, CGDisplayIDToOpenGLDisplayMask(kCGDirectMainDisplay), (NSOpenGLPixelFormatAttribute) 0 }; _pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes]; if (!_pixelFormat) { return nil; } //_pixelFormat = [format retain]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_surfaceNeedsUpdate:) name:NSViewGlobalFrameDidChangeNotification object:self]; _openGLContext = [self openGLContext]; client_init(1280, 720, win, "192.168.0.98", 8000, 2222); } return self; </code></pre> <p>}</p> <p>client_init code</p> <pre><code> // pthread_create(&amp;posixThreadID, NULL, (void*(*)(void*))ShowThread, dh_tmp); pthread_create(&amp;posixThreadID, NULL, (void*(*)(void*))ShowThread, NULL); void* ShowThread(struct drawhandle * dh){ //glViewport(0, 0, dh-&gt;swidth, dh-&gt;sheight);//EXT_BAD_ACCESS glViewport(0, 0, 1280, 720);//EXT_BAD_ACCESS glMatrixMode(GL_PROJECTION); glLoadIdentity(); //gluOrtho2D(0, dh-&gt;swidth, 0, dh-&gt;sheight); gluOrtho2D(0, 1280, 0, 720); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); ... return 0; } </code></pre> <p>I think the problem is? that uncreated context opengl.</p> <p>How to create it in macos / linux?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload