PDA

View Full Version : [REF]Write 3D Games and apps: a C#/.NET Compact Framework wrapper for OpenGLES


Koush
9th August 2008, 08:48 AM
Update 8/10:
I published a 3D game called Sensory Overload. Full source is included.
http://forum.xda-developers.com/showthread.php?p=2508955#post2508955


Initial Post 8/08
http://hosted.koushikdutta.com/OpenGLTest.png

I've been doing 3d graphics development for a while, and it's really exciting to finally own a Windows Mobile device that has hardware acceleration.
I'm also primarily a managed developer, and I know a lot of people are in the same boat. If you're looking to access the 3d hardware acceleration of the HTC Touch Diamond, then you will be interested in this managed library for OpenGL (http://www.koushikdutta.com/2008/08/net-compact-framework-wrapper-for.html). The download includes the full source for the wrapper and the sample "spinning triangle" application that goes with it.

Have fun coding, and let me know if you find any bugs!

CutePinkSox
9th August 2008, 10:01 AM
http://hosted.koushikdutta.com/OpenGLTest.png

I've been doing 3d graphics development for a while, and it's really exciting to finally own a Windows Mobile device that has hardware acceleration.
I'm also primarily a manager developer, and I know a lot of people are in the same boat. If you're looking to access the 3d hardware acceleration of the HTC Touch Diamond, then you will be interested in this managed library for OpenGL (http://www.koushikdutta.com/2008/08/net-compact-framework-wrapper-for.html). The download includes the full source for the wrapper and the sample "spinning triangle" application that goes with it.

Have fun coding, and let me know if you find any bugs!

So the rendering is done by the GPU rather than CPU - didn't think anyone accessed the hardware yet through the driver???

Koush
9th August 2008, 10:26 AM
By querying the device via D3D and OpenGL, you can verify that they are both indeed hardware accelerated. Incidentally, it was the Diamond drivers that provided a breakthrough for hackers to provide hardware acceleration for the Kaiser devices.

Menneisyys
9th August 2008, 02:05 PM
http://hosted.koushikdutta.com/OpenGLTest.png

I've been doing 3d graphics development for a while, and it's really exciting to finally own a Windows Mobile device that has hardware acceleration.
I'm also primarily a managed developer, and I know a lot of people are in the same boat. If you're looking to access the 3d hardware acceleration of the HTC Touch Diamond, then you will be interested in this managed library for OpenGL (http://www.koushikdutta.com/2008/08/net-compact-framework-wrapper-for.html). The download includes the full source for the wrapper and the sample "spinning triangle" application that goes with it.

Have fun coding, and let me know if you find any bugs!


Wowz! This is GREAT news! Want me to stick the thread?

WWWeed
9th August 2008, 02:09 PM
wow, nice work mate!!

CutePinkSox
9th August 2008, 03:02 PM
Wowz! This is GREAT news! Want me to stick the thread?

STICK IT STICK IT - lets make sure it gets alot of attention :)

Menneisyys
9th August 2008, 03:03 PM
STICK IT STICK IT - lets make sure it gets alot of attention :)

OK, I stick it. Hope the original poster will work on the project further :)

marco.catelli
9th August 2008, 03:41 PM
wow, that's really nice, I never developed graphics things and I only know a bit of vb.net but during holidays maybe I'll give a try!!! thanks and go on!

Koush
9th August 2008, 05:44 PM
OK, I stick it. Hope the original poster will work on the project further :)

Thanks! Functionally, it is a complete implementation of a way to access OpenGL through managed code. However, there are some small things I want to do to make it easier for developers to write applications for OpenGL.


Implement/port GLU
Implement/port GLUT
Change the constants that are passed into OpenGL into enums so that it makes it easier for to see a list of valid arguments in Intellisense. This will also address some of the loose typing that is typical of OpenGL.
Implement a fixed point sample that works with the Vincent 3D software implementation of OpenGL.

A_C
9th August 2008, 08:05 PM
Thanks for the great news. But how about the unmanaged way (c++)? Which header file(s) should be referenced?

Koush
9th August 2008, 08:25 PM
Thanks for the great news. But how about the unmanaged way (c++)? Which header file(s) should be referenced?

You *should* be able to use the libs and headers provided by the Vincent3D software OpenGL implementation. Just don't copy the Libgles_cm.dll to your device, or it will actually use software rendering instead. My website post has a link to that site.

You will want to link to libgles_cm.lib and just #include gl.h and egl.h.

Koush
10th August 2008, 08:34 PM
I published a 3D game called Sensory Overload. Full source is included.
http://forum.xda-developers.com/showthread.php?p=2508955#post2508955

WhistlerNL
11th August 2008, 03:32 PM
Studied on Microsoft's XNA last half year, have been wanting to try if I could use any of it on the Diamond. If not, I guess this is the next best thing atm. Thanks :)

dajudge01
11th August 2008, 06:45 PM
Played around a little bit with that and built something to load Milkshape 3D models and display them... Not too much horsepowers in the GPU though. I guess some really old-school 3D skills are required to get decent graphics out of the chip.

Is there any info on how much RAM is dedicated to the graphics chip? I wonder if things are mostly fillrate limited there or if texture count is the real impact. Maybe I'll try that later on with a number of simple but all differently textured models with loads of overdraw so the Z-Buffer can pretty much eliminate fillrate limitations to see if texture size is the real problem here. Once that is found out it shouldn't be too hard to get a little game-world up and running.

I'm thinking in the lines of a G-Sensor driven rollerball thingie for starters - a little bit like tweeter from a 3rd person perspective with some interesting levels? If that runs smoothly on the diamond it would be a real show-off kind of game :-)

The thing I haven't done before here is the physics part. Obviously you wouldn't want to run a fully fledged physics simulation (ODE comes to mind here) especially when doing it in C# - but there should be enough CPU power to handle some sphere-? collisions in a timely manner?

Cheers,
Alex

JayZee2
12th August 2008, 12:17 AM
...
I'm thinking in the lines of a G-Sensor driven rollerball thingie for starters - a little bit like tweeter from a 3rd person perspective with some interesting levels? If that runs smoothly on the diamond it would be a real show-off kind of game :-)
...


