Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (579)
games submitted by our members
Games in WIP (500)
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  
  new to OpenGL, could use some help  (Read 1262 times)
0 Members and 1 Guest are viewing this topic.
Offline Wildern

Junior Member





« Posted 2010-06-02 19:03:39 »

Basically, I am being forced to use OpenGL to do my drawing (by a 3rd party application that I cannot avoid).
I need to be able to draw in image from a png file.  I need to be able to rotate that image.  Both of these, I have working.  What I need help with it figuring out how to clip the image.  Basically, the image is large and I want to have a small viewport with the image moving/rotating inside it.  The viewport would stay fixed (a small square) and the image I am drawing would pan/rotate behind the viewport square and be clipped to fit within the viewport square (I hope that made sense)

I am currently loading the file and drawing the image as a texture as follows:
(I modified example code to get to here, so please let me know if I am doing this  part incorrectly as well)

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  
m_imageList = gl.glGenLists(1);
gl.glNewList(m_imageList, gl.GL_COMPILE);
gl.glPushMatrix();
gl.glTranslatef(-0.5, -0.5, 0.0);
gl.glTexEnvi(gl.GL_TEXTURE_ENV, gl.GL_TEXTURE_ENV_MODE, gl.GL_MODULATE);
gl.glEnable(gl.GL_TEXTURE_2D);
gl.glBindTexture(gl.GL_TEXTURE_2D, textureID);
gl.glBegin(gl.GL_QUADS);
gl.glTexCoord2f(0.0, 0.0);
gl.glVertex2f(0.0, 0.0);
gl.glTexCoord2f(1.0, 0.0);
gl.glVertex2f(1.0, 0.0);
gl.glTexCoord2f(1.0, 1.0);
gl.glVertex2f(1.0, 1.0);
gl.glTexCoord2f(0.0, 1.0);
gl.glVertex2f(0.0, 1.0);
gl.glEnd();
gl.glPopMatrix();
gl.glEndList();

//later, the drawing....

gl.glPushMatrix();
gl.glLoadIdentity();
gl.glPushMatrix();
gl.glTranslate(x, y, 0.0);
gl.glScalef(256.0, 32.0, 0.0); //actual image size
gl.glColor4f(1.0, 1.0, 1.0, 0.5); //50% transparent
gl.glCallList(m_imageList);
gl.glPopMatrix();
Online Riven
« League of Dukes »

JGO Overlord


Medals: 605
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #1 - Posted 2010-06-02 19:06:49 »

use glScissor if you don't want to use glViewport

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline Wildern

Junior Member





« Reply #2 - Posted 2010-06-02 19:25:06 »

I appreciate the response, but I have attempted to use both of those (I *really* have no clue what I am doing here)

My attempt to use glViewPort resulted in all my images being scaled down to the size of the viewport instead of being clipped, and glScissor doesn't appear to do anything.

I am working within another application's OpenGL context and when it is done drawing, I get a callback letting me know it is safe for me to draw.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Online Riven
« League of Dukes »

JGO Overlord


Medals: 605
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #3 - Posted 2010-06-02 19:27:31 »

glEnable(GL_SCISSOR_TEST);   

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline Wildern

Junior Member





« Reply #4 - Posted 2010-06-02 19:31:49 »

Any idea what the value for that constant should be as all of the Enable constants are commented out of the api wrapper I have to use?
Online Riven
« League of Dukes »

JGO Overlord


Medals: 605
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #5 - Posted 2010-06-02 19:34:01 »

According to:
http://www.blackberry.com/developers/docs/5.0.0api/constant-values.html

public static final int   GL_SCISSOR_TEST   3089

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline Wildern

Junior Member





« Reply #6 - Posted 2010-06-02 19:39:26 »

I managed to get glScissor working.
Thank you Riven!!!!!
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.

xsi3rr4x (32 views)
2014-04-15 18:08:23

BurntPizza (29 views)
2014-04-15 03:46:01

UprightPath (44 views)
2014-04-14 17:39:50

UprightPath (27 views)
2014-04-14 17:35:47

Porlus (44 views)
2014-04-14 15:48:38

tom_mai78101 (65 views)
2014-04-10 04:04:31

BurntPizza (125 views)
2014-04-08 23:06:04

tom_mai78101 (225 views)
2014-04-05 13:34:39

trollwarrior1 (190 views)
2014-04-04 12:06:45

CJLetsGame (198 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!