Errors, errors, and more errors..the kicker->theyre Run-t

Ok. I’m trying to encapsulate all of my EGL code into an EGLInterface class. Just when I think I’ve got it working, I have a complete crash when I run the app. The form caption changes to the name of my app, and then it changes back to “File Explorer”, so I know that the window is being created, but it’s being destroyed right after windows registers the class. I’m thinking that I passed a pointer to a function when I shouldn’t have, or vise versa, but nothing jumps out at me as being wrong. I’m planning on making this publicly available when I get it finished anyway, so I’ll just post the entire project in here. …NOTE: If you are hoping to be able to use this code AS IS, remember that it is currently BROKEN. When I get it fixed, I’ll get you a working copy. I’m really just trying to create an “OpenGL | ES shell” that replaces the broken code that I generated using the ug library :evil:

edit Ok…I’ve looked and looked and looked and I still can’t find what caused this problem. Could someone please help?

SOURCE

Render.cpp


#include <stdio.h>
#include "render.h"
#include <stdlib.h>



GLuint	texture1 = 0;
bool	result = false; 


extern	HWND	g_hWnd;
extern	HDC		g_hDC;
extern	bool	drawInOrtho;

EGLInterface	*egl;
//--------------------------------------------------------




//--------------------------------------------------------

bool	InitOGLES()
{
	
	
	if(!CreateEGLInterface(egl))
	{
		MessageBox(NULL, L"Error setting up EGL", L"Error", MB_OK | MB_ICONINFORMATION);
		return false;
	}
	egl->Initialize(g_hDC);

	//Interface is set up.
	//Set OpenGL properties

	glClearColorx(0,0,0,0);
	glShadeModel(GL_SMOOTH);
	glEnable(GL_DEPTH_TEST);
	glEnable(GL_CULL_FACE);

	RECT r;
	GetWindowRect(g_hWnd, &r);
	glViewport(r.left, r.top, r.right-r.left, r.bottom-r.top);
	SetOrtho();



	return true;

}
//--------------------------------------------------------



//--------------------------------------------------------

void	Render()
{
	static int rotation = 0;

	GLshort	vertexArray[9]	=	{-25, -25, 0,	25,-25,0,	0,25,0};
	GLubyte	colorArray[12]	=	{255,0,0,0,		0,255,0,0,	0,0,255,0};
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glLoadIdentity();

	//Test render crap.  It'll display a spinning triangle *borrowed* from TyphoonLabs tut1.  
	//(If you're reading this code hoping that you can learn OGLES from it, you should really look them up.
	// wonderful, detailed tutorials. http://www.typhoonlabs.com/index.php?action=developer.htm
	glTranslatex(0, 0, FixedFromInt(-10));
	glRotatex(FixedFromInt(rotation++), 0, ONE, 0);
	glEnableClientState(GL_VERTEX_ARRAY);
	glVertexPointer(3, GL_SHORT, 0, vertexArray);
	glEnableClientState(GL_COLOR_ARRAY);
	glColorPointer(4, GL_UNSIGNED_BYTE, 0, colorArray);
	glDrawArrays(GL_TRIANGLES, 0, 3);
	glDisableClientState(GL_VERTEX_ARRAY);
	glDisableClientState(GL_COLOR_ARRAY);
	
	egl->SwitchBuffers();

	
}
//------------------------------------------------------------------------
bool	CreateEGLInterface(EGLInterface *egl)
{
	egl = EGLInterface::Instance();
	if(!egl)	return false;

	return true;
}
void	Perspective(GLfloat fovy, GLfloat aspect, GLfloat zNear, GLfloat zFar)
{
	GLfixed xmin, xmax, ymin, ymax, aspectFixed, znearFixed;

	aspectFixed = FixedFromFloat(aspect);
	znearFixed	= FixedFromFloat(zNear);

	ymax	=	MultiplyFixed(znearFixed, FixedFromFloat((GLfloat)tan(fovy * 3.1415962f / 360.0f)));
	ymin = -ymax;

	xmin = MultiplyFixed(ymin, aspectFixed);
	xmax = MultiplyFixed(ymax, aspectFixed);
	glFrustumx(xmin, xmax, ymin, ymax, znearFixed, FixedFromFloat(zFar));
}
//------------------------------------------------------------------------
void	SetOrtho()
{
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glOrthox(	FixedFromInt(-20),	FixedFromInt(-20),
				FixedFromInt(-20),	FixedFromInt(-20),
				FixedFromInt(-20),	FixedFromInt(-20));
	glMatrixMode(GL_MODELVIEW);
	SetWindowText(g_hWnd, L"OpenGLES ortho");
}
//------------------------------------------------------------------------
void	SetPerspective()
{
	RECT r;
	GetWindowRect(g_hWnd, &r);
	float ratio = (float)(r.right-r.left)/(r.bottom - r.top);
	
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();

	Perspective(45.0f, ratio, 1.0f, 40.0f);
	glMatrixMode(GL_MODELVIEW);
	SetWindowText(g_hWnd, L"OpenGLES perspective");
}

//------------------------------------------------------------------------
void	Clean()
{
	egl->Clean();
}
//------------------------------------------------------------------------
bool	LoadTextureTGA10(const char *filename, GLuint	*id)
{
	FILE *file	= fopen(filename, "rb");
	GLubyte *pixels = NULL;
	if(!file){return false;}

	WORD	width = 0, height = 0;
	byte	headerLength = 0;
	byte	imageType	= 0;
	byte	bits		= 0;
	int		format		= 0;
	int		lineWidth	= 0;

	
	
	//targa file format dt10
	/*
			--------------------------------------------------------------------------------
				DATA TYPE 10:  Run Length Encoded, RGB images.                                 |
				_______________________________________________________________________________|
				| Offset | Length |                     Description                            |
				|--------|--------|------------------------------------------------------------|
				|--------|--------|------------------------------------------------------------|
				|    0   |     1  |  Number of Characters in Identification Field.             |
				|        |        |                                                            |
				|        |        |  This field is a one-byte unsigned integer, specifying     |
				|        |        |  the length of the Image Identification Field.  Its range  |
				|        |        |  is 0 to 255.  A value of 0 means that no Image            |
				|        |        |  Identification Field is included.                         |
				|        |        |                                                            |
				|--------|--------|------------------------------------------------------------|
				|    1   |     1  |  Color Map Type.                                           |
				|        |        |                                                            |
				|        |        |  This field contains either 0 or 1.  0 means no color map  |
				|        |        |  is included.  1 means a color map is included, but since  |
				|        |        |  this is an unmapped image it is usually ignored.  TIPS    |
				|        |        |  ( a Targa paint system ) will set the border color        |
				|        |        |  the first map color if it is present.  Wowie zowie.       |
				|        |        |                                                            |
				|--------|--------|------------------------------------------------------------|
				|    2   |     1  |  Image Type Code.                                          |
				|        |        |                                                            |
				|        |        |  Binary 10 for this type of image.                         |
				|        |        |                                                            |
				|--------|--------|------------------------------------------------------------|
				|    3   |     5  |  Color Map Specification.                                  |
				|        |        |                                                            |
				|        |        |  Ignored if Color Map Type is 0; otherwise, interpreted    |
				|        |        |  as follows:                                               |
				|        |        |                                                            |
				|    3   |     2  |  Color Map Origin.                                         |
				|        |        |  Integer ( lo-hi ) index of first color map entry.         |
				|        |        |                                                            |
				|    5   |     2  |  Color Map Length.                                         |
				|        |        |  Integer ( lo-hi ) count of color map entries.             |
				|        |        |                                                            |
				|    7   |     1  |  Color Map Entry Size.                                     |
				|        |        |  Number of bits in color map entry.  This value is 16 for  |
				|        |        |  the Targa 16, 24 for the Targa 24, 32 for the Targa 32.   |
				|        |        |                                                            |
				|--------|--------|------------------------------------------------------------|
				|    8   |    10  |  Image Specification.                                      |
				|        |        |                                                            |
				|    8   |     2  |  X Origin of Image.                                        |
				|        |        |  Integer ( lo-hi ) X coordinate of the lower left corner   |
				|        |        |  of the image.                                             |
				|        |        |                                                            |
				|   10   |     2  |  Y Origin of Image.                                        |
				|        |        |  Integer ( lo-hi ) Y coordinate of the lower left corner   |
				|        |        |  of the image.                                             |
				|        |        |                                                            |
				|   12   |     2  |  Width of Image.                                           |
				|        |        |  Integer ( lo-hi ) width of the image in pixels.           |
				|        |        |                                                            |
				|   14   |     2  |  Height of Image.                                          |
				|        |        |  Integer ( lo-hi ) height of the image in pixels.          |
				|        |        |                                                            |
				|   16   |     1  |  Image Pixel Size.                                         |
				|        |        |  Number of bits in a pixel.  This is 16 for Targa 16,      |
				|        |        |  24 for Targa 24, and .... well, you get the idea.         |
				|        |        |                                                            |
				|   17   |     1  |  Image Descriptor Byte.                                    |
				|        |        |  Bits 3-0 - number of attribute bits associated with each  |
				|        |        |             pixel.  For the Targa 16, this would be 0 or   |
				|        |        |             1.  For the Targa 24, it should be 0.  For the |
				|        |        |             Targa 32, it should be 8.                      |
				|        |        |  Bit 4    - reserved.  Must be set to 0.                   |
				|        |        |  Bit 5    - screen origin bit.                             |
				|        |        |             0 = Origin in lower left-hand corner.          |
				|        |        |             1 = Origin in upper left-hand corner.          |
				|        |        |             Must be 0 for Truevision images.               |
				|        |        |  Bits 7-6 - Data storage interleaving flag.                |
				|        |        |             00 = non-interleaved.                          |
				|        |        |             01 = two-way (even/odd) interleaving.          |
				|        |        |             10 = four way interleaving.                    |
				|        |        |             11 = reserved.                                 |
				|        |        |                                                            |
				|--------|--------|------------------------------------------------------------|
				|   18   | varies |  Image Identification Field.                               |
				|        |        |  Contains a free-form identification field of the length   |
				|        |        |  specified in byte 1 of the image record.  It's usually    |
				|        |        |  omitted ( length in byte 1 = 0 ), but can be up to 255    |
				|        |        |  characters.  If more identification information is        |
				|        |        |  required, it can be stored after the image data.          |
				|        |        |                                                            |
				|--------|--------|------------------------------------------------------------|
				| varies | varies |  Color map data.                                           |
				|        |        |                                                            |
				|        |        |  If the Color Map Type is 0, this field doesn't exist.     |
				|        |        |  Otherwise, just read past it to get to the image.         |
				|        |        |  The Color Map Specification, describes the size of each   |
				|        |        |  entry, and the number of entries you'll have to skip.     |
				|        |        |  Each color map entry is 2, 3, or 4 bytes.                 |
				|        |        |                                                            |
				|--------|--------|------------------------------------------------------------|
				| varies | varies |  Image Data Field.                                         |
				|        |        |                                                            |
				|        |        |  This field specifies (width) x (height) pixels.  The      |
				|        |        |  RGB color information for the pixels is stored in         |
				|        |        |  packets.  There are two types of packets:  Run-length     |
				|        |        |  encoded packets, and raw packets.  Both have a 1-byte     |
				|        |        |  header, identifying the type of packet and specifying a   |
				|        |        |  count, followed by a variable-length body.                |
				|        |        |  The high-order bit of the header is "1" for the           |
				|        |        |  run length packet, and "0" for the raw packet.            |
				|        |        |                                                            |
				|        |        |  For the run-length packet, the header consists of:        |
				|        |        |      __________________________________________________    |
				|        |        |      | 1 bit |   7 bit repetition count minus 1.      |    |
				|        |        |      |   ID  |   Since the maximum value of this      |    |
				|        |        |      |       |   field is 127, the largest possible   |    |
				|        |        |      |       |   run size would be 128.               |    |
				|        |        |      |-------|----------------------------------------|    |
				|        |        |      |   1   |  C     C     C     C     C     C    C  |    |
				|        |        |      --------------------------------------------------    |
				|        |        |                                                            |
				|        |        |  For the raw packet, the header consists of:               |
				|        |        |      __________________________________________________    |
				|        |        |      | 1 bit |   7 bit number of pixels minus 1.      |    |
				|        |        |      |   ID  |   Since the maximum value of this      |    |
				|        |        |      |       |   field is 127, there can never be     |    |
				|        |        |      |       |   more than 128 pixels per packet.     |    |
				|        |        |      |-------|----------------------------------------|    |
				|        |        |      |   0   |  N     N     N     N     N     N    N  |    |
				|        |        |      --------------------------------------------------    |
				|        |        |                                                            |
				|        |        |                                                            |
				|        |        |  For the run length packet, the header is followed by      |
				|        |        |  a single color value, which is assumed to be repeated     |
				|        |        |  the number of times specified in the header.  The         |
				|        |        |  packet may cross scan lines ( begin on one line and end   |
				|        |        |  on the next ).                                            |
				|        |        |                                                            |
				|        |        |  For the raw packet, the header is followed by             |
				|        |        |  the number of color values specified in the header.       |
				|        |        |                                                            |
				|        |        |  The color entries themselves are two bytes, three bytes,  |
				|        |        |  or four bytes ( for Targa 16, 24, and 32 ), and are       |
				|        |        |  broken down as follows:                                   |
				|        |        |                                                            |
				|        |        |  The 2 byte entry -                                        |
				|        |        |  ARRRRRGG GGGBBBBB, where each letter represents a bit.    |
				|        |        |  But, because of the lo-hi storage order, the first byte   |
				|        |        |  coming from the file will actually be GGGBBBBB, and the   |
				|        |        |  second will be ARRRRRGG. "A" represents an attribute bit. |
				|        |        |                                                            |
				|        |        |  The 3 byte entry contains 1 byte each of blue, green,     |
				|        |        |  and red.                                                  |
				|        |        |                                                            |
				|        |        |  The 4 byte entry contains 1 byte each of blue, green,     |
				|        |        |  red, and attribute.  For faster speed (because of the     |
				|        |        |  hardware of the Targa board itself), Targa 24 image are   |
				|        |        |  sometimes stored as Targa 32 images.                      |
				|        |        |                                                            |
				--------------------------------------------------------------------------------
*/
	
	//1.need the length of the Image Identification Field
	//2.*skip color map*
	//3.need imageType
	//4.*not doing color mapping.  Skip color map info*
	//5.Image specification.  need width, height, bits out of this memory block
	fread(&headerLength, sizeof(byte), 1, file);
	//skip the next byte
	fseek(file, 1, SEEK_CUR);
	//read in imageType (RLE, RGB, etc)
	fread(&imageType, sizeof(byte), 1, file);

	fseek(file, 9, SEEK_CUR);

	//width, height, and color bit depth are 
	fread(&width,	sizeof(WORD),	1,	file);
	fread(&height,	sizeof(WORD),	1,	file);
	fread(&bits,	sizeof(byte),	1,	file);
	//move file pointer to pixel data
	fseek(file, headerLength + 1, SEEK_CUR);

	if(imageType != 10)
	{
		if(bits == 24)
		{
			format = bits >> 3;
			lineWidth = format * width;
			pixels	=	new GLubyte[lineWidth * height];
			//load pixel data line by line
			for(int i = 0; i < height; i++)
			{
				GLubyte	*line	=	&(pixels[lineWidth * i]);
				fread(line, lineWidth, 1, file);

				//TGA stores color in BRG format.
				for(int x = 0; x < lineWidth; x++)
				{
					int temp = line[x];
					line[x] = line[x+2];
					line[x+2] = temp;
				}
			}

		}
		else
		{
			fclose(file);
			*id = 0;
			return false;
		}
	}
	fclose(file);
	glGenTextures(1, id);
	glBindTexture(GL_TEXTURE_2D, *id);
	glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,	GL_NEAREST);
	glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,	GL_NEAREST);
	glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,		GL_REPEAT);
	glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,		GL_REPEAT);

	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, pixels);

	//copy in main memory is no longer needed
	delete [] pixels;
	return true;

}