you may want to join this thread (http://forum.xda-developers.com/showthread.php?t=416582) and participate in the project

CutePinkSox
13th August 2008, 11:52 PM
Played around a little bit with that and built something to load Milkshape 3D models and display them... Not too much horsepowers in the GPU though. I guess some really old-school 3D skills are required to get decent graphics out of the chip.

Is there any info on how much RAM is dedicated to the graphics chip? I wonder if things are mostly fillrate limited there or if texture count is the real impact. Maybe I'll try that later on with a number of simple but all differently textured models with loads of overdraw so the Z-Buffer can pretty much eliminate fillrate limitations to see if texture size is the real problem here. Once that is found out it shouldn't be too hard to get a little game-world up and running.

I'm thinking in the lines of a G-Sensor driven rollerball thingie for starters - a little bit like tweeter from a 3rd person perspective with some interesting levels? If that runs smoothly on the diamond it would be a real show-off kind of game :-)

The thing I haven't done before here is the physics part. Obviously you wouldn't want to run a fully fledged physics simulation (ODE comes to mind here) especially when doing it in C# - but there should be enough CPU power to handle some sphere-? collisions in a timely manner?

Cheers,
Alex

16 MB 12 Pipe GFX Chip cannot remember where i read it...

Jin187
16th August 2008, 05:02 PM
Here are the Direct 3D Drivers from the omnia, working great on the Diamond, check it out!!

http://forum.xda-developers.com/showthread.php?t=416474

Jorlin
16th August 2008, 05:51 PM
Here are the Direct 3D Drivers from the omnia, working great on the Diamond, check it out!!

http://forum.xda-developers.com/showthread.php?t=416474

Anything that works better with these drivers installed?

Radeon123
16th August 2008, 05:58 PM
Just doing a sprite backup then I am going to try those drivers, wonder what will happen :D

TDO
16th August 2008, 06:24 PM
Anything that works better with these drivers installed?

Yes, you can read the 3d text in the demos.

But with the drivers installed they run a lot slower!

Maybe vsync enabeld/disabled.

TDO

Radeon123
16th August 2008, 06:28 PM
Yes, you can read the 3d text in the demos.

But with the drivers installed they run a lot slower!

Maybe vsync enabeld/disabled.

TDO

Same here, even the GL Benchmark seems slower, just running that test now, see what the difference is between the drivers.

Edit - Finished the test but not a lot of difference between the drivers using GL Benchmark.

Koush
16th August 2008, 09:17 PM
Here are the Direct 3D Drivers from the omnia, working great on the Diamond, check it out!!

http://forum.xda-developers.com/showthread.php?t=416474

The Diamond does not need D3D drivers; it already has it and it is hardware accelerated. The Diamond stock D3D drivers are a wrapper around OpenGL ES. I would not be surprised if the Kaiser D3D drivers were actually just a copy of the Diamond drivers.

Edit:
Misread, they're the Omnia drivers, not Kaiser. Maybe they are better, dunno, haven't looked into it.

Incidentally, Direct3D and GAPI are being removed from Windows Mobile 7. Using either of them is pretty pointless from here on out. :)

xdaking
16th August 2008, 09:27 PM
very koool finding many many thanks

Jin187
17th August 2008, 01:58 AM
The Diamond does not need D3D drivers; it already has it and it is hardware accelerated. The Diamond stock D3D drivers are a wrapper around OpenGL ES. I would not be surprised if the Kaiser D3D drivers were actually just a copy of the Diamond drivers.

Edit:
Misread, they're the Omnia drivers, not Kaiser. Maybe they are better, dunno, haven't looked into it.

Incidentally, Direct3D and GAPI are being removed from Windows Mobile 7. Using either of them is pretty pointless from here on out. :)

Hmmm, I see, just thought I'd post them here anyway just incase it could be useful for you guys.

p.s. I've noticed something quite strange, general scrolling in applications like iContacts, PCM Imageviewer, S2P(Coverflow) and opera seem faster with these drivers but video playback using coreplayer is definately slower.

uniqueboy
19th August 2008, 01:44 AM
Has anyone got any demos working yet? I mean got the diamond to draw a nice complex shaded textured moving object. Lets see em please:D

tafkatadd
19th August 2008, 03:33 AM
Hi,

Can someone please program some of the classics, like Pac-Man, Tetris and such? It can be cool to play those with the sensor...

koven
19th August 2008, 06:18 AM
rather q1,q2 maybe q3 with hardware acceleration :)

charly_mx
19th August 2008, 07:05 PM
I used to program OpenGL in my school. I havent programmed anything since then. :) Hurra for the Dedicated Graphic Chip in our Diamonds

_Edd_
24th August 2008, 11:26 AM
Update 8/10:
I published a 3D game called Sensory Overload. Full source is included.
http://forum.xda-developers.com/showthread.php?p=2508955#post2508955


Initial Post 8/08
http://hosted.koushikdutta.com/OpenGLTest.png

I've been doing 3d graphics development for a while, and it's really exciting to finally own a Windows Mobile device that has hardware acceleration.
I'm also primarily a managed developer, and I know a lot of people are in the same boat. If you're looking to access the 3d hardware acceleration of the HTC Touch Diamond, then you will be interested in this managed library for OpenGL (http://www.koushikdutta.com/2008/08/net-compact-framework-wrapper-for.html). The download includes the full source for the wrapper and the sample "spinning triangle" application that goes with it.

Have fun coding, and let me know if you find any bugs!
Hi,
I've downloaded ManagedOpenGLES.zip and I have problems running it in windows mobile sdk. It builds without errors but when I try to run it I get this exception:

http://img228.imageshack.us/img228/5990/glhz4.jpg

I've downloaded Vincent 3D and took libgles_cm.dll from it. I've put this dll to my bin folder but I still get the same error. Of course I can copy exec files directly to my device and run it from there without problems (because it does not need libgles_cm.dll) but I want it to work in sdk too. Any ideas? Thanks.

Dynomite232
26th August 2008, 02:22 AM
has anyone seen this will it work on r diamond http://ca.youtube.com/watch?v=7DikbVmYLR0&feature=related

GurneyHalleck
26th August 2008, 03:14 AM
has anyone seen this will it work on r diamond http://ca.youtube.com/watch?v=7DikbVmYLR0&feature=related

... completely OT - but it's still awesome. There's no reason that wouldn't be possible with TD, just need some enterprising soul to figure out how to do it... or wait for those guys doing the demo to release a WM version.

Radeon123
26th August 2008, 03:34 AM
Would love to see that kind of app on the Diamond to, looks amazing :)

raptorgt
26th August 2008, 11:16 AM
you can try this 3d game if you want it works great on the diamond http://htc-touch-diamond.handster.com/product.php?id=905
http://www.omnigsoft.com/products/2007/Super-G%20Stunt/Utopia.jpg
http://www.omnigsoft.com/products/2007/Super-G%20Stunt/DinosaurPark.jpg
another game
http://www.omnigsoft.com/products/2002/MiniJetfight/scr5.jpg
http://www.omnigsoft.com/products/2002/MiniDogfight/scr4.jpg

Koush
26th August 2008, 06:26 PM
Hi,
I've downloaded ManagedOpenGLES.zip and I have problems running it in windows mobile sdk. It builds without errors but when I try to run it I get this exception:

http://img228.imageshack.us/img228/5990/glhz4.jpg

I've downloaded Vincent 3D and took libgles_cm.dll from it. I've put this dll to my bin folder but I still get the same error. Of course I can copy exec files directly to my device and run it from there without problems (because it does not need libgles_cm.dll) but I want it to work in sdk too. Any ideas? Thanks.

If you copy the file it to the emulator, that line should not fail. But Vincent 3d is fixed point only, so all the floating point GL functions that are available on the Diamond will fail.

cgeboers
26th August 2008, 09:18 PM
I think I ran into a small problem with the OpenGL SDK.

When trying to load a .png or .bmp file, the byte order seems to be BGRA instead of RBGA or at least WM6.1 handles it like that.
It is hardly noticable in Sensory Overload, because the space ship is small. It is better visible with larger textures.
I created a "quick and dirty" fix by swapping the bytes, but this works currently only for 32bpp RGBA images. I don't think this is real a problem because most "modern" image programs will use RGBA.
I used Gimp 2.4.x for creating the images, but I got it also with images I downloaded from the NeHe tutorials.

I have included images of what I mean. The original is the picture I created with Gimp, the others are screendumps from my Diamond. Needless to say it is actually a rotating cube and pyramid (in landscape).


===============
If you like my applications, consider a donation to Koushik.
After all it is thanks to his (and the many other developers) work and readiness to share it that I can write these programs. I still get enough satisfaction in writing these programs.

kultus
26th August 2008, 09:50 PM
you can try this 3d game if you want it works great on the diamond http://htc-touch-diamond.handster.com/product.php?id=905
http://www.omnigsoft.com/products/2007/Super-G%20Stunt/Utopia.jpg
http://www.omnigsoft.com/products/2007/Super-G%20Stunt/DinosaurPark.jpg
another game
http://www.omnigsoft.com/products/2002/MiniJetfight/scr5.jpg
http://www.omnigsoft.com/products/2002/MiniDogfight/scr4.jpg

