Tell me more ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I think it would be very useful if there was a game engine that works like any other game engine (such as Unity, for example), but has the capability of you inserting native OpenGL code. Like for example, you could insert the following lines of code (simple, just for example) and it would work like it would in an OpenGL application, but it would run side-by-side the game engine's code:

glColor3f(1.0f, 0.0f, 0.0f);

glBegin(GL_TRIANGLES);
    glVertex3f(0.0f, 0.0f, 0.0f);
    glVertex3f(1.0f, 0.0f, 0.0f);
    glVertex3f(1.0f, 1.0f, 0.0f);
glEnd();

glFlush();
share|improve this question
6  
what is your question? – pivotnig Feb 4 at 16:09
First, most engines that use OpenGL are using modern OpenGL (2.1+), not the 1992 immediate-mode OpenGL 1.0. You have very little to work with if you're not using the engine's shaders, etc. Second, this runs the risk of the user messing up the engine's expected OpenGL state and could mess up any rendering done after it. Third, how/when would your code be run? Most engines use some kind of scene graph to optimize rendering and draw everything in one go... A well designed engine won't require this kind of functionality. – Robert Rouhani Feb 4 at 16:14
1  
1  
The GL class in Unity is an OpenGL-inspired API (they generally use D3D when available for actual rendering), and not at all intended for efficient rendering; it's a debug API, mostly. – Sean Middleditch Feb 4 at 20:11
3  
@DantheMan So you're asking if such a thing is a good idea? If it's possible? If such game engines exist? How you would make a game engine like that? Your question in the title is not actually a question. – Byte56 Feb 4 at 22:24
show 2 more comments

closed as not a real question by Trevor Powell, Byte56, mh01, Josh Petrie, Sean Middleditch Feb 5 at 4:44

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, see the FAQ.

1 Answer

No, it would be dangerous.

No game engine beyond the most basic uses glBegin/glEnd calls any more - they're dead, forget about them, they're over.

Every rendering engine manages it's own draw calls and state in it's own way; what you're proposing is to totally disrupt that management and allow injection of arbitrary GL code.

Any state management the engine implements is destroyed. Modders can wreck things by changing buffers, shaders, textures at times when the engine wouldn't; this can cause crashes at worst and wrong renderings at best. The engine can no longer rely on current states being what they should be.

It affects portability. The engine can no longer be ported to GL ES because it has to remain able to support whatever legacy garbage a careless modder chooses to inject. It can't be ported to D3D, XBox 360 or PS3 because it just flat out won't work. It can't be ported up to a higher GL_VERSION because of the same legacy garbage. It may not be even possible to run on different hardware if a modder uses a vendor-specific extension.

This is just not a good idea.

share|improve this answer
The glBegin and glEnd calls are simply placeholders, for simple example. – Dan the Man Feb 5 at 17:28
Placeholders or not, the rest of the points made still stand. – mh01 Feb 6 at 0:41

Not the answer you're looking for? Browse other questions tagged or ask your own question.