Exception in launch application in libgdx - libgdx

LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration();
cfg.title = "my-gdx-game";
cfg.useGL20 = false;
cfg.width = 480;
cfg.height = 320;
new LwjglApplication(new MyGdxGame(), cfg);
I use this code in my desktop launcher class, but I get GdxRuntimeException: OpenGL is not supported by the video driver.
any help ?

Its probably because:
OpenGL is not supported by your video driver
Libgdx on the desktop requires at least OpenGL 1.5 be supported by your desktop video card (to emulate OpengGL ES 1.x). OpenGL should be included with your OS's graphics card drivers (you should include details about your platform in your question). See the OpenGL Getting Started Wiki for some hints.
See also libGDX Exception in thread "LWJGL Application"

Related

How to Support JFrame transparency on Linux

I'm making a java swing application which is executed on linux machine and shown in users' computer by X11 forwarding.
I want to apply rounded corners on JFrame, so I changed its background to new Color(0,0,0,0).
The frame is now hidden on my computer(windows 10). But the linux(centOS7) doesn't seem not to support Window Frame transparency.
It returns error below.
Exception in thread "AWT-EventQueue-0"
java.lang.UnsupportedOperationException: PERPIXEL_TRANSLUCENT translucency is not supported
at java.awt.Window.setBackground(Window.java:3844)
at java.awt.Frame.setBackground(Frame.java:988)
Without changing its background works fine on both but the default background is also shown.
Is there any way to make rounded corners??
Thank you.
Not every platfrom supports transparency.
Take a look at https://docs.oracle.com/javase/tutorial/uiswing/misc/trans_shaped_windows.html
chapter
Determining a Platform's Capabilities
import static java.awt.GraphicsDevice.WindowTranslucency.*;
// Determine what the default GraphicsDevice can support.
GraphicsEnvironment ge =
GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = ge.getDefaultScreenDevice();
boolean isUniformTranslucencySupported =
gd.isWindowTranslucencySupported(TRANSLUCENT);
boolean isPerPixelTranslucencySupported =
gd.isWindowTranslucencySupported(PERPIXEL_TRANSLUCENT);
boolean isShapedWindowSupported =
gd.isWindowTranslucencySupported(PERPIXEL_TRANSPARENT);
To be tested, but I don't thing that X11 forwarding allows transparency !
EDIT
Just made a test, through ssh -X, java version 1.8.0_162-b12
and it works.
What is your java version ?

sound effects are not playing in my game

I am developing a game for windows phone. The target version of game is 7.1 and 7.1 games and apps will be supported on wp8 devices.
Here is my code:
public SoundEffect l1;
public SoundEffectInstance level1sound;
l1 = contentManager.Load<SoundEffect>("sound/level1");
level1sound = l1.CreateInstance();
level1sound.IsLooped = true;
level1sound.Play();
Gaming sounds are working fine in simulator of 7.1 but when I deploy on wp8 device nothing works.
How to fix this issue?
If you develop Silverlight game, you must call FrameworkDispatcher.Update() method in every frame to dispatch messages that are in the XNA Framework message queue
sound file properties should set to soundeffect type

starling atf textures not displaying

So i'm running air 3.7, the latest starling frameworks, added -swf-version=20 -target-player=11.7 in compiler arguments and running the code
[Embed(source="/assets/wtf4.atf", mimeType="application/octet-stream")]
private static const why:Class;
var data:ByteArray = new why();
var texture:starling.textures.Texture = starling.textures.Texture.fromAtfData(data);
var image:Image = new Image(texture);
addChild(image);
if I'm using the starling atf that came with the framework demo it works fine, but whenever i try to display my own png that I create in photoshop converted into atf it gives me a error saying
ArgumentError: Error #3677: Texture decoding failed. Internal error.
The image I'm trying to convert into atf is just a red square png with 512x512 sizes with the compiler arguments: png2atf -c -i example.png -o example.atf. I'm not sure whether my flash builder isn't setup to decode atfs or if i'm creating the atfs wrong for some reason, if someone could shed some light on this it would be awesome!
When creating the .atf, did you created mipmaps also? If not, you need to set the second argument of the Texture.fromAtfData() function to false - don't use Mipmaps.
From Starlign wiki:
"If you omit mipmaps, you must set the parameter “useMipMaps” of the “Texture.fromAtfData()” method to “false”! Otherwise, you'll get a run-time error."
http://wiki.starling-framework.org/manual/atf_textures
The latest version of ATF requires AIR 3.8 (which is currently in beta). You need to download the AIR installer, and the latest AIR SDK. More details here: http://forum.starling-framework.org/topic/error-3677-texture-decoding-failed-internal-error

JPEGEncoderOptions is undefined

