Showing posts with label media. Show all posts
Showing posts with label media. Show all posts

Sunday, June 12, 2011

Sgine + VLC = Awesomeness

I have long been interested in being able to play video in OpenGL and if you look back at previous posts I've made here, as well as posts at matthicks.com you'll see most of my previous work has been around the use of JMC (one of the only cool things to come out of JavaFX 1.x). However, it had significant problems playing specific kinds of videos and was just generally buggy. In this new remix of Sgine I'm adding a new project that provides complete support for VLC through the use of the VLCJ project.

Here are a couple screenshots taken in my testing using "Better Off Ted":





Still very preliminary, but both sound and video are displaying flawlessly on the screen. The great features of VLC include the ability to play practically any video file or stream, record from a webcam, watch DVDs, play audio, and even record the desktop. This will open the door for lots of useful non-game applications utilizing Sgine I hope.

It will probably be a while before I commit this new project as I still have a lot of tweaking and customization to do before it's ready. Additionally, this will likely rely on the still undefined scenegraph model for this iteration so check back frequently as there's much more to come.

Saturday, July 31, 2010

Writing Tetris

I'm currently in the process of writing a couple small games in an effort to use Sgine for some real-world game development in order to fill in any wholes and evaluate how easy it is to use in a complete application. The first simple game on my agenda is Tetris. I'd say I'm about half-way finished writing it, and I think it's coming along pretty well:



As you can see I'm using 3d cubes to represent pieces and though the game itself is still played on two dimensions the appearance is in 3d slightly translucent and rotated on the x-axis in order to give it a little more depth. I'll post a link to play the game once it is finished, but I know many people have asked if there are any practical examples of Sgine and I just wanted to send out this note to let everyone know that there will be soon. :)

Also, you can't see it from the screenshot obviously, but I have the original Tetris theme playing in the background on loop. Oh, how it takes me back to playing on the Gameboy as a kid. :)

Sunday, June 13, 2010

MediaPlayer Component

Getting JMC from JavaFX 1.3 to work within Sgine took a bit longer than I anticipated. In JavaFX 1.2 it was a simple matter of calling paintVideoFrame and using a BufferedImage to draw onto and then convert to a texture. Fortunately for performance in JavaFX 1.3 they changed to working with NIO buffers instead, but unfortunately that created a much bigger headache trying to figure out how to access and properly use it since there is absolutely no documentation and the source code is not freely available. However, after several days of poking around it has finally paid off. There are still some optimizations that should be done but on my machine I'm able to watch H.264 video at 4,000fps in synchronous mode (direct rendering in OpenGL) and 5,200fps in asynchronous mode (pushing data to the buffer in another thread via PBO).

Here's a screenshot of the working example:


Here's the source required to run the video:
package org.sgine.ui

import org.sgine.core.Resource

import org.sgine.render.Renderer
import org.sgine.render.scene.RenderableScene

import org.sgine.scene.GeneralNodeContainer
import org.sgine.scene.ext.ResolutionNode

object TestMediaPlayer {
 def main(args: Array[String]): Unit = {
  val r = Renderer.createFrame(640, 480, "Test MediaPlayer")
  
  val scene = new GeneralNodeContainer() with ResolutionNode
  scene.setResolution(640, 480)
  
  val component = new MediaPlayer()
  val url = new java.net.URL("http://sun.edgeboss.net/download/sun/media/1460825906/1460825906_2956241001_big-buck-bunny-640x360.flv")
  component.source := Resource(url)
  scene += component
  
  r.renderable := RenderableScene(scene)
  
  component.play()
 }
}

As always the goal is to keep the API as simple as possible and hopefully 27 total lines of code is simplistic enough. :)

There's still much left to do as far as introspection and control of video playing as well as controls to allow user interaction with the player, but we've finally got a fast and reliable means of playing all popular audio and video formats and I will probably divert back to more important work for a while. :)
Scala Engine for high-performance interactive applications.