User avatar
PeterO
Posts: 5892
Joined: Sun Jul 22, 2012 4:14 pm

Example Code

Thu Feb 14, 2013 8:29 pm

I've put a simple(ish) example on my web site: http://www.peteronion.org.uk/OpenGLES/C-openGLES.1.tgz

There's a CMakeLists.txt file included so you'll need the cmake package installed to rebuild(*) the executable if you want to change anything,

Please report any problems here.

PeterO

(*) In the C-openGLES directory run "cmake ." then "make"
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

User avatar
panik
Posts: 369
Joined: Fri Sep 23, 2011 12:29 pm
Location: Netherlands

Re: Example Code

Fri Feb 15, 2013 8:49 pm

Wow, very clear and simple example. Great comments in Ex1.c. Thanks so much for sharing, PeterO.

I have a question about this code in the Draw() function:

Code: Select all

    // These will be needed later......
#if 0   
    glViewport(0,0,displayWidth,displayHeight);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glEnable(GL_DEPTH_TEST);
    glDepthMask(GL_TRUE);
    glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
#endif
It seems to me that this code is needed only once (in the InitScene() function?), not every frame. Except for glClear() maybe, but I'm not sure. And what do you mean by 'This will be needed later...'? Enabling it doesn't seem to make a difference.

Thanks again, I'm still struggling a bit to make the transition from GLES1 to GLES2, and this will certainly help.

User avatar
PeterO
Posts: 5892
Joined: Sun Jul 22, 2012 4:14 pm

Re: Example Code

Fri Feb 15, 2013 9:15 pm

I hoped someone would find it useful :D

"This will be needed later" was a note to me not to delete it. It is there in Ex1.c but isn't used. I should have take it out of Ex1.c (Infact I'll go and take it out now...... Done ;) ).
However it is used in Ex2.c which I'm writing at this moment.

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

User avatar
panik
Posts: 369
Joined: Fri Sep 23, 2011 12:29 pm
Location: Netherlands

Re: Example Code

Fri Feb 15, 2013 9:24 pm

Cool, I'll delete it too.
Looking forward to Ex2.c! :D

User avatar
PeterO
Posts: 5892
Joined: Sun Jul 22, 2012 4:14 pm

Re: Example Code

Thu Feb 28, 2013 9:42 pm

Not quite the Ex2 I intended...
http://www.peteronion.org.uk/OpenGLES/rubikCube.tgz
No user interaction yet, and source code to follow....

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

User avatar
PeterO
Posts: 5892
Joined: Sun Jul 22, 2012 4:14 pm

Re: Example Code

Sun Mar 10, 2013 3:17 pm

I've uploaded a new version of the tarball that includes all the source code.
I had lots of trouble trying to get the user controlled rotations of the cube to work, until I realised I was going about it in completely the wrong fashion......

http://www.peteronion.org.uk/OpenGLES/rubikCube.tgz

Mouse motion will rotate the cube, left and right buttons rotate the front face.
Keyboard controls: Cursor keys rotate the cube, "I" resets cube to initial position, "Q" quits, "Z" and "X" rotate the front face Note control-C will not work.

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

Return to “OpenGLES”