Jump to content

  • Log In with Google      Sign In   
  • Create Account


Portable graphics programming?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
10 replies to this topic

#1 vinnyvicious   Members   -  Reputation: 356

Like
0Likes
Like

Posted 08 February 2014 - 05:00 PM

After analyzing the source-code of games like Doom, Abuse and Wolf3D, and inspecting their ports to SDL and other platforms, i'm curious about the architecture and techniques used for rendering. They don't use SDL or any other platform-specific code for rendering sprites or text to the screen, neither they use it for sound. So, porting the graphics part is quite easy. 

 

Is this the job of a software renderer? Where i can find more information about 2D software renderers? 3D might be good use too, but i'm curious about implementing a 2D game entirely in software, relaying in SDL only for the platform-specificity.



Sponsor:

#2 richardurich   Members   -  Reputation: 1187

Like
0Likes
Like

Posted 08 February 2014 - 06:44 PM

The original Doom and Wolf3D most certainly had platform-specific code. I have no idea what Abuse is, so I won't comment on their approach. SDL Doom uses SDL's rendering. So I'm left scratching my head on what code you're looking at that doesn't use SDL nor any platform-specific code to render. Unless you're looking at code that uses OpenGL to render, which is available on a lot of platforms.

 

You can use SDL's rendering functions if you're already going to use SDL to avoid platform-specific code. If you're using SDL2, it will even use hardware acceleration when able. There is no requirement that other software renderers support a lot of platforms, and often they do not. If there's a reason you don't want to use SDL for rendering even though you're already using it for other purposes, perhaps you can elaborate on the rationale. What platform are you targeting that SDL supports outside of rendering, but not in rendering?



#3 vinnyvicious   Members   -  Reputation: 356

Like
0Likes
Like

Posted 09 February 2014 - 05:44 AM

Wolf3D has direct framebuffer access and renders a full bitmap into SDL. That's what i mean.



#4 richardurich   Members   -  Reputation: 1187

Like
0Likes
Like

Posted 09 February 2014 - 07:53 AM

Wolf3D ports replace the direct framebuffer access, which is why you're seeing rendering to bitmap. On most hardware you'd ever use now, you will not have direct framebuffer access.

 

If you want to render to bitmap first, you can do that. With SDL, you'd use SDL_SetRenderTarget. You can even SDL_LockTexture and mess with the texture pixel-by-pixel however you want. Or you could just make your own bitmap altogether and write your own draw functions. I don't recommend any of this, and still think you should just use SDL since you're already using SDL.

 

You could also use an old version of OpenGL ES to get portability. I suppose it's even more portable than SDL, and it's certainly more portable than a software renderer that has system-specific optimizations so it can run at a less terrible speed. Although you're already tied to SDL's portability, so I still have no idea why you don't just use SDL.



#5 vinnyvicious   Members   -  Reputation: 356

Like
0Likes
Like

Posted 09 February 2014 - 03:00 PM

Do you know any tutorials or books on rendering directly to the framebuffer? I would love to learn more about it, and write a small engine with this support. It's amazing for porting to non-standard platforms. (DC, PS1, etc.)



#6 richardurich   Members   -  Reputation: 1187

Like
0Likes
Like

Posted 09 February 2014 - 03:51 PM

Writing directly to the framebuffer means you're going to deal with hardware-specific bugs, timing requirements for the bus and for the video hardware, etc. that normally get handled by drivers. It is a very, very bad idea to write directly to the framebuffer unless you are actually writing a video driver. Just write to a bitmap and blit it every frame.

 

On Windows, you can't directly access the framebuffer unless you're a graphics driver. For old versions of Windows, there were bugs you could exploit to gain access, but you'd usually just crash the OS anyways. SoftICE did the best job, and even they failed to run on tons of hardware. If you are writing a graphics driver, you'd be passed the address of the framebuffer by Windows. You'd want to learn Windows Display Driver Model (WDDM).

 

On Linux, I think you still can access the framebuffer directly at 0xd0000000. No clue if that would work on 64-bit. If you're going to mess with the framebuffer on Linux, you should probably use fbdev.



#7 vinnyvicious   Members   -  Reputation: 356