I dont what does "great" mean for you but for me this game isnt great slow on my diamond with all options and only qvga so very ugly I was very dissapointed

Koush
27th August 2008, 04:01 AM
I think I ran into a small problem with the OpenGL SDK.

When trying to load a .png or .bmp file, the byte order seems to be BGRA instead of RBGA or at least WM6.1 handles it like that.
It is hardly noticable in Sensory Overload, because the space ship is small. It is better visible with larger textures.
I created a "quick and dirty" fix by swapping the bytes, but this works currently only for 32bpp RGBA images. I don't think this is real a problem because most "modern" image programs will use RGBA.
I used Gimp 2.4.x for creating the images, but I got it also with images I downloaded from the NeHe tutorials.

I have included images of what I mean. The original is the picture I created with Gimp, the others are screendumps from my Diamond. Needless to say it is actually a rotating cube and pyramid (in landscape).


===============
If you like my applications, consider a donation to Koushik.
After all it is thanks to his (and the many other developers) work and readiness to share it that I can write these programs. I still get enough satisfaction in writing these programs.


You are correct, this is a bug in the Sensory Overload game that I knew about, but just didn't care to fix/document :).
The offending code in particular:
bitmap.LockBits(ref rect, ImageLockMode.ImageLockModeRead, PixelFormatID.PixelFormat32bppARGB, out data);
gl.TexImage2D(gl.GL_TEXTURE_2D, 0, gl.GL_RGBA, size.Width, size.Height, 0, gl.GL_RGBA, gl.GL_UNSIGNED_BYTE, data.Scan0);

PixelFormat32bppARGB is an int that is equivalent to GL_BGRA byte array, not GL_RGBA. You can view the memory pointer of data.Scan0 and verify this. However, GL_BGRA (0x80E1 when implemented as an extension) is not a valid OpenGL ES format; atleast not on the Diamond.

Your solution of doing a byte level swap per pixel is necessary. As far as I know, there is no way to solve this other than using non-GDI/IImage loading routines. There are two viable solutions:

Do the pixel swap in code as you are now.
Swap your R and B components in your image before saving so you don't waste time doing that in the application.

Usper
28th August 2008, 04:19 PM
I dont what does "great" mean for you but for me this game isnt great slow on my diamond with all options and only qvga so very ugly I was very dissapointed
Same. Too slow. Bit laggy.

tommm
29th August 2008, 12:42 PM
Same. Too slow. Bit laggy.


Really - to slow and only QVGA:(

pix27
29th August 2008, 12:52 PM
Some nice OpenGL|ES tutorials that I have found

25 Step tutorial with lots of screens
http://www.zeuscmd.com/tutorials/opengles/

7 Doc ZIP
http://www.khronos.org/developers/tutorials/typhoonlabs_tutorials.zip

Koush
29th August 2008, 05:33 PM
My favorite OpenGL series (which works with OpenGLES too) is http://nehe.gamedev.net. It's a ~50ish tutorial series. You can start from basically nothing and get into some really advanced stuff by the end of it!

Zeppie
2nd September 2008, 12:46 PM
I like the wrapper!
It is a bit different than the original OpenGL (some small functions/methods in the NeHe beginner tut's are missing I guess? glVertex3f becomes drawing with glVertexPointer).
I wrote a little spinning piramid and now trying to make a building or a ball (or some other more complex struture).

In highschool I wrote a car-crashing game in OpenGL with Ageia PhysX engine attached to it. Would be fun on the Diamond :D

Koush
3rd September 2008, 12:16 AM
Yeah, OpenGL ES is a subset of OpenGL, so not all functions are available. glVertex3f is really slow anyways! Multiple function calls per polygon = bad. :)

cgeboers
3rd September 2008, 11:22 AM
Has anybody ported the GLUT/ES libraries to the Diamond ? It could make programming a bit easier as far as I can see. I tried the sample program that comes with the GLUT/ES sources, but it scrambles the screen and fails with an error message during the initialization of the GLU window.
Any guidelines or pointers to documents that could help me out here are appreciated !

Koush
3rd September 2008, 11:27 PM
I've had the same problem. I think it is because the Glut_ES implementation is meant to link to the Vincent version of libGLES_CM.dll.

toastedlogic
4th September 2008, 01:12 AM
... so who's working on porting GLQuake to wm6.1? :)

jaikben22
4th September 2008, 12:15 PM
glquake would be nice, the test demo also works on xda flame with goforce so comp will be great somebody please use this knowledge :)

Zeppie
4th September 2008, 02:36 PM
I might try to make a c# .3ds loader to do some funny stuff :) without loading some basic 3d models openGL is half te fun ;)

cgeboers
11th September 2008, 03:59 PM
I have a small example wich uses some C code together with C#. the code is from the GLUT_Shapes and draws, boxes, spheres and some other objects.
They are all based on the sample application coming with the OpenGL SDK here.

I have tried to use lights and fog, but the results are "disappointing". Probably because I do not really understand the concept.
When I enable lighting, all my objects are not colored, but just get a pure white color. It sems also that the lights rotate along with the axises, because sometimes only the "front" of an object is lighted.
Similar when I use "fog", I expect to see a haze on my screen, but the effect is merely that all my objects get a gray color (see picture: fog.png)

Could some kind OpenGL specialist look at my project and tell me what I am doing wrong ? I have looked at the tutorials from NeHe and Zeus, but seem to misinterpret them.

For the rest everything is working fine, translations and rotations do work correctly. (My only other experience with OpenGL is the AH64 lander game I wrote and posted here a few days ago in another thread, but that was using a 2D Orhtographic projection. It looks like the 3D is a bit to high for me ;)

I have included everything in the zip, except the OpenGL SDK.

Koush
11th September 2008, 11:36 PM
Very cool!

The reason your lighting shows white is because when lighting is enabled, color is disregarded in favor of "Material". Check out the gl.Material calls. The Sensory Overload application I wrote demonstrates how to use both ambient and diffuse lights.

Koush
11th September 2008, 11:39 PM
Oh, and your fog does not seem to work because your background is not a solid object to which Fog is applied (ie, the background has no depth). That's why only the objects seem to get fogged, and nothing else. Your fog end value of "5" might also be a little too close.

Koush
11th September 2008, 11:44 PM
Incidentally, you are linking against libgles_cm.lib. Is that the Vincent3D one?

cgeboers
12th September 2008, 06:05 AM
Incidentally, you are linking against libgles_cm.lib. Is that the Vincent3D one?

Yes that is correct. Is there another one available ?

Zeppie
15th September 2008, 04:19 PM
I'm almost done writing a 3DS file loader.. I;m trying to wrap it up in a sort of resource loader and tidy up things a bit. When I've tested it I will make it openSource. Let the gaming begin :)

idrisito
20th September 2008, 12:52 PM
i found this website, may be its useful for some of you, its got allot of examp[le code to play around with

http://www.codeproject.com

cgeboers
20th September 2008, 08:46 PM
Oh, and your fog does not seem to work because your background is not a solid object to which Fog is applied (ie, the background has no depth). That's why only the objects seem to get fogged, and nothing else. Your fog end value of "5" might also be a little too close.

Your suggestions made everything work fine. I am currently rewriting the "SnowStorm" application with OpenGL to get better performance and I am slowly getting there. Still will be a few days before it is ready.

cgeboers
20th September 2008, 08:47 PM
I'm almost done writing a 3DS file loader.. I;m trying to wrap it up in a sort of resource loader and tidy up things a bit. When I've tested it I will make it openSource. Let the gaming begin :)

