Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (593)
Games in Android Showcase (168)
games submitted by our members
Games in WIP (646)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  SWT & OpenGL  (Read 1482 times)
0 Members and 1 Guest are viewing this topic.
Offline trigun008

Junior Newbie

Java games rock!

« Posted 2003-06-23 15:31:23 »

Hi All,

Not sure if this is the right place to post this, but I am trying to write a game using SWT and its OpenGL Plugin.  I am running into problems when I try to load textures and enable alpha blending.  I am loading textures from a PNG file that has an alpha channel defined.  The image is loaded by a ImageLoader object into a ImageData object.  So far so good.  Then when I try to create the texture through the glTexImage2D()
call, an exception is thrown.  The following is the exact call:

GL.glTexImage2D(GL.GL_TEXTURE_2D, 0, 4, source[0].width, source[0].height, 0,      GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, source[0].data);

And I get the following error:

An unexpected exception has been detected in native code outside the VM.
Unexpected Signal : EXCEPTION_ACCESS_VIOLATION occurred at PC=0x69042298

NOTE: We are unable to locate the function name symbol for the error
     just occurred. Please refer to release documentation for possible
     reason and solutions.

Current Java thread:
     at org.eclipse.swt.opengl.GL.glTexImage2D(Native Method)
     at beje.BejeCanvas.loadTexture(
     at beje.BejeCanvas.initTexture(
     at beje.BejeCanvas.init(
     at beje.BejeCanvas.<init>(
     at beje.Main.main(

Dynamic libraries:
0x76AC0000 - 0x76ADD000       C:\WINDOWS\SYSTEM\IMAGEHLP.DLL

Local Time = Mon Jun 23 03:25:11 2003
Elapsed Time = 6
# The exception above was detected in native code outside the VM
# Java VM: Java HotSpot(TM) Client VM (1.4.1_03-b02 mixed mode)
# An error report file has been saved as hs_err_pid4293977641.log.
# Please refer to the file for further information.


I don't get this error if the 3rd argument of lTexImage2D is changed from 4 to 3, and when GL.GL_RGBA is changed to GL.GL_RGB.

I am wondering if anyone has came across this problem, or have a clue why this is happening.   Huh Any help is greatly appreciated!  Thanks!

btw, I am using Windows 98.


Offline Rob Grzywinski

Junior Devvie

Reality Interactive

« Reply #1 - Posted 2003-06-23 20:05:29 »

Other than ensuring that:

 source[0].data.length == (source[0].width * source[0].height * 4 /*RGBA*/)

I cannot think of anything.  Since it works switching from 4 -> 3 I would definitely believe that the array is of the incorrect size.

I don't remember running into any problems when I used the SWT OpenGL plugin.  I will be getting out an JOGL port to SWT shortly.  I am working through a mire of goo trying to get communication between myself and the Eclipse and JOGL teams.  It's resolving itself slowly.
Offline nech_neb

Junior Devvie

Java for LIFE !!!

« Reply #2 - Posted 2003-06-24 00:49:57 »


I don't remember running into any problems when I used the SWT OpenGL plugin.  I will be getting out an JOGL port to SWT shortly.  I am working through a mire of goo trying to get communication between myself and the Eclipse and JOGL teams.  It's resolving itself slowly.

Thanks very much !!
The OpenGL SWT community seems rather small...
But I'm really thankful that people haven't given
up on it.

I was wondering if you have an inside view on SWT
people's direction right now :

Is there furthure development being done for the
SWT OpenGL plugin? Or is the consensus of the SWT
people to trash it and try to integrate with JOGL??

Anyways, I'm eagerly awaiting your JOGL port to SWT
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Rob Grzywinski

Junior Devvie

Reality Interactive

« Reply #3 - Posted 2003-06-24 01:10:14 »

I have been in touch with the Eclipse people and I do not have a firm commitment on their direction.  The word is that they have a lot of work to do and OpenGL is not a committed item for 3.0.  This basically means that it will get attention as the individual developers have time.

I have my biz dev team starting to work with the Eclipse project to see how we can move forward in a manner that is mutually beneficial while providing the best OpenGL support for SWT.

My personal opinion is that once our product suite is available (you can get some hints from our site at then there will be A LOT of people jumping on the SWT bandwagon -- so stick with it.  Of course this opinion is highly biased  Smiley
Offline trigun008

Junior Newbie

Java games rock!

« Reply #4 - Posted 2003-06-24 05:09:55 »

Thank you sooo much!   Smiley
Ya, the array size was incorrect.  After fixing that, it doesn't crash anymore.

Also got my desired blending to work now!

Thank you!
Offline Rob Grzywinski

Junior Devvie

Reality Interactive

« Reply #5 - Posted 2003-06-24 14:20:16 »

Glad that I could help.  If I may be so bold as to offer a few suggestions that may help you down the road based on the snippet that you sent (and, yes, I know it's a snippet):

1.  Comment.  Comment, comment, comment.  The extra 5 minutes that you spend commenting will save 5 hours later.  For example, you have a few constants in your expression.  When you're deep in the mix looking for a pesky bug, you'll question everything that you did.  "Why did I choose 4?" will come to mind at first glance.  Just add a 2 second comment to help:

   GL.glTexImage2D(GL.GL_TEXTURE_2D, 0 /* mipmap*/, 4 /*RGBA*/, source[0].width, source[0].height, 0 /*border*/, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, source[0].data);

2.  Code defensively.  JDK 1.4 provided us with assertions.  Use them.  Taking 5 seconds to add an assertion before the glTextImage2D() call (which leaves the protection of the JVM and ventures into the unknown) would save hours of debugging later.  Just remember that assertions are DISABLED by default.  Get in the habit of adding assertions as you code.  As you code more and more, you'll get more adept a knowing the common gotcha points (mainly arrays and null pointers) and just add assertions without even thinking.

3.  As somewhat a rule of thumb, if you call into an array more than once, make a local reference.  This has less to do with performance than it does with anticipating refactoring and debugging, though accessing array can be expensive.  Following along with #2, it's easier to add the assert statement if you make a local reference.  It's also easier to create a difficult to find bug if you have the same base statement (source[0]) three times as the eye will tend to scan it quickly rather than focus on it.

Just trying to be helpful.
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

deepthought (34 views)
2015-06-30 15:39:44

deepthought (38 views)
2015-06-30 15:39:09

deepthought (50 views)
2015-06-30 15:36:52

Za\'Anzabar (21 views)
2015-06-29 05:44:54

TritonDreyja (38 views)
2015-06-24 17:10:40

CopyableCougar4 (35 views)
2015-06-23 00:34:45

BurntPizza (39 views)
2015-06-21 20:36:46

cookiecompiler (82 views)
2015-06-11 15:42:53

cookiecompiler (45 views)
2015-06-11 15:41:14

NegativeZero (75 views)
2015-06-11 09:49:18
How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21

Resources for WIP games
by kpars
2014-12-18 10:26:14 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!