Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (542)
Games in Android Showcase (133)
games submitted by our members
Games in WIP (604)
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  
  GL.glMaterialfv  (Read 3889 times)
0 Members and 1 Guest are viewing this topic.
Offline Mac_Systems

Junior Devvie




I love my Java


« Posted 2003-08-03 14:21:27 »

Hello,  Grin

while converting the Lession 36 from Nehe Tutorials.
I ran in a Exception using the GL.glMaterialfv Method.

There the Code :
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
   private void ProcessHelix()                                                                        // Draws A Helix
  {
        float x;                                                                              // Helix x Coordinate
        float y;                                                                              // Helix y Coordinate
        float z;                                                                              // Helix z Coordinate
        float phi;                                                                        // Angle
        float theta;                                                                        // Angle
        float v,u;                                                                        // Angles
        float r;                                                                              // Radius Of Twist
        int twists = 5;                                                                        // 5 Twists


        float [] glfMaterialColor = new float [] {0.4f,0.2f,0.8f,1.0f};                  // Set The Material Color
        float [] specular = new float[] {1.0f,1.0f,1.0f,1.0f};                              // Sets Up Specular Lighting

        FloatBuffer glfMaterialColorBuffer = FloatBuffer.allocate(4);
        FloatBuffer specularBuffer = FloatBuffer.allocate(4);

        glfMaterialColorBuffer = glfMaterialColorBuffer.wrap(glfMaterialColor);
        specularBuffer = specularBuffer.wrap(specular);


        GL.glLoadIdentity();                                                                  // Reset The Modelview Matrix
        GLU.gluLookAt(0, 5, 50, 0, 0, 0, 0, 1, 0);                                    // Eye Position (0,5,50) Center Of Scene (0,0,0), Up On Y Axis

        GL.glPushMatrix();                                                                        // Push The Modelview Matrix

        GL.glTranslatef(0,0,-50);                                                            // Translate 50 Units Into The Screen
        GL.glRotatef(angle/2.0f,1,0,0);                                                // Rotate By angle/2 On The X-Axis
        GL.glRotatef(angle/3.0f,0,1,0);                                                // Rotate By angle/3 On The Y-Axis

        GL.glMaterialfv(GL.GL_FRONT_AND_BACK,GL.GL_AMBIENT_AND_DIFFUSE,glfMaterialColorBuffer);
        GL.glMaterialfv(GL.GL_FRONT_AND_BACK,GL.GL_SPECULAR,specularBuffer);
     


JBuilder said :


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
An unexpected exception has been detected in native code outside the VM.
Unexpected Signal : EXCEPTION_ACCESS_VIOLATION occurred at PC=0x69649BC2
Function=[Unknown.]
Library=C:\WINNT\System32\nvoglnt.dll

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.lwjgl.opengl.CoreGL11.glMaterialfv(Native Method)
      at rendertotexture.Lesson36.ProcessHelix(Lesson36.java:288)
      at rendertotexture.Lesson36.RenderToTexture(Lesson36.java:381)
      at rendertotexture.Lesson36.Draw(Lesson36.java:525)
      at rendertotexture.Lesson36.renderLoop(Lesson36.java:65)
      at rendertotexture.Lesson36.<init>(Lesson36.java:58)
      at rendertotexture.Lesson36.main(Lesson36.java:535)


Is it really the Native Code,or my Code producing the error ?

Bye the Way im using 0.7 of LWJGL
and the NVidia Drivers Version is: 6.14.10.4403
on GeForce 2 MX 400 under Win2k.

Thx,

- Jens


The Network is the Music
http://www.mac-systems.de
Offline princec

« JGO Spiffy Duke »


Medals: 439
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #1 - Posted 2003-08-03 17:46:18 »

Easily fixed: you cannot use indirect buffers for LWJGL operations, you must use direct ones instead:
1  
2  
3  
FloatBuffer glfMaterialColorBuffer = ByteBuffer.allocateDirect(16).order(ByteOrder.nativeOrder()).asFloatBuffer();

   glfMaterialColorBuffer.put(glfMaterialColor).flip();


The flip() is now required too because we use the buffer's current position() and limit() to determine what is actually being passed in to GL. (Limit is not always used but in those functions where you were expecting to type a size parameter and there isn't one -- that's where we use limits)

Cas Smiley

Offline Matzon

JGO Knight


Medals: 19
Projects: 1


I'm gonna wring your pants!


« Reply #2 - Posted 2003-08-03 19:14:41 »

Quote
The flip() is now required too because we use the buffer's current position() and limit() to determine what is actually being passed in to GL.


if you use the buffer with the .get(index) a flip isn't required - is it ?

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline princec

« JGO Spiffy Duke »


Medals: 439
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #3 - Posted 2003-08-03 19:30:46 »

What flip() does is set the limit to the position and the position back to 0.

In LWJGL we are now passing buffers to all functions offset by their position. In some OpenGL commands a size is also specified, ie. the number of elements expected in the buffer. We no longer allow this to be specified arbitrarily; you have to specify the buffer's limit to give the size to GL.

Example:
Old way:
gl.genLists(1, Sys.getDirectBufferAddress(buf));

New way:
buf.position(0).limit(1);
GL.glGenLists(buf);

For most GL functions the limit is not used, for example, in glVertexPointer, where all we are interested in is the position at the time the function is called.

But for those functions where we do use the limit, flip's what you want generally. In the OP's problem above he could just have easily used position(0) or rewind() though.

Cas Smiley

Offline Mac_Systems

Junior Devvie




I love my Java


« Reply #4 - Posted 2003-08-04 07:09:16 »

Thx,

i will try that.   Smiley

Bye the Way , i there somthing in OpenGL you havent Ported or missing right now ?

- Jens


The Network is the Music
http://www.mac-systems.de
Offline princec

« JGO Spiffy Duke »


Medals: 439
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #5 - Posted 2003-08-04 08:01:02 »

Yes, in 0.7 we've started removing methods that are either pointless, pointless in Java, or pointlessly slow.

These means goodbye to most of the methods which take pointers to small arrays, goodbye to most methods taking doubles, goodbye to texture priorities, and goodbye to a bunch of GLU stuff that's just not needed by pro games programmers.

Amongst other things.

Cas Smiley

Offline Mac_Systems

Junior Devvie




I love my Java


« Reply #6 - Posted 2003-08-04 09:14:43 »

Yeah  Grin Grin Grin

I was able to port the "Render To Texture" Code, based on the cpp Code avaible at Nehe in Lesson 36.

I will put it on my Website asap - and post the Link for everbody.

- Jens

The Network is the Music
http://www.mac-systems.de
Offline elias

Senior Devvie





« Reply #7 - Posted 2003-08-04 13:53:24 »

Why is texture priorities removed?

- elias

Offline princec

« JGO Spiffy Duke »


Medals: 439
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #8 - Posted 2003-08-04 15:22:34 »

Texture priorities is an anachronism from when they first thought about implementing textures. The reality of how texturing works turns out to be very different from how the original designers assumed it was going to work.

The short answer is: when you draw a scene, either a texture is in the scene, or it isn't. They don't jostle for priority over who gets to be on the graphics card; they're all required. Any that aren't required are overwritten as new textures are required when the RAM fills up. If you don't have enough texture RAM to fit all the textures in the scene into RAM - you have to upload the difference over the top of something. As the next frame is likely to have the same textures in too, you'll have to replace the bit you've overwritten in the next frame, and then once more upload the difference. The driver is the best at figuring out what texture memory to overwrite; generally it will try to overwrite an existing patch of memory the same size, rather than clobber a big texture.

So I removed the methods because they're a) a waste of space b) don't improve performance one iota and c) confusing

Cas Smiley

Offline cfmdobbie

Senior Devvie


Medals: 1


Who, me?


« Reply #9 - Posted 2003-08-04 15:54:41 »

Well, I have to say I like the trimming that's going on - it's focusing the API nicely to the intended topic.  Users should be a little better isolated from the cruft that's built up in OpenGL over the years, and hopefully their applications will perform better because of it.  I'm just hoping you don't get over-zealous and discontinue support for things that people really do want... Grin

Q1: Is there any intended release date for 0.7 yet?

Q2: And is the reason for not providing a OpenGL10 interface because you don't see any need for it - don't see any cards out there still running 1.0?

Hellomynameis Charlie Dobbie.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline elias

Senior Devvie





« Reply #10 - Posted 2003-08-04 16:23:38 »

We still have some goodies left for 0.7, so there will probably be another pre one of these days. The final will be delayed, which is good, considering our massive API changes (especially the position() and remaining() stuff is sure to break many apps out there).

I don't think 1.0 would be useful at all - IIRC, 1.0 doesn't even have proper support for texture objects and display lists.

- elias

Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Reply #11 - Posted 2003-08-04 17:59:51 »

Quote
and goodbye to a bunch of GLU stuff that's just not needed by pro games programmers.


Does that include quadrics, spheres and cylinders and stuff? Those might not needed by pro's maybe but I found them handy. The newbie idiot that I am.

Offline Mojomonkey

Senior Devvie




ooh ooh eee eeee


« Reply #12 - Posted 2003-08-04 18:09:37 »

Yes, please don't remove quadrics as I use them extensively for visualizing debug info (bounding volumes, etc).

Don't send a man to do a monkey's work.
Offline elias

Senior Devvie





« Reply #13 - Posted 2003-08-04 18:15:18 »

Yes it includes all GLU quadric shapes.

- elias

Offline Mojomonkey

Senior Devvie




ooh ooh eee eeee


« Reply #14 - Posted 2003-08-04 18:19:09 »

Dang, I'm sorry to hear that. I guess it's time for me to think seriously about the transfer to JOGL.  Embarrassed

edit:
Just saw the thread regarding Quadrics being implemented in pure java at puppygames.

Don't send a man to do a monkey's work.
Offline princec

« JGO Spiffy Duke »


Medals: 439
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #15 - Posted 2003-08-04 19:27:39 »

Yes, if anyone wants to help vrm port GLU to Java that'd be very kind Wink

Cas Smiley

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.

Elsealabs (15 views)
2014-12-28 10:39:27

CopyableCougar4 (19 views)
2014-12-28 02:10:29

BurntPizza (24 views)
2014-12-27 22:38:51

Mr.CodeIt (14 views)
2014-12-27 04:03:04

TheDudeFromCI (19 views)
2014-12-27 02:14:49

Mr.CodeIt (26 views)
2014-12-23 03:34:11

rwatson462 (58 views)
2014-12-15 09:26:44

Mr.CodeIt (47 views)
2014-12-14 19:50:38

BurntPizza (96 views)
2014-12-09 22:41:13

BurntPizza (115 views)
2014-12-08 04:46:31
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

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
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!