Like
0Likes
Like

Posted 09 February 2014 - 07:02 PM

No, no. I mean creating a virtual framebuffer with my bitmap pixels and then streaming that to the hardware framebuffer using the driver API. At least, that's how i did on my Wolf3D SDL port.


Any other book other than Michael Abrash's about virtual fbs?

Edited by jbadams, 13 April 2014 - 01:36 AM.


#8 richardurich   Members   -  Reputation: 1187

Like
0Likes
Like

Posted 13 February 2014 - 11:36 AM

Michael Abrash? Are you reading about Mode X rendering on VGA hardware or something? Those types of optimizations will do absolutely nothing for you on modern systems that have to emulate VGA. It's certainly fun to read about the cool stuff we did to extract every bit of performance on a 386 with a VGA chip, but not all that useful to portable code writing.

 

What you are describing is just rendering to a texture and then displaying said texture. But you seem to want resources on how to more effectively restrict your options when rendering to texture, which is pretty much the opposite of what books teach. Books teach to unrestrict you, not to restrict you.

 

If you want to write portable code, read about portable code and write in an environment that requires portable code. Use SDL. Or use NaCl and you'll run on PC, iOS, Android, and anywhere else Chrome exists. But you don't seem to want to use the tools available for portable coding either, so I'm at a loss trying to figure out what you even want.



#9 zzzz....   Members   -  Reputation: 88

Like
0Likes
Like

Posted 15 February 2014 - 10:24 AM

Hello,
 
Copied from a post of mine in the Multiplayer forum
 
This is my impoverished map of the world right now:
 
1) C++ + SDL 2.0 + OpenGL ES 2.0 compliant -> Native application (Windows/OSX/iOS/Android/Linux)
2) C++ + SDL 2.0 + OpenGL ES 2.0 compliant -> LLVM -> Emscripten -> Browser (Chrome and Firefox + others)
 
This allows for you to make a C++ framework where you have different renderers (minimal variations of OpenGL commands) and that would cover almost the whole market with no plug-in install required.
 
Since you mentioned platformers and sprite based games, those can be emulated with calling different quad rendering commands in OpenGL. Of course if you prefer going old school you could simply generate the pixels yourself, then copy them to the graphics buffer via a texture.

Edited by jbadams, 15 April 2014 - 02:19 AM.
Restored post contents from history.


#10 Paradigm Shifter   Crossbones+   -  Reputation: 5265

Like
0Likes
Like

Posted 15 February 2014 - 11:29 AM

Do you know any tutorials or books on rendering directly to the framebuffer? I would love to learn more about it, and write a small engine with this support. It's amazing for porting to non-standard platforms. (DC, PS1, etc.)

 

Rendering directly to the framebuffer would be terribly inefficient on the PS1.


"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

#11 vinnyvicious   Members   -  Reputation: 356

Like
0Likes
Like

Posted 09 March 2014 - 06:38 PM

 

Hello,
 
Copied from a post of mine in the Multiplayer forum
 
This is my impoverished map of the world right now:
 
1) C++ + SDL 2.0 + OpenGL ES 2.0 compliant -> Native application (Windows/OSX/iOS/Android/Linux)
2) C++ + SDL 2.0 + OpenGL ES 2.0 compliant -> LLVM -> Emscripten -> Browser (Chrome and Firefox + others)
 
This allows for you to make a C++ framework where you have different renderers (minimal variations of OpenGL commands) and that would cover almost the whole market with no plug-in install required.
 
Since you mentioned platformers and sprite based games, those can be emulated with calling different quad rendering commands in OpenGL. Of course if you prefer going old school you could simply generate the pixels yourself, then copy them to the graphics buffer via a texture.
 
spinningcube

 

 

While i agree with you that this is a pretty standard way of portability for modern games, i'm looking to design a versatile and simplistic architecture. I'm trying to write a very simple game engine, written in C, capable of small 2D platformers, RPGs and so on. The biggest objective is making the engine highly portable across different devkits. Currently, the DC, PS1, N64 and GBA. All of them, C89-compatible and easy to render whole bitmaps to the screen... but not so easy to load and handle separate assets. That's why my questions is about rendering to the whole screen at once.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS