Nougash
Posts: 2
Joined: Mon Jan 28, 2013 4:30 am

OpenGLES 1.1 problem

Mon Jan 28, 2013 5:21 am

Hello!

I've recently been trying to get started with GLES and created a project, following the Jon's Teapot tutorial. I managed to get a window created without a problem. I have since tried to draw a simple vertex array to test it out and so far I don't get any primitives rendered, just the same window; it is glClearColor'd so I guess GL is functioning somewhat. My inherited window looks like this:

#include "MyWindow.h"
#include <iostream>
#include <stdlib.h>
#include <GLES/gl.h>
#include <GLES/glext.h>

GLfloat square[] = {0.25, 0.25, 0.0,
0.75, 0.25, 0.0,
0.25, 0.75, 0.0, //global for quick test
0.75, 0.75, 0.0};




void MyWindow :: initGL()
{
glClearColor(0.0f,0.0f,0.0f,0.5f); //initialising clear colour

glMatrixMode(GL_PROJECTION);
glLoadIdentity();

glOrthof(0.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

glVertexPointer(3, GL_FLOAT, 0, square); //point to vert array
glEnableClientState(GL_VERTEX_ARRAY); //enable vert array
}

void MyWindow ::display()
{
glClearColor(1.0f,0.0f,0.0f,1.0f); //setting clear colour
glClear( GL_COLOR_BUFFER_BIT);


glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);


swapBuffers();

}

I've tried adding extra gl commands (viewport, cull-face etc.) but none seem to do the trick, the current vertex array and ortho projection is from an example after thinking mine was wrong. I've been reading for the past few hours trying to find similar issues, I came across something about conflicting gl libraries, but I only have the .a and .so files of libEGL and libGLESv1, as well as the lib for bcm_host (I'm very new to Linux stuff!) linked into Code::Blocks IDE.
I could be missing something incredibly obvious but I've been looking at it so long now I'm not sure! Any advice would be appreciated; I'm hoping it's at least an interesting problem.

-rst-
Posts: 1316
Joined: Thu Nov 01, 2012 12:12 pm
Location: Dublin, Ireland

Re: OpenGLES 1.1 problem

Mon Jan 28, 2013 3:08 pm

I have really no idea about OpenGL (yet), but wouldn't you need to set the shading model (glShadeModel() - maybe GL_FLAT to begin with) and assign the draw color (glEnableClientState( GL_COLOR_ARRAY ); glColorPointer(4, GL_FLOAT, 0, <colors>);) or a texture (glBindTexture())?
http://raspberrycompote.blogspot.com/ - Low-level graphics and 'Coding Gold Dust'

Nougash
Posts: 2
Joined: Mon Jan 28, 2013 4:30 am

Re: OpenGLES 1.1 problem

Tue Jan 29, 2013 3:01 pm

I've tried setting the shade model and sending a colour array, I moved them out of my example code because the calls in that example should produce a default white primitive.

Return to “OpenGLES”