Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (522)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (589)
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 1309 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
Function=[Unknown.]
Library=(N/A)

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(BejeCanvas.java:143)
     at beje.BejeCanvas.initTexture(BejeCanvas.java:113)
     at beje.BejeCanvas.init(BejeCanvas.java:85)
     at beje.BejeCanvas.<init>(BejeCanvas.java:64)
     at beje.Main.run(Main.java:41)
     at beje.Main.main(Main.java:81)

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.

Thanks,
Ed

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 »

Quote


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
Grin
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 http://www.realityinteractive.com) 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!
Ed
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.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xFryIx (62 views)
2014-11-13 12:34:49

digdugdiggy (41 views)
2014-11-12 21:11:50

digdugdiggy (34 views)
2014-11-12 21:10:15

digdugdiggy (30 views)
2014-11-12 21:09:33

kovacsa (52 views)
2014-11-07 19:57:14

TehJavaDev (56 views)
2014-11-03 22:04:50

BurntPizza (55 views)
2014-11-03 18:54:52

moogie (70 views)
2014-11-03 06:22:04

CopyableCougar4 (70 views)
2014-11-01 23:36:41

DarkCart (156 views)
2014-11-01 14:51:03
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org 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‑gaming.org
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!