Replace these OpenGL features with OpenGL ES?

I am looking for the opportunity to transfer the OpenGL application to a PC and iPhone application in one Xcode project (for convenience). Therefore, if I do my best for these source files, I want to apply them for both formats and want them to be compiled for both platforms from the same project. How could I do this? Is there a way to do this in Xcode 4 or 3.25? Any help would be greatly appreciated

edit: Ok, I went this far. In general, it seems to work with Xcode 4. My only problems are these openGL / Glut features that don't work on the iPhone:

glPushAttrib( GL_DEPTH_BUFFER_BIT | GL_LIGHTING_BIT );
glPopAttrib();
glutGet(GLUT_ELAPSED_TIME);
glutSwapBuffers();

Any ideas on fixing these issues?

+3
source share
4 answers

PushAttrib/PopAttrib , , , , , .

glutGet (GLUT_ELAPSED_TIME) mach_absolute_time ( , ) [NSDate timeIntervalSinceReferenceDate] (, , 1.0 per )

glutSwapBuffers -presentRenderbuffer: EAGLContext ( , , , ).

+3

dgles, OpenGL OpenGL ES 1.x.

+2

OpenGL ES 1.0

, . ( , ..), , . PushAttrib PopAttrib , , . , . , , , , , , , . , .

, , , . .

glut just causes the system code, huh? (wglSwapBuffers, glxSwapBuffers)

Try it here eglSwapBuffers and maybe this book

Sorry, I do not have a more specific answer for you.

+2
source

this lack of seemingly simple attribute pushing functionality is very annoying, but you can use glGetto to get the state of something before you set the parameter, how it worked for me:

Boolean tmpB;
int tmpSrc,tmpDst;

glGetBooleanv(GL_BLEND,&tmpB);
glGetIntegerv(GL_BLEND_SRC_ALPHA,&tmpSrc);
glGetIntegerv(GL_BLEND_DST_ALPHA,&tmpDst);    


glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//draw rectangle
CGSize winSize=[[CCDirector sharedDirector] winSize];
CGPoint vertices[] = { ccp(0,0), ccp(winSize.width,0), ccp(winSize.width,20), ccp(0,20) };
glColor4ub(255, 0, 255, 55);
ccFillPoly( vertices, 4, YES);


if(!tmpB)
    glDisable(GL_BLEND);

glBlendFunc(tmpSrc, tmpDst);
+1
source

Source: https://habr.com/ru/post/1784723/


All Articles