This is great, if you need a beta tester, put me on the list :)
Would be nice for the "Toy Plane", which I intend to rewrite also for OpenGL.

Zeppie
27th September 2008, 11:13 PM
I'm still at the 'almost done' phase... files read ok as far as I know, reads vertices and faces (and some texture stuff). When I use glDrawArray with gl.GL_POINTS, all the dots are drawn right, but when I use GL_LINES or GL_TRIANGLES it gets messed up. Will post some screenshots asap. :)

Zeppie
30th September 2008, 10:14 AM
Ok, fixed a bug.. while reading faces from a 3ds file, 1 tutorial I found just stated "read 3 ushorts, point a b and c"... while there was an EXTRA ushort ccontaining some additional info.

On to the texture part!!

Zeppie
30th September 2008, 11:18 AM
3ds file of a barrel:
http://www.mijnalbum.nl/Foto-FW4BCOSD.jpg
http://www.mijnalbum.nl/Foto-IPRUDODY.jpg

Zeppie
30th September 2008, 11:18 AM
face errors:
http://www.mijnalbum.nl/Foto-OO7J3Y87.jpg
http://www.mijnalbum.nl/Foto-JOEHBT3H.jpg
http://www.mijnalbum.nl/Foto-677T7UR8.jpg
http://www.mijnalbum.nl/Foto-MEA46YMD.jpg

Zeppie
30th September 2008, 11:19 AM
Working GL_POINTS:
http://www.mijnalbum.nl/Foto-HHD7CMT7.jpg

Working LineLoop and TRIANGLES:
http://www.mijnalbum.nl/Foto-O6DEKAHB.jpg
http://www.mijnalbum.nl/Foto-B73HWXU3.jpg
http://www.mijnalbum.nl/Foto-4QPGGCC8.jpg

danthekilla
30th September 2008, 03:29 PM
I'm still at the 'almost done' phase... files read ok as far as I know, reads vertices and faces (and some texture stuff). When I use glDrawArray with gl.GL_POINTS, all the dots are drawn right, but when I use GL_LINES or GL_TRIANGLES it gets messed up. Will post some screenshots asap. :)

sweet it will be great once that is working im good at makeing games but not to good with c# or rendering stuff (im used to using engines like torque, xna, gamebryo etc...)

Koush
30th September 2008, 07:15 PM
That looks like an issue with GL cull face. Try turning it off using
gl.Disable(gl.GL_CULL_FACE);

Zeppie
30th September 2008, 09:17 PM
Hi Koush,
It was an error on my side :)
while reading faces from a 3ds file, 1 tutorial I found just stated "read 3 ushorts, point a b and c"... while there was an EXTRA ushort ccontaining some additional info.

Zeppie
1st October 2008, 07:09 PM
When I try to add a texture like this:

uint[] textures = new uint[1];
fixed (uint* texturesPointer = &textures[0])
{
gl.GenTextures(1, texturesPointer);
}

I get some kind of nullpointer and my phone crashes prety bad.. what am I overseeing here?

Koush
1st October 2008, 09:49 PM
uint tex;
gl.GenTextures(1, &tex);


thats how I do it.

You can alternatively try it like:
uint[] textures = new uint[1];
fixed(uint* texturesPointer = textures)
{
gl.GenTextures(1, texturesPointer);
}

Koush
15th October 2008, 02:21 AM
http://hosted.koushikdutta.com/ManagedOpenGLESText.png

Updated the SDK to allow an easy and feature rich way to rendering text.

http://www.koushikdutta.com/2008/10/drawing-text-in-opengl-es.html

hellgod
15th October 2008, 09:56 AM
Hi all !

I wonder if there is a way to port a open source 3D engine from Windows to Windows Mobile.
This could realy help form making games.
Here some 3D engine :
Raydium (http://raydium.org/)
Ogre (http://www.ogre3d.org/)

I have started looking into Raydium to rebuild it with CeGCC but it seems to be a hard task.......

doc morelli
19th October 2008, 06:47 PM
hey everyone,

im just playing around with some of Koushs TestOpenGLES sample code. I read a few tutorials and searched around the hole day but i still dont know why it wont work.

i draw a rectangle and im just trying map a texture on it.


unsafe void InitGL()
{
myTexture = new uint[1];
gl.ShadeModel(gl.GL_SMOOTH);
gl.ClearColor(0.0f, 0.0f, 0.0f, 0.5f);
gl.ClearDepthf(1.0f);
gl.Enable(gl.GL_DEPTH_TEST);
gl.BlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA);
gl.DepthFunc(gl.GL_LEQUAL);
gl.Hint(gl.GL_PERSPECTIVE_CORRECTION_HINT, gl.GL_NICEST);
gl.Enable(gl.GL_TEXTURE_2D);

myFont = new OpenGLFont(new Font(FontFamily.GenericSerif, 12, FontStyle.Regular));
myHugeFont = new OpenGLFont(new Font(FontFamily.GenericSerif, 32, FontStyle.Regular));

zoomFactor = zoomMax;

// Loading Bitmap
currentBitmap = new Bitmap("zeus.bmp");

System.Drawing.Imaging.BitmapData bitmapdata;
Rectangle rect = new Rectangle(0, 0, currentBitmap.Width, currentBitmap.Height);

bitmapdata = currentBitmap.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb) ;

fixed (uint* myTexturePointer = &myTexture[0])
{
gl.GenTextures(1, myTexturePointer);
}
gl.BindTexture(gl.GL_TEXTURE_2D, myTexture[0]);
gl.TexImage2D(gl.GL_TEXTURE_2D, 0, gl.GL_RGB, currentBitmap.Width, currentBitmap.Height, 0, gl.GL_RGB, gl.GL_UNSIGNED_BYTE, bitmapdata.Scan0);
gl.TexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR);
gl.TexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR);

currentBitmap.UnlockBits(bitmapdata);
currentBitmap.Dispose();
}



unsafe void DrawGLScene()
{
int count;

gl.GetIntegerv(gl.GL_MAX_TEXTURE_UNITS, &count);

gl.Viewport(ClientRectangle.Left, ClientRectangle.Top, ClientRectangle.Width, ClientRectangle.Height);
gl.MatrixMode(gl.GL_PROJECTION);
gl.LoadIdentity();
gluPerspective(45, (float)ClientSize.Width / (float)ClientSize.Height, .1f, 100);

gl.MatrixMode(gl.GL_MODELVIEW);
gl.BindTexture(gl.GL_TEXTURE_2D, myTexture[0]);
gl.LoadIdentity();

float[] square = { -1f, -1f, 0f, 1f, -1f, 0f, -1f, 1f, 0f, 1f, 1f, 0f };
float[] texCoords = { 1f, 1f, 0f, 1f, 0f, 0f, 1f, 0f};

gl.LoadIdentity();
gl.Translatef(0.0f, 0.0f, zoomFactor);
gl.Rotatef(myRotation, 0.0f, 1.0f, 0.0f);

fixed (float* squarePointer = &square[0], texCoordsPointer = &texCoords[0])
{
gl.EnableClientState(gl.GL_VERTEX_ARRAY);
gl.EnableClientState(gl.GL_TEXTURE_COORD_ARRAY);

gl.VertexPointer(3, gl.GL_FLOAT, 0, (IntPtr)squarePointer);
gl.TexCoordPointer(2, gl.GL_FLOAT, 0, (IntPtr)texCoordsPointer);

gl.DrawArrays(gl.GL_TRIANGLE_STRIP, 0, 4);

gl.DisableClientState(gl.GL_TEXTURE_COORD_ARRAY);
gl.DisableClientState(gl.GL_VERTEX_ARRAY);
gl.Flush();
}

gl.MatrixMode(gl.GL_PROJECTION);
gl.LoadIdentity();
gl.Orthof(0, ClientSize.Width, ClientSize.Height, 0, -10, 10);

gl.MatrixMode(gl.GL_MODELVIEW);
gl.LoadIdentity();

gl.Translatef(0, 0, 0);

GlyphRun fpsText = new GlyphRun(myFont, Math.Round(myFps, 2).ToString() + " FPS" + ", " + myRotation.ToString());
fpsText.Draw();
}
}


But its just displaying a white square with no texture on it. Please can someone help me? I also checked zeuscmd.com and nehe.gamedev.net tutorials and cant manage to get it work.

btw sorry for my english

Koush
19th October 2008, 10:46 PM
hey everyone,

im just playing around with some of Koushs TestOpenGLES sample code. I read a few tutorials and searched around the hole day but i still dont know why it wont work.

i draw a rectangle and im just trying map a texture on it.


unsafe void InitGL()
{
myTexture = new uint[1];
gl.ShadeModel(gl.GL_SMOOTH);
gl.ClearColor(0.0f, 0.0f, 0.0f, 0.5f);
gl.ClearDepthf(1.0f);
gl.Enable(gl.GL_DEPTH_TEST);
gl.BlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA);
gl.DepthFunc(gl.GL_LEQUAL);
gl.Hint(gl.GL_PERSPECTIVE_CORRECTION_HINT, gl.GL_NICEST);
gl.Enable(gl.GL_TEXTURE_2D);

myFont = new OpenGLFont(new Font(FontFamily.GenericSerif, 12, FontStyle.Regular));
myHugeFont = new OpenGLFont(new Font(FontFamily.GenericSerif, 32, FontStyle.Regular));

zoomFactor = zoomMax;

// Loading Bitmap
currentBitmap = new Bitmap("zeus.bmp");

System.Drawing.Imaging.BitmapData bitmapdata;
Rectangle rect = new Rectangle(0, 0, currentBitmap.Width, currentBitmap.Height);

bitmapdata = currentBitmap.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb) ;

fixed (uint* myTexturePointer = &myTexture[0])
{
gl.GenTextures(1, myTexturePointer);
}
gl.BindTexture(gl.GL_TEXTURE_2D, myTexture[0]);
gl.TexImage2D(gl.GL_TEXTURE_2D, 0, gl.GL_RGB, currentBitmap.Width, currentBitmap.Height, 0, gl.GL_RGB, gl.GL_UNSIGNED_BYTE, bitmapdata.Scan0);
gl.TexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR);
gl.TexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR);

currentBitmap.UnlockBits(bitmapdata);
currentBitmap.Dispose();
}



unsafe void DrawGLScene()
{
int count;

gl.GetIntegerv(gl.GL_MAX_TEXTURE_UNITS, &count);

gl.Viewport(ClientRectangle.Left, ClientRectangle.Top, ClientRectangle.Width, ClientRectangle.Height);
gl.MatrixMode(gl.GL_PROJECTION);
gl.LoadIdentity();
gluPerspective(45, (float)ClientSize.Width / (float)ClientSize.Height, .1f, 100);

gl.MatrixMode(gl.GL_MODELVIEW);
gl.BindTexture(gl.GL_TEXTURE_2D, myTexture[0]);
gl.LoadIdentity();

float[] square = { -1f, -1f, 0f, 1f, -1f, 0f, -1f, 1f, 0f, 1f, 1f, 0f };
float[] texCoords = { 1f, 1f, 0f, 1f, 0f, 0f, 1f, 0f};

gl.LoadIdentity();
gl.Translatef(0.0f, 0.0f, zoomFactor);
gl.Rotatef(myRotation, 0.0f, 1.0f, 0.0f);

fixed (float* squarePointer = &square[0], texCoordsPointer = &texCoords[0])
{
gl.EnableClientState(gl.GL_VERTEX_ARRAY);
gl.EnableClientState(gl.GL_TEXTURE_COORD_ARRAY);

gl.VertexPointer(3, gl.GL_FLOAT, 0, (IntPtr)squarePointer);
gl.TexCoordPointer(2, gl.GL_FLOAT, 0, (IntPtr)texCoordsPointer);

gl.DrawArrays(gl.GL_TRIANGLE_STRIP, 0, 4);

gl.DisableClientState(gl.GL_TEXTURE_COORD_ARRAY);
gl.DisableClientState(gl.GL_VERTEX_ARRAY);
gl.Flush();
}

gl.MatrixMode(gl.GL_PROJECTION);
gl.LoadIdentity();
gl.Orthof(0, ClientSize.Width, ClientSize.Height, 0, -10, 10);

gl.MatrixMode(gl.GL_MODELVIEW);
gl.LoadIdentity();

gl.Translatef(0, 0, 0);

GlyphRun fpsText = new GlyphRun(myFont, Math.Round(myFps, 2).ToString() + " FPS" + ", " + myRotation.ToString());
fpsText.Draw();
}
}


But its just displaying a white square with no texture on it. Please can someone help me? I also checked zeuscmd.com and nehe.gamedev.net tutorials and cant manage to get it work.

btw sorry for my english



I'm going to take a wild guess and say your zues.bmp texture isn't a 2^N square texture. Textures must be 4x4, 8x8, 16x16, 32x32... 512x512. I provided a "Texture" class in that tutorial that allows you to easily load odd sized textures by automatically resizing them into squares for you behind the scenes.

cgeboers
21st October 2008, 07:37 AM
I'm going to take a wild guess and say your zues.bmp texture isn't a 2^N square texture. Textures must be 4x4, 8x8, 16x16, 32x32... 512x512. I provided a "Texture" class in that tutorial that allows you to easily load odd sized textures by automatically resizing them into squares for you behind the scenes.
Actually textures don't have to be squares, they can be rectangles too:
4x8, 8x32, 512x256, as long as the sides are a 2^N number. I noticed that in the latest version of your OpenGL SDK, the texture will force dimensions to be squares, but that is not necessary.
I have used the 512x256, etc several times. Especially with the larger sizes, you can save some (mega)bytes of space if your image is rectangular instead of square.

cgeboers
21st October 2008, 07:40 AM
hey everyone,

im just playing around with some of Koushs TestOpenGLES sample code. I read a few tutorials and searched around the hole day but i still dont know why it wont work.

i draw a rectangle and im just trying map a texture on it.


But its just displaying a white square with no texture on it. Please can someone help me? I also checked zeuscmd.com and nehe.gamedev.net tutorials and cant manage to get it work.

btw sorry for my english

You might want to check the source code of the Beer program and the Diamond Cubes perhaps in one of the other threads, but the main reason is perhaps because you did not enable the lighting ?
Use something like this before you draw the texture:

gl.Enable(gl.GL_LIGHTING);

And of course you need to tell OpenGL about the Normal of your texture, so it can do the lighting correctly. Again have a look at the Diamond Cubes program for an example. It is also used in the Beer program, but there it is fixed, because all textures are facing the same direction.

Koush
21st October 2008, 07:29 PM
Actually textures don't have to be squares, they can be rectangles too:
4x8, 8x32, 512x256, as long as the sides are a 2^N number. I noticed that in the latest version of your OpenGL SDK, the texture will force dimensions to be squares, but that is not necessary.
I have used the 512x256, etc several times. Especially with the larger sizes, you can save some (mega)bytes of space if your image is rectangular instead of square.

Oh, wow, that square restriction is a Direct3D restriction, and not OpenGL! :) Didn't know about that, thanks for the tip! I'll update the code.

Koush
21st October 2008, 07:31 PM
You might want to check the source code of the Beer program and the Diamond Cubes perhaps in one of the other threads, but the main reason is perhaps because you did not enable the lighting ?
Use something like this before you draw the texture:

gl.Enable(gl.GL_LIGHTING);

And of course you need to tell OpenGL about the Normal of your texture, so it can do the lighting correctly. Again have a look at the Diamond Cubes program for an example. It is also used in the Beer program, but there it is fixed, because all textures are facing the same direction.

You don't need to enable lighting to use textures. Lighting is a pretty expensive operation, so I'd recommend leaving it off if you don't actually use it.

cgeboers
22nd October 2008, 09:30 AM
You don't need to enable lighting to use textures. Lighting is a pretty expensive operation, so I'd recommend leaving it off if you don't actually use it.

Are you sure about this ? If I put a gl.Disable(gl.GL_LIGHTING); in my code, all I get is a black screen. (My app is only showing textures and no background at all).
Now, I do think that by default lighting is enabled, at least for LIGHT0, so maybe the call would not be necessary ?

I also only use LIGHT0, just to avoid too heavy calculations. (at least for the moment, just need to get the physics for my game right first :D )

Koush
22nd October 2008, 06:02 PM
Are you sure about this ? If I put a gl.Disable(gl.GL_LIGHTING); in my code, all I get is a black screen. (My app is only showing textures and no background at all).
Now, I do think that by default lighting is enabled, at least for LIGHT0, so maybe the call would not be necessary ?

I also only use LIGHT0, just to avoid too heavy calculations. (at least for the moment, just need to get the physics for my game right first :D )

Yep, I just tried gl.Disable(gl.GL_LIGHTING); to explicitly disable lighting, and my stuff continued working fine.

p1000
25th October 2008, 08:51 PM
Hi,

I am using your library (which is really great!) to do some game development for the HTC Diamond. But my game requires the user to both click on 3D buttons and drag 3D objects around the screen.

I am pretty new to 3D graphics programming, but I am trying to use:

glRenderMode(GL_SELECT);

which does not seem to be supported.

If someone could either post a small piece of code for a HitTest function or simply explain how I can do this it would be a great help. The Diamond has a really cool touch screen and I would really like to be able to use it to interact with my 3D scene.

Thanks a lot!

Joppiz HTC LOVER
26th October 2008, 09:04 AM
Hi how can i update my framework i have tryed to download it but i cant make it to work on my htc.

guizmox
28th October 2008, 11:06 AM
Hi,
I have a question for those who are developping OpenGLES apps...

I don't find any information on the 3D chipset in the MSM7201 chipset.
Is it an Imageon 2300 modified ? And what about specifications (shared memory ? OpenglES 1.0 or 1.1 ?)

In my opinion it's an OpenglES 1.1 compatible chipset but the driver only seems to support 1.0 instructions (GlBenhmark informations)... Am I right ?

GL_VENDOR QUALCOMM, Inc.
GL_VERSION OpenGL ES-CM 1.0
GL_RENDERER Q3Dimension MSM7500W 01.02.03 0 5.1.2

I'm asking this question for Koush and other guys who are working with OpenGLES... You probably have more informations than me !

I found this datasheet, but perhaps it's only "paper" and not real specs...

http://brew.qualcomm.com/bnry_brew/pdf/brew_2007/Tech-303_Ligon.pdf

cgeboers
4th November 2008, 10:06 PM
I'm almost done writing a 3DS file loader.. I;m trying to wrap it up in a sort of resource loader and tidy up things a bit. When I've tested it I will make it openSource. Let the gaming begin :)

How far did you get with this ? I am looking for a 3DS loader for my "Diamond Cubes" program, it would be great if I could have a look at your program.
You also mentioned a 3DS tutorial, could you tell me where it is ?

Edit: In the mean time I wrote my own 3DS loader, but I fear that it is just a bit too much for the diamond and OpenGL, because of some floating point errors ?

baallrog
4th November 2008, 11:15 PM
Hi Koush,

I have tested your wrapper through your pyramide application.
The fps are 4.5 on my diamond.

This is low i think.

And i have a question for you.
Why this is low ? is there a way to increase this ?


Thank you in advance !!!!

Koush
9th November 2008, 10:42 AM
Did you replace your libgles_cm.dll on your device by installing drivers for another phone?
If not, does the pyramid application have a libgles_cm.dll in the directory? If so, remove it.

I get around 60fps.

xeirwn
15th November 2008, 09:21 AM
Hi guys!

I have an Xda Flame that also supports OpenGLES...
Today I found a small benchmark that initially run on Axim x50v, but it runs smoothly on my phone as well.
Can you please try to run this on your Diamond?
download here: http://www.ims.tuwien.ac.at/~daniel/download/BenchGLES_0_2.zip

more info at initial thread:
http://pocketmatrix.com/forums/viewtopic.php?p=246425#246425

compare our scores here:
http://xdaflameusers.com/viewtopic.php?id=1318

jamesd256
15th November 2008, 12:49 PM
Can you please try to run this on your Diamond?

I will try that when I get home.

In the mean time, can anyone tell me how to get GLBenchmark running?

It looks like it must run, as there are scores posted on the site, but it don't work on my Raphael.

It runs the full page rendering test, then draws a horizontal line across the screen before hanging.

idrisito
15th November 2008, 02:47 PM
try running it with TF3D off!

i get 1259 on my diamond xda with ignito stock rom
the first time i have been impressed with the diamonds 3d performance


too bad i can program suff like this

jamesd256
15th November 2008, 03:57 PM
try running it with TF3D off!

i get 1259 on my diamond xda with ignito stock rom
the first time i have been impressed with the diamonds 3d performance


too bad i can program suff like this

Not sure which post you're replying to.

idrisito
15th November 2008, 07:11 PM
Not sure which post you're replying to.

the benchmark software!

i tried it with tf3d on first and it didnt work proper
then tried the bench mark test with it off and worked

may be im confused ! lol

xeirwn
15th November 2008, 07:25 PM
this little benchmark runs on imate ppcs as well..

so this 3d engine proves that it is feasible to make hardware-accelerated games & apps, compatible with different devices!

really hope to see some cool apps coming some day!! :D

harweyko
26th December 2008, 06:27 PM
Hi guys!

I have an Xda Flame that also supports OpenGLES...
Today I found a small benchmark that initially run on Axim x50v, but it runs smoothly on my phone as well.
Can you please try to run this on your Diamond?
download here: http://www.ims.tuwien.ac.at/~daniel/download/BenchGLES_0_2.zip

more info at initial thread:
http://pocketmatrix.com/forums/viewtopic.php?p=246425#246425

compare our scores here:
http://xdaflameusers.com/viewtopic.php?id=1318

runs smoothly on Diamond, 1240 points after softreset on stock ROM with TF3D on, after whole day of usage 1224 points....