myfile.cpp


#include "myfile.h"

myfile::myfile()
{

}
myfile::~myfile()
{
}

void myfile::setFileLocation(char *filename)
{
	myfile::texFilename = filename;
	TCHAR path[256];
	GetModuleFileName(NULL, path, 256);
	TCHAR *pos = wcsrchr(path, '\\');
	*(pos + 1) = '\0';
	wcstombs(myfile::fullPath, path, 256);
	strcat(myfile::fullPath, filename);
}
const char* myfile::FileName()
{
	return myfile::texFilename;
}

mainES.cpp


#include "mainES.h"
#include "render.h"

HINSTANCE	g_hInstance;
HWND		g_hWnd;
HDC			g_hDC;




//Window vars
TCHAR		szAppName[]	=	L"Kips OpenGLES";

bool drawInOrtho = true;
bool keyPressed[256];


int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
	MSG			msg;
	WNDCLASS	windowClass;
	g_hInstance = hInstance;

	bool done = false;

	if(g_hWnd = FindWindow(szAppName, szAppName))
	{
		SetForegroundWindow((HWND)((ULONG) g_hWnd | 0x00000001));
		return 0;
	}

	windowClass.style			= CS_HREDRAW | CS_VREDRAW;
	windowClass.lpfnWndProc		= (WNDPROC) WndProc; //function pointer
	windowClass.cbClsExtra		= 0;
	windowClass.cbWndExtra		= 0;
	windowClass.hInstance		= hInstance;
	windowClass.hIcon			= NULL;
	windowClass.hCursor			= LoadCursor(NULL, IDC_ARROW);
	windowClass.hbrBackground	= 0;
	windowClass.lpszClassName	= szAppName;
	windowClass.lpszMenuName	= NULL;

	if(!RegisterClass(&windowClass))
	{
		return false;
	}

	g_hWnd = CreateWindow(szAppName,
						szAppName,
						WS_VISIBLE,
						CW_USEDEFAULT, CW_USEDEFAULT,
						CW_USEDEFAULT, CW_USEDEFAULT,
						NULL, NULL,
						g_hInstance, NULL);

	if(!g_hWnd)	return false;
	
	//********************
	if(!InitOGLES())	return false;
	//********************

	SetWindowText(g_hWnd, L"OpenGLES ortho");
	ShowWindow(g_hWnd, nCmdShow);
	UpdateWindow(g_hWnd);


	while(!done)
	{
		if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
		{
			if(msg.message == WM_QUIT)
			{
				done = true;
			}
			else
			{
				if(keyPressed[VK_UP])
				{
					MessageBox(g_hWnd, L"Up Pushed", L"Button Press", MB_OK | MB_ICONINFORMATION);
					
				}
				else
				{
					TranslateMessage(&msg);
					DispatchMessage(&msg);
				}
			}
		}
		else
		{
			//***************
			Render();
			//***************
		}
	}
	Clean();
	DestroyWindow(g_hWnd);
	UnregisterClass(szAppName, g_hInstance);
	return 0;
}

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{

	switch(message)
	{
	case WM_PAINT:
		ValidateRect(g_hWnd, NULL);
		return 0;

	case WM_DESTROY:
		PostQuitMessage(0);
		return 0;

	case WM_KEYDOWN:
		keyPressed[wParam] = true;
		return 0;

	case WM_KEYUP:
		keyPressed[wParam] = false;
		return 0;
		
	};
	return DefWindowProc(hWnd, message, wParam, lParam);
}

EGLInterface.cpp [ I presume the error is in here]


#include "EGLInterface.h"

EGLInterface	*EGLInterface::m_instance	= NULL;
EGLDisplay		 glesDisplay	= EGL_NO_DISPLAY;
EGLSurface		 glesSurface	= EGL_NO_SURFACE;
EGLContext		 glesContext	= EGL_NO_CONTEXT;
				 EGLint			 configAttribs[]	= {
														EGL_ALPHA_SIZE,	0,
														EGL_RED_SIZE,	8,
														EGL_GREEN_SIZE,	8,
														EGL_BLUE_SIZE,	8,
														EGL_DEPTH_SIZE,	24,
														EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
														EGL_NONE
														};	

EGLint			matchingConfigs;
EGLConfig		configs[10];
extern HWND	g_hWnd;



//--------------------------------------------------------------
EGLInterface::~EGLInterface()
{
	m_instance = NULL;
}
//--------------------------------------------------------------
EGLInterface	*EGLInterface::Instance()
{
	if(!m_instance)
	{
		m_instance = new EGLInterface();
	}
	return m_instance;
}
//--------------------------------------------------------------
bool	EGLInterface::Initialize(HDC hDC)
{
	//I'll change these to throw errors later.  Just want to get this working
	if(!	EGLInterface::GetDisplay(hDC)			)	return false;
	if(!	EGLInterface::Initialize(glesDisplay)	)	return false;
	if(!	EGLInterface::ChooseConfig()			)	return false;
	if(!	EGLInterface::CreateWindowSurface()		)	return false;
	if(!	EGLInterface::CreateContext()			)	return false;
	if(!	EGLInterface::MakeCurrent()				)	return false;


	return true;
	
}
//--------------------------------------------------------------
bool	EGLInterface::GetDisplay(HDC hDC)
{
	glesDisplay = eglGetDisplay(hDC);
	if(glesDisplay == EGL_NO_DISPLAY || eglGetError()	!=	EGL_SUCCESS)	return false;

	return true;
}
//--------------------------------------------------------------
bool	EGLInterface::Initialize(EGLDisplay glesDisplay)
{
	if(eglInitialize(glesDisplay, NULL, NULL) ==EGL_FALSE || eglGetError()	!= EGL_SUCCESS)		return false;

	return true;
}
//--------------------------------------------------------------
bool	EGLInterface::ChooseConfig()
{
	if(!eglChooseConfig(glesDisplay, configAttribs, &configs[0], 10, &matchingConfigs)) return false;

	return true;
}
//--------------------------------------------------------------
bool	EGLInterface::CreateWindowSurface()
{
	glesSurface = eglCreateWindowSurface(glesDisplay, configs[0], g_hWnd, configAttribs);
	if(glesSurface == EGL_NO_SURFACE || eglGetError()	!= EGL_SUCCESS)	return false;

	return true;
}
//--------------------------------------------------------------
bool	EGLInterface::CreateContext()
{
	glesContext = eglCreateContext(glesDisplay, configs[0], 0, configAttribs);
	if(glesContext == EGL_NO_CONTEXT || eglGetError()	!= EGL_SUCCESS)	return false;

	return true;
}
//--------------------------------------------------------------
bool	EGLInterface::MakeCurrent()
{
	if(eglMakeCurrent(glesDisplay, glesSurface, glesSurface, glesContext)== EGL_FALSE || eglGetError() != EGL_SUCCESS) return false;

	return true;
}
//--------------------------------------------------------------
void	EGLInterface::SwitchBuffers()
{
	eglSwapBuffers(glesDisplay, glesSurface);
}
//--------------------------------------------------------------
void	EGLInterface::Clean()
{
	if(glesDisplay)
	{
		eglMakeCurrent(glesDisplay, NULL, NULL, NULL);
		if(glesContext)	eglDestroyContext(glesDisplay, glesContext);
		if(glesSurface)	eglDestroySurface(glesDisplay, glesSurface);
		eglTerminate(glesDisplay);
	}
}

drawingobjects.cpp [not used yet. Just threw it in anyway]


//////////////////////////////////////////////////////
//													   ¦
//drawing objects									   ¦
//													   ¦
//_____________________________________________________¦

#include <GLES/gl.h>
GLfloat box[] = {
	//FRONT FACE
		-0.5f, -0.5f, 0.5f,
		 0.5f, -0.5f, 0.5f,
		-0.5f,  0.5f, 0.5f,
		 0.5f,  0.5f, 0.5f,
	//BACK FACE
		-0.5f, -0.5f, -0.5f,
		-0.5f,  0.5f, -0.5f,
		 0.5f, -0.5f, -0.5f,
		 0.5f,  0.5f, -0.5f,
	//LEFT FACE
		-0.5f, -0.5f,  0.5f,
		-0.5f,  0.5f,  0.5f,
		-0.5f, -0.5f, -0.5f,
		-0.5f,  0.5f, -0.5f,
	//RIGHT FACE
		 0.5f, -0.5f, -0.5f,
		 0.5f,  0.5f, -0.5f,
		 0.5f, -0.5f,  0.5f,
		 0.5f,  0.5f,  0.5f,
	//TOP FACE
		-0.5f,  0.5f,  0.5f,
		 0.5f,	0.5f,  0.5f,
		-0.5f,	0.5f, -0.5f,
		 0.5f,  0.5f, -0.5f,
	//BOTTOM FACE
		-0.5f, -0.5f,  0.5f,
		-0.5f, -0.5f, -0.5f,
		 0.5f, -0.5f,  0.5f,
		 0.5f, -0.5f, -0.5f
		 
};

GLfloat texCoords[] = {
		//FRONT
		0.0f, 0.0f,
		1.0f, 0.0f,
		0.0f, 1.0f,
		1.0f, 1.0f,
		//BACK
		1.0f, 0.0f,
		1.0f, 1.0f,
		0.0f, 0.0f,
		0.0f, 1.0f,
		//LEFT
		1.0f, 0.0f,
		1.0f, 1.0f,
		0.0f, 0.0f,
		0.0f, 1.0f,
		//RIGHT
		1.0f, 0.0f,
		1.0f, 1.0f,
		0.0f, 0.0f,
		0.0f, 1.0f,
		//TOP
		0.0f, 0.0f,
		1.0f, 0.0f,
		0.0f, 1.0f,
		1.0f, 1.0f,
		//BOTTOM
		1.0f, 0.0f,
		1.0f, 1.0f,
		0.0f, 0.0f,
		0.0f, 1.0f

};


float lightAmbient[]	= {0.8f, 0.8f, 0.8f, 1.0f};
float lightDiffuse[]	= {0.0f, 0.0f, 0.0f, 1.0f};
float lightSpecular[]	= {1.0f, 0.0f, 0.0f, 1.0f};


float matAmbient[]		= {0.8f, 0.8f, 0.8f, 0.8f};
float matDiffuse[]		= {1.0f, 1.0f, 1.0f, 1.0f};
float matSpecular[]		= {1.0f, 1.0f, 1.0f, 1.0f};


float lightRed[]		= {1.0f, 0.5f, 0.5f, 1.0f};
float lightGreen[]		= {0.5f, 1.0f, 0.5f, 1.0f};
float lightBlue[]		= {0.5f, 0.5f, 1.0f, 1.0f};
float lightYellow[]		= {1.0f, 1.0f, 0.5f, 1.0f};
float lightPurple[]		= {1.0f, 0.5f, 1.0f, 1.0f};
float lightCyan[]		= {0.5f, 1.0f, 1.0f, 1.0f};
float lightOrange[]		= {1.0f, 0.5f, 0.15f, 1.0f};


float lightPosition[]	= {2.0f, 2.0f, 3.0f, 0.0f};

HEADERS:

render.h


#ifndef RENDER_H
#define RENDER_H

#include <windows.h>
#include "myfile.h"
#include <GLES/gl.h>
#include <GLES/egl.h>
#include "EGLInterface.h"

const unsigned int PRECISION = 16;
const GLfixed ONE = 1 << PRECISION;
const GLfixed ZERO = 0;

inline GLfixed	FixedFromInt(int value) {return value << PRECISION;};
inline GLfixed	FixedFromFloat(float value){return static_cast<GLfixed> (value * static_cast<float>(ONE));};
inline GLfixed	MultiplyFixed(GLfixed op1, GLfixed op2){return (op1 * op2) >> PRECISION;};

bool	InitOGLES();
void	Render();
void	SetOrtho();
bool	CreateEGLInterface(EGLInterface *eglInterface);
void	SetPerspective();
bool	LoadTextureTGA10(const char *filename, GLuint	*id);

void	Perspective	(GLfloat fovy, GLfloat aspect, GLfloat zNear, GLfloat zFar);
void	Clean();
#endif

myfile.h


#ifndef MYFILE_H
#define MYFILE_H


#include <windows.h>
#include <stdlib.h>

class myfile
{

	const char * texFilename;
public:
	myfile();
	~myfile();
	void setFileLocation(char *filename);
	char	fullPath[256];
	const char * FileName();
};

#endif

mainES.h


#ifndef MAINES_H
#define MAINES_H

#include <windows.h>


int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow);
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);

#endif

EGLInterface.h



#include <GLES/egl.h>
#include <GLES/gl.h>
#include <GLES/egltypes.h>

class EGLInterface
{
	//anything without an access modifier is automatically given the access level of private.  These are all private fields.  
	//I use the "public" and "private" accessors for function declarations.  
	//Any public field will be located under the "public:" accessor
	
public:
	
	
							~EGLInterface();
	static	EGLInterface	*Instance();
			bool			Initialize(HDC);
			bool			CreateWindowSurface();
			void			SwitchBuffers();
			void			Clean();
	

private:
	
							EGLInterface()	{};
	static	EGLInterface	*m_instance;
			bool			GetDisplay(HDC private_HDC);
			bool			Initialize(EGLDisplay private_EGLDisplay);
			bool			ChooseConfig();
			bool			CreateContext();
			bool			MakeCurrent();
			


		EGLDisplay		glesDisplay;
		EGLSurface		glesSurface;
		EGLContext		glesContext;

	EGLConfig		configs[10];
	EGLint			matchingConfigs;
		EGLint			configAttribs[25]; 
	


	
};

#endif

…I won’t include the egl and gl resource files. You’ve already got them.
…Anyway, my EGLInterface seems to be causing the error. The code was working before I gutted the EGL stuff and decided to throw it in its own class.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.