I get a runtime error that JPEGEncoderOptions is an undefined variable when running the below code in AIR 3.5:
rawBitmapData.encode(rawBitmapData.rect, new JPEGEncoderOptions(), rawByteArray);
Make sure the following files in your sdk are up-to-date in the folder \yoursdk\frameworks\
air-config.xml
flex-config.xml
airmobile-config.xml
Update this:
<target-player>11.5</target-player>
<swf-version>18</swf-version>
This ensures your runtime is up-to-date
See : Use Adobe Air 3.3 SDK with Flash Builder
You may be missing an import of the flash.display.JPEGEncoderOptions package, or you may fully quality the package inline as below.
Example from Adobe Flash Platform Compressing bitmap data:
// Compress a BitmapData object as a JPEG file.
var bitmapData:BitmapData = new BitmapData(640,480,false,0x00FF00);
var byteArray:ByteArray = new ByteArray();
bitmapData.encode(new Rectangle(0,0,640,480), new flash.display.JPEGEncoderOptions(), byteArray);
If you get a runtime error, it can't be a missing import. You must be running it in a Flash Player that's too old, or an AIR runtime that's too old.
I've tested PNG encoding a while back and did this:
var bitmapData:BitmapData = yourBitmapDataHere;
if("encode" in bitmapData)
{
// use the native encode method
png = bitmapData.encode(bitmapData.rect, new PNGEncoderOptions(false));
}
else
{
// use old png encoder (from AS3CoreLib)
png = PNGEncoder.encode(bitmapData);
}
This effectively tests if your player or runtime environment supports BitmapData's .encode() method. If that test fails, you must be using a player that's too old.
Are you definitely including the class at the top of your code?
You need the latest Flex SDK to compile that, because those classes were only introduced in Flash Player 11.3. Flex SDK 4.6 worked for me, while Flex SDK 4.5 and lower gave me the same compiler error.
If its a runtime error, then you are running the content in a lower AIR version, or in a lower Flash Player version. Use the following method to fallback to normal code if the class is not present in the FP version you are running in. Useful for web content.
try {
// use FP 11.3 encoding
var options:Object = new JPEGEncoderOptions(quality);
var bytes:ByteArray = new ByteArray();
bitmap.encode(bitmap.rect, options, bytes);
} catch (e:Error){
// use manual JPEG encoding
}
It may be that you are missing a playerglobal for the version you are targeting or it's an incorrect playerglobal.swc in the SDK's player directory.
Download the latest Apache Flex SDK and switch to that if you can and try to create an instance of the class in a new project or your main application.
Honestly, I think it was a bug in the compiler or playerglobal. When I looked at the sdk folders I think that the playerglobal.swc might have been incorrect (all versions are named playerglobal.swc) OR it might have been the fact that I only had one directory in the SDK I was using and it had an "/11.2/playerglobal.swc" but no other folders. I think I would have needed a directory called "/11.5/playerglobal.swc" to have -swf-version make any difference.
It would be nice if the compiler threw an error when the playerglobal for the swf-version was not found at compile time. Go into the SDK folder and download and add the playerglobals to the SDK directory for the minimum targeted player to use this class.
In my Flex 4.6.0 SDK player directory, "$Flash Builder/sdks/4.6.0/frameworks/libs/player/" the swcs in:
11.1 dated 10/30/2012 351kb
11.2 dated 01/27/2013 352kb
11.5 dated 11/23/2014 351kb
11.6 dated 01/27/2013 352kb
15.0 dated 11/20/2014 388kb
In the Apache Flex 4.14RC install is:
11.1 dated 10/30/2012 351kb
11.2 dated 01/27/2013 352kb
11.5 dated 11/23/2014 351kb
11.6 dated 01/27/2013 352kb
15.0 dated 01/12/2015 388kb
It's possible something was installed somewhere along the way that is out of sync.

Flash Player 10.1 for Flash Professional CS4 playerglobal.swc?

Adobe released projector, debugger and plugin for Flash 10.1 yesterday. on my Mac i've installed the standalone player and debugger in Adobe Flash CS4/Players/ and Adobe Flash CS4/Players/Debug respectively.
however, i think i need to download the globalplayer.swc for 10.1 so that Flash CS4 IDE is directed to use the new players.
i've searched but i could only find the globalplayer.swc that was released during the 10.1 betas, and i'm not sure if that's the .swc i should use for the final 10.1 release.
Adobe's site doesn't mention anything about replacing the .swc to use 10.1 in CS4, so i'm not sure if it's necessary.
i've tried creating actionscripts to include flash.ui.Multitouch and flashx.textLayout and neither can be found. i have no idea how to make Flash Professional CS4 use the new APIs available in Flash Player 10.1
suggestions?
FRAME SCRIPT:
import flash.ui.Multitouch;
var myTextField:TextField = new TextField();
myTextField.width = 200;
addEventListener(Event.ENTER_FRAME, enterhandler);
function enterhandler(e:Event):void
{
var support:Boolean = Multitouch.supportsTouchEvents;
switch (support)
{
case true: myTextField.text = "Touch events supported";
break;
case false: myTextField.text = "Touch events not supported";
break;
default: myTextField.text = "unknown";
}
addChild(myTextField);
}
ERROR: (continuous enter frame event error)
ReferenceError: Error #1065: Variable flash.ui::Multitouch is not defined.
at multitouchtest_fla::MainTimeline/enterhandler()
ReferenceError: Error #1065: Variable flash.ui::Multitouch is not defined.
at multitouchtest_fla::MainTimeline/enterhandler()
ReferenceError: Error #1065: Variable flash.ui::Multitouch is not defined.
at multitouchtest_fla::MainTimeline/enterhandler()
You can get the official playerglobal.swc for Flash Player 10.1 from the Flex 4.1 SDK:
http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4
It's in the frameworks/libs/player/10.1 directory.
Also you can check if the device supports gestures and touch using these statics:
Multitouch.supportsGestureEvents
Multitouch.supportsTouchEvents
Not sure whether it's up to date but it's at least for 10.1 beta:
http://labs.adobe.com/downloads/flashplayer10.html
I had similar issues with my Flash CS4, recently i have found one important link for that check out
http://swfhead.com/blog/?p=709
http://swfhead.com/blog/?p=133
hope it helps... :)