
2D Graphics Engine
Posted Monday, 4 February, 2008 - 21:07 by lubos inOverview
Hello, so I'm slowly progressing with my OpenTK, OpenGL and whole C# adventure. I'm taking opportunity to start development diary so here I am :) I have started writing a small engine with OpenTK, that handles ONLY 2D rendering, but completely removes need to use any OpenGL function, while cooperating with other parts of OpenTK. I haven't decided for the name yet but that's not important I think.
The goal is to build a small, easy to use engine capable of building small 2D games together with OpenTK.
Engine doesn't use any scene-graph, you must draw each image every frame manually. I think this way it's cleaner and faster when working with 2D graphics. However, Gui uses a GuiManager which will draw all widgets at once.
To use engine, engine code is linked directly with game code. If you don't need some parts of engine you just don't link them.
The colors are passed as unsigned bytes (0-255).
The positions and sizes are passed as integers, meaning the x and y position of pixel on screen, where 0,0 is in the top left part of the screen.
Features implemented:
- Images loading/drawing (rotating, scaling, blending, drawing part of image)
- Animations(Sprite) (frames rendered from one texture, same options as image)
- Particle systems (uses single VBO, Point sprites)
- Custom VBOs
Features planned:
- Basic Gui(first widgets done)
- Complete documentation/examples(some examples done)
- Shaders
| Attachment | Size |
|---|---|
| Mines.zip | 464.13 KB |
| PointSprites.zip | 467.25 KB |
| Game.zip | 476.52 KB |
| Engine.zip | 23.6 KB |







Comments
Re: 2D Graphics Engine
Nice! Did performance improve?
Re: 2D Graphics Engine
Hm I didn't notice any performance gain. The thing is that all particles are still moving so I must rebuild VBO every time on update, is this correct?
Re: 2D Graphics Engine
Of course, as long as the CPU has to update all these particles, it will be the bottleneck. I wondered if there was any thing to be gained anyway (maybe the driver would be better able to optimize the data before sending it?), but it looks not :)
Re: 2D Graphics Engine
I tried to run engine on other pc but the window just blinked for the second and then exited without any error message, do you have any idea why it crashes on other pc? It works here normal both in debug and release mode, I use VC# 2008 express
Re: 2D Graphics Engine
Ok, required info for the failing platform:
Suggestions: invoke your program through the commandline. See if any exception is reported there.
It will also be very helpful to compile a debug version of OpenTK and run Examples.exe on that PC. Examples.exe generate a debug.log which will help pinpoint the problem.
To compile OpenTK, open a commandline window and head to opentk-0.9.0/Build. Then type:
Press finish to convert the project to VC# 2008 and press F6 to build. Zip up the
bin/Debug/Exaples/folder and try it on the problematic PC.Re: 2D Graphics Engine
1. Windows Vista, comes with .Net 3.0 I think
2. Same as here, nVidia GeForce7600gt, 7.15.10.9689
3. 0.9.0
no messages from command line
When I run OpenTK examples they run fine, but when I run "First shader" example, it reports that I need atleast OpenGL 2.0, so it seems like opentk doesnt use hardware acceleration or what?
Re: 2D Graphics Engine
What does
GL.GetStringwith theVendor, Renderer and Versiontokens return?Re: 2D Graphics Engine
If I'm reading the nvidia driver version correctly there, you're running a pretty old driver.
Try updating that?
Re: 2D Graphics Engine
renderer: GDI Generic
vendor: Microsoft Corporation
version: 1.1.0
Re: 2D Graphics Engine
Definitely software accelerated then. The string should read "Nvidia Corporation blah blah blah".
First step is to update the drivers for the video card - I'd give a 90% chance that this will fix the problem.
Second step is to set the monitor at 32bit color.
Is he able to run other *opengl* applications?