Hi Edge,
I'm trying to render a simple 3d object using the OpenGL ES library. I couldn't find examples of using the Edgelib 3d Rendering engine so I decided to try OpenGL ES Rasteroid in the end.
When the program opens on my WM2003 device the screen is blank. I have declared the E3DSurface as a member variable and have done the following :
- Created the 3D surface.
- Set it's Polygons and Vertices
- Set the Vertice colours
- Set the Normal
- Set texture co-ordinates (Probably not required as I'm not binding or uploading any texture to the 3D surface.)
- Set Perspective 3D
- Set Shading
- Set the camera to be a certain distance away from the 3D model
- Set light source
- Render the 3d Model
This program compiles with no errors and opens up on my WM2003 device but all that shows is a black background.
Here is my Code :
Here is my Entry CPP file
Any help would be appreciated thanks!
Regards,
Slither2006.
I'm trying to render a simple 3d object using the OpenGL ES library. I couldn't find examples of using the Edgelib 3d Rendering engine so I decided to try OpenGL ES Rasteroid in the end.
When the program opens on my WM2003 device the screen is blank. I have declared the E3DSurface as a member variable and have done the following :
- Created the 3D surface.
- Set it's Polygons and Vertices
- Set the Vertice colours
- Set the Normal
- Set texture co-ordinates (Probably not required as I'm not binding or uploading any texture to the 3D surface.)
- Set Perspective 3D
- Set Shading
- Set the camera to be a certain distance away from the 3D model
- Set light source
- Render the 3d Model
This program compiles with no errors and opens up on my WM2003 device but all that shows is a black background.
Here is my Code :
- Code:
ERESULT ClassMain::OnDisplayInit(ENATIVETYPE instance, ClassEDisplay *display)
{
//Create 3D surface
display->CreateSurface(&es3dRectangle;, 4, 2);
//Set Vertex's and Polygons
es3dRectangle.SetPolygon(0, 0, 2, 1);
es3dRectangle.SetPolygon(1, 1, 2, 3);
es3dRectangle.SetVertex(0, -2048, -2048, 0); es3dRectangle.SetColor(0, E_RGBA(255, 0, 0, 255)); es3dRectangle.SetNormal(0, 0, 0, 127);//tl
es3dRectangle.SetVertex(1, 2048, -2048, 0); es3dRectangle.SetColor(1, E_RGBA(255, 0, 0, 255)); es3dRectangle.SetNormal(1, 0, 0, 127);//tr
es3dRectangle.SetVertex(2, -2560, 2048, 0); es3dRectangle.SetColor(2, E_RGBA(255, 0, 0, 255)); es3dRectangle.SetNormal(2, 0, 0, 127);//bl
es3dRectangle.SetVertex(3, 2560, 2048, 0); es3dRectangle.SetColor(3, E_RGBA(255, 0, 0, 255)); es3dRectangle.SetNormal(3, 0, 0, 127);//br
//Set Texture Co-Ordinates
es3dRectangle.SetTexCoord(0, 0, 0);
es3dRectangle.SetTexCoord(1, 0, 65536);
es3dRectangle.SetTexCoord(2, 65536, 0);
es3dRectangle.SetTexCoord(3, 65536, 65536);
return(E_OK);
}
ERESULT ClassMain::OnNextFrame(ClassEDisplay *display, unsigned long timedelta)
{
//Set 3D perspective, Camera position and shading.
display->Perspective3D(display->GetWidth(), display->GetHeight());
display->SetShading(E3D_GOURAUD);
display->WorldReset();
display->WorldTranslate(0, 0, -6000);
//Set lighting
display->SetLightSource(0, 4096, 4096, 4096, ECOLOR_WHITE, E_RGBX(32, 32, 32));
display->UseLight(0);
//Render 3D Model
display->Render(&es3dRectangle;);
}
Here is my Entry CPP file
- Code:
/////////////////////////////////////////////////////////////////////
// Code/view3d.cpp
// One of the Edge samples
// Shows how to create a 3D model manually and how to load a .3DS
// file. Rotate the model based on input.
//
// Copyright (c) Elements Interactive B.V.
// http://www.edgelib.com
//
// Show a 3D model on the screen, rotate it with the d-pad or stylus
/////////////////////////////////////////////////////////////////////
//Use Windows Desktop OpenGL by default
#if !defined(__EDGEIDE__)
#define EGL_USEGLES
#endif
/////////////////////////////////////////////////////////////////////
// Include and link the library //
/////////////////////////////////////////////////////////////////////
//Use a GL library if an implementation has been defined in the workspace
#if defined(EGL_PC) || defined(EGL_SYMBIAN) || defined(EGL_RASTEROID) || defined(EGL_POWERVR) || defined(EGL_NVIDIA)
#define EGL_USEGL
#if !defined(EGL_PC)
#define EGL_USEGLES
#endif
#endif
//Include Edge
#include "edgemain.h"
//Link the Edge static library
#pragma comment(lib, "edge.lib")
//Include headers and link OpenGL libraries
#if defined(EGL_USEGL)
#if defined(EGL_USEGLES)
#include "GLES\\gl.h"
#include "GLES\\egl.h"
#else
#include "GL\\gl.h"
#endif
#if defined(DEVICE_WIN32)
#if defined(EGL_PC)
#pragma comment(lib, "plugingl.lib")
#else
#if defined(DEVICE_DESKTOP)
#if defined(EGL_POWERVR)
#pragma comment(lib, "pluginpowervr.lib")
#elif defined(EGL_RASTEROID)
#pragma comment(lib, "pluginrasteroid.lib")
#endif
#else
#pragma comment(lib, "plugin1-0.lib")
#endif
#endif
#if defined(EGL_PC)
#pragma comment(lib, "opengl32.lib")
#elif defined(EGL_POWERVR)
#pragma comment(lib, "libgles_cl.lib")
#elif defined(EGL_NVIDIA)
#pragma comment(lib, "libgles_cm.lib")
#elif defined(EGL_RASTEROID)
#pragma comment(lib, "libEGL.lib")
#pragma comment(lib, "libGLES_CM_NoE.lib")
#endif
#endif
#endif
//Contains ClassMain, the application framework
#include "main.h"
/////////////////////////////////////////////////////////////////////
// The program entry point //
/////////////////////////////////////////////////////////////////////
ClassEdge *EdgeMain(EDGESTARTUP *data){ return(new ClassMain); }
Any help would be appreciated thanks!
Regards,
Slither2006.