sandmen
26th December 2008, 09:41 PM
Hi,
i have this code-snippet (from koush's glmaps). Everything work's fine,
but i can't change the lineWidth. It looks that DrawArrays are drawing
the lines allwas with linewidth(1.0f).
Does anybody knows, how to change th linewidth.


unsafe public void DrawLines(float lineWidth, Color color, Point[] points)
{
gl.Color4f((float)color.R / 255f, (float)color.G / 255f, (float)color.B / 255f, (float)color.A / 255f);
float[] floatPoints = new float[points.Length * 3];
for (int i = 0; i < points.Length; i++)
{
int index = i * 3;
floatPoints[index] = points[i].X;
floatPoints[index + 1] = points[i].Y;
floatPoints[index + 2] = 0;
}
gl.PushMatrix();
{
gl.Scalef(myScale, myScale, myScale);
gl.EnableClientState(gl.GL_VERTEX_ARRAY);
fixed (float* positionPointer = floatPoints)
{
gl.VertexPointer(3, gl.GL_FLOAT, 0, (IntPtr)positionPointer);
gl.DrawArrays(gl.GL_LINE_STRIP, 0, points.Length);
}
gl.DisableClientState(gl.GL_VERTEX_ARRAY);
}
gl.PopMatrix();
}



thnaks

Koush
29th December 2008, 09:47 PM
Hi,
i have this code-snippet (from koush's glmaps). Everything work's fine,
but i can't change the lineWidth. It looks that DrawArrays are drawing
the lines allwas with linewidth(1.0f).
Does anybody knows, how to change th linewidth.


unsafe public void DrawLines(float lineWidth, Color color, Point[] points)
{
gl.Color4f((float)color.R / 255f, (float)color.G / 255f, (float)color.B / 255f, (float)color.A / 255f);
float[] floatPoints = new float[points.Length * 3];
for (int i = 0; i < points.Length; i++)
{
int index = i * 3;
floatPoints[index] = points[i].X;
floatPoints[index + 1] = points[i].Y;
floatPoints[index + 2] = 0;
}
gl.PushMatrix();
{
gl.Scalef(myScale, myScale, myScale);
gl.EnableClientState(gl.GL_VERTEX_ARRAY);
fixed (float* positionPointer = floatPoints)
{
gl.VertexPointer(3, gl.GL_FLOAT, 0, (IntPtr)positionPointer);
gl.DrawArrays(gl.GL_LINE_STRIP, 0, points.Length);
}
gl.DisableClientState(gl.GL_VERTEX_ARRAY);
}
gl.PopMatrix();
}



thnaks

Yeah, on OpenGL ES, the line width is locked at 1. You can render a thicker line by drawing a triangle strip. I am going to write that code eventually. :)

sandmen
29th December 2008, 10:59 PM
Thanks,
Eventually i write by me self :)

thanks

hobbbbit
19th January 2009, 04:53 AM
Maybe somebody could give me a hint on how to solve the texturing problem I'm having. I have more or less the same problem as doc morelli a few posts back. I draw a rectangle and map a texture onto it, however all I get is a white rectangle. I am using the Texture class that Koush provided in his wrapper. I'm fairly sure that it has to do with the coordinates for the texture that I create, but I don't know how to change them to make them work. Here's my code:


if (Size != null && Image != null)
{
//Load image as texture
Texture myImage;
using (MemoryStream ms = new MemoryStream())
{
Image.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
myImage = Texture.LoadStream(ms, false);
}

float[] rectangle = new float[] {
0, 0,
Size.Width, 0,
0, Size.Height,
Size.Width, Size.Height
};

float[] texturePosition = new float[] {
0, 0,
myImage.Width, 0,
0, myImage.Height,
myImage.Width, myImage.Height
};

gl.ShadeModel(gl.GL_SMOOTH);
gl.ClearColor(0.0f, 0.0f, 0.0f, 0.5f);
gl.ClearDepthf(1.0f);
gl.BlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA);
gl.DepthFunc(gl.GL_LEQUAL);
gl.Hint(gl.GL_PERSPECTIVE_CORRECTION_HINT, gl.GL_NICEST);

//Bind texture
gl.BindTexture(gl.GL_TEXTURE_2D, myImage.Name);
gl.TexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR);
gl.TexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR);
//move cursor
glLocation.MoveCursor(Location.X, Location.Y);
gl.EnableClientState(gl.GL_TEXTURE_COORD_ARRAY);
gl.EnableClientState(gl.GL_VERTEX_ARRAY);

//draw square and texture it.
fixed (float* rectanglePointer = &rectangle[0], positionPointer = &texturePosition[0])
{
gl.VertexPointer(2, gl.GL_FLOAT, 0, (IntPtr)rectanglePointer);
gl.TexCoordPointer(2, gl.GL_FLOAT, 0, (IntPtr)positionPointer);
gl.DrawArrays(gl.GL_TRIANGLE_STRIP, 0, 4);
}

gl.DisableClientState(gl.GL_TEXTURE_COORD_ARRAY);
gl.DisableClientState(gl.GL_VERTEX_ARRAY);
}


By the way, does anyone knows a link to a good 2D OpenGLES tutorial on the net? All tutorials I've seen so far deal with almost only 3D, and all I want to do is simple 2D hardware-accelerated graphics.

crystalizer
9th February 2009, 01:35 AM
am looking for the same sort of code sample but using visual C++, openGL ES and a blackstone
tried to deal with all openGL ES libraries i could find but excluding this C# example i dont see how running openGL ES on a blackstone by coding on C++

Synced
15th February 2009, 05:52 PM
Hey gang.

First off want to thank the author for this OpenGL ES wrapper. This is great.

Secondly I have a couple projects where opengl could really benefit, one is a winforms finger scrolling control ala iPhone which I wrote, so I plan on porting the UI aspects to OpenGL for much higher frame rates.

I also started a WPF/SL/XAML parser/library for the Compact Framework many months ago that I am going to be investigating with opengl if the first item goes well.

I am new to 3D and toolkits like OpenGL however so I think I am in need of some assistance.

Yesterday I did a ton of googling and followed many samples but just can't get the same results in OpenGL ES with this wrapper so I must be doing something wrong.

Is it possible to get a viewport where 1:1 pixel mapping occurs? I am trying to make it as simple as possible to handle 0,0 being top/left in controls map to OpenGL coordinates so controls show up where they should.

Secondly I am trying to just do a noob test of rendering a square and I keep getting a triangle no matter what I do via the following:

float[] square = new float[] {
0.0f, 0.0f,
0.0f, 1.0f,
1.0f, 1.0f,
1.0f, 0.0f,
};

float[] colors2 = new float[] { 128.0f };

gl.LoadIdentity();
gl.Translatef(-left, 0.0f, -6.0f);

fixed (float* trianglePointer = &square[0], colorPointer = &colors2[0])
{
gl.EnableClientState(gl.GL_VERTEX_ARRAY);
gl.VertexPointer(2, gl.GL_FLOAT, 0, (IntPtr)trianglePointer);
gl.EnableClientState(gl.GL_COLOR_ARRAY);
gl.ColorPointer(4, gl.GL_FLOAT, 0, (IntPtr)colorPointer);

gl.DrawArrays(gl.GL_TRIANGLE_STRIP, 0, 4);
gl.DisableClientState(gl.GL_VERTEX_ARRAY);
gl.DisableClientState(gl.GL_COLOR_ARRAY);
gl.Flush();
}

Does anyone see anything wrong with this? I'm sure there is :)

hobbbbit
15th February 2009, 07:28 PM
1:1 pixel mapping would go like this:

gl.MatrixMode(gl.GL_PROJECTION);
gl.LoadIdentity();
gl.Orthof(0, ClientSize.Width, ClientSize.Height, 0, 0, 1);
gl.Disable(gl.GL_DEPTH_TEST);

gl.MatrixMode(gl.GL_MODELVIEW);
gl.LoadIdentity();

This would be for 2D drawing... For 3D don't disable depth_test.
For square drawing, just copy the code that I posted in the previous message, and remove all the references to texture, that will paint a square. To put a texture on it, I was just missing gl.Enable(gl.GL_TEXTURE_2D); so if you need texture, just add it right before gl.TexCoordPointer(2, gl.GL_FLOAT, 0, (IntPtr)positionPointer);
If you need more examples, send me a PM, and I'll give you a link to my code repository.

Synced
16th February 2009, 05:37 AM
Cool thanks for the help!

Although I still get no square now hehe.

I think I am probably misunderstanding some calls and have some things conflicting.

I am mostly confused about things that should go into the form resize event (to setup the perspetive/Orthof/viewport).

Do I have to set these things per render loop or just in an InitGL() type method?

I pretty much pasted what you have in your above sample in my render loop method and just get a black screen.

In the wrapper's sample with the spinning triangle, they set in InitGL() things like the shadermodel, clearcolor, cleardepth, BlendFunc, DepthFunc, Hint

But then in the DrawGLScene() they do a GetIntegerv, Viewport, Perspective, then construct the triangles and colors etc.

I've got to have something here that is causing this to not work hehe.

hobbbbit
16th February 2009, 05:08 PM
Orthof is what sets a projection. It should only be initialized once in InitGL, however, if you want to support form resizing, you might have to change it when you get an event (not sure, haven't tried it yet).
When rendering a square, paste my code into DrawGLScene method, and then paste the orthof code into InitGL.
As I said in the last message, if you have problems getting your code to run, send me a PM on the forum, and I'll give you access to my code repository. What I did in my code is I created some base classes to setup OpenGL Form that will do all of the base OpenGL settings for you, as well as base class for glControl, which replaces base .NET Control class and allows you to build custom controls that would use OpenGL to render it's output vs. GDI. It's a bit messy, but it works fine.

picolo5
12th March 2009, 03:21 AM
Hi all, thanks for the wrapper !!!

i have a project in vb.net, i use 'classic' drawing on the form to show a sliding list and it is slow...

i would like to try opengles but i not good at c# and i don t want to traduct all my project in c#

i do not understand how to traduct this in vb.net :

myLeftAligned.ApplyTextureShader((glyphPos) =>
{
float left = glyphPos.TopLeft.X / myLeftAligned.Size.Width;
float top = glyphPos.TopLeft.Y / myLeftAligned.Size.Height;
float right = glyphPos.TopRight.X / myLeftAligned.Size.Width;
float bottom = glyphPos.BottomLeft.Y / myLeftAligned.Size.Height;
return new GlyphTexCoords(left, top, right, bottom);
}
);

myLeftAligned.Texture = myTexture;

myRightAligned.ApplyColorShader((glyphPos) =>
{
GlyphColors colors = new GlyphColors();
colors.TopLeft = new Vector4f(1, 0, 0, 1);
colors.BottomLeft = new Vector4f(0, 1, 0, 1);
colors.TopRight = new Vector4f(1, 0, 0, 1);
colors.BottomRight = new Vector4f(0, 0, 1, 1);

return colors;
}
);

i dont understand anonymous method/lambda expressions and vb does not support it...

Can somebody explain me / show me the traduction ???

thanx !!

NuShrike
25th March 2009, 04:12 AM
I would not be surprised if the Kaiser D3D drivers were actually just a copy of the Diamond drivers.You're not worthy, and really off-base here. There's was much more work involved than just copying .dlls files over. Most will never understand. The Kaiser OpenGL ES drivers are based off the LG KS20 OGLES drivers.

The HTCClassAction driver disables the default HTC D3D driver that just maps to Golden master full-debug, software, reference D3D driver which renders in seconds per frame (ref Don Couch). This default driver is supposed to run this slow, but it's not supposed to ship with any production device (ref Microsoft). This horrid driver is replaced it with the hardware-accelerated D3D OGLES wrapper from the KS20. This wrapper fix, funny enough, is now called the Diamond D3D drivers and being passed around as a panacea for any and all 3D questions.

The Omnia D3D driver is the official Platform Builder 5 D3D cpu-based drivers optimized by Intel that HTC should be shipping instead of that golden-master debug driver.

So, all that Kaiser 3D work was accomplished without: the bounty payment, Menneisyys's help (disappearing after soliciting for driver work), and without recognition of the originality of all the work as you just evidenced.

574ND410N3
11th May 2009, 06:52 PM
Hey gang.

First off want to thank the author for this OpenGL ES wrapper. This is great.

Secondly I have a couple projects where opengl could really benefit, one is a winforms finger scrolling control ala iPhone which I wrote, so I plan on porting the UI aspects to OpenGL for much higher frame rates.

I also started a WPF/SL/XAML parser/library for the Compact Framework many months ago that I am going to be investigating with opengl if the first item goes well.

I am new to 3D and toolkits like OpenGL however so I think I am in need of some assistance.

Yesterday I did a ton of googling and followed many samples but just can't get the same results in OpenGL ES with this wrapper so I must be doing something wrong.

Is it possible to get a viewport where 1:1 pixel mapping occurs? I am trying to make it as simple as possible to handle 0,0 being top/left in controls map to OpenGL coordinates so controls show up where they should.

Secondly I am trying to just do a noob test of rendering a square and I keep getting a triangle no matter what I do via the following:

float[] square = new float[] {
0.0f, 0.0f,
0.0f, 1.0f,
1.0f, 1.0f,
1.0f, 0.0f,
};

float[] colors2 = new float[] { 128.0f };

gl.LoadIdentity();
gl.Translatef(-left, 0.0f, -6.0f);

fixed (float* trianglePointer = &square[0], colorPointer = &colors2[0])
{
gl.EnableClientState(gl.GL_VERTEX_ARRAY);
gl.VertexPointer(2, gl.GL_FLOAT, 0, (IntPtr)trianglePointer);
gl.EnableClientState(gl.GL_COLOR_ARRAY);
gl.ColorPointer(4, gl.GL_FLOAT, 0, (IntPtr)colorPointer);

gl.DrawArrays(gl.GL_TRIANGLE_STRIP, 0, 4);
gl.DisableClientState(gl.GL_VERTEX_ARRAY);
gl.DisableClientState(gl.GL_COLOR_ARRAY);
gl.Flush();
}

Does anyone see anything wrong with this? I'm sure there is :)

if you want a quad...
try this:


float[] square = new float[] {
0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f,
1.0f, 1.0f, 0.0f,
1.0f, 0.0f, 0.0f,
};

i dont know if it works with 2d data :S


fixed (float* trianglePointer = &square[0], colorPointer = &colors2[0])
{
gl.EnableClientState(gl.GL_VERTEX_ARRAY);
gl.VertexPointer(3, gl.GL_FLOAT, 0, (IntPtr)trianglePointer);
gl.EnableClientState(gl.GL_COLOR_ARRAY);
gl.ColorPointer(4, gl.GL_FLOAT, 0, (IntPtr)colorPointer);

gl.DrawArrays(6/*6 = gl.GL_QUAD*/, 0, 4);
gl.DisableClientState(gl.GL_VERTEX_ARRAY);
gl.DisableClientState(gl.GL_COLOR_ARRAY);
gl.Flush();
}


the wrapper dont have gl.GL_QUAD ... i wonder why
same as with gl.Begin and gl.End and few others

so this should work ;)

leonatan25
26th June 2009, 11:25 AM
the wrapper dont have gl.GL_QUAD ... i wonder why
same as with gl.Begin and gl.End and few others
It's not the wrapper, it's OpenGL ES that lacks these features. :)