1. C(++?) to EUPHORIA Code

Can somebody see where I'm going wrong...

--original C code...
void glEnable2D()
{
	int vPort[4];

   glGetIntegerv(GL_VIEWPORT, vPort);

   glMatrixMode(GL_PROJECTION);
   glPushMatrix();
   glLoadIdentity();

   glOrtho(0, vPort[2], 0, vPort[3], -1, 1);
   glMatrixMode(GL_MODELVIEW);
   glPushMatrix();
   glLoadIdentity();
}

--my translation attempt:
global procedure glGo2D()

	--I have no idea what to do with this line!!!
	--glGetIntegerv(GL_VIEWPORT, vPort)
	
	glMatrixMode(GL_PROJECTION)
	glPushMatrix()
	glLoadIdentity()
	
	glOrtho(0, vPort[2], 0, vPort[3], -1, 1)
	glMatrixMode(GL_MODELVIEW)
	glPushMatrix()
	glLoadIdentity()
end procedure

new topic     » topic index » view message » categorize

2. Re: C(++?) to EUPHORIA Code

cklester wrote:
> 
> Can somebody see where I'm going wrong...
> 
> --original C code...
> void glEnable2D()
> {
> 	int vPort[4];
> 
>    glGetIntegerv(GL_VIEWPORT, vPort);
> 
>    glMatrixMode(GL_PROJECTION);
>    glPushMatrix();
>    glLoadIdentity();
> 
>    glOrtho(0, vPort[2], 0, vPort[3], -1, 1);
>    glMatrixMode(GL_MODELVIEW);
>    glPushMatrix();
>    glLoadIdentity();
> }
> 
> --my translation attempt:
> global procedure glGo2D()
> 
> 	--I have no idea what to do with this line!!!
> 	--glGetIntegerv(GL_VIEWPORT, vPort)
> 	
> 	glMatrixMode(GL_PROJECTION)
> 	glPushMatrix()
> 	glLoadIdentity()
> 	
> 	glOrtho(0, vPort[2], 0, vPort[3], -1, 1)
> 	glMatrixMode(GL_MODELVIEW)
> 	glPushMatrix()
> 	glLoadIdentity()
> end procedure
> 


atom vPort
vPort = allocate(16) -- space for 4 integer values

glOrtho(0, vPort[3], 0, vPort[4], -1, 1) Euphoria is 1 based }}}

new topic     » goto parent     » topic index » view message » categorize

3. Re: C(++?) to EUPHORIA Code

Evan Marshall wrote:
> 
> cklester wrote:
> > 
> > Can somebody see where I'm going wrong...
> > 
> > --original C code...
> > void glEnable2D()
> > {
> > 	int vPort[4];
> > 
> >    glGetIntegerv(GL_VIEWPORT, vPort);
> > 
> >    glMatrixMode(GL_PROJECTION);
> >    glPushMatrix();
> >    glLoadIdentity();
> > 
> >    glOrtho(0, vPort[2], 0, vPort[3], -1, 1);
> >    glMatrixMode(GL_MODELVIEW);
> >    glPushMatrix();
> >    glLoadIdentity();
> > }
> > 
> > --my translation attempt:
> > global procedure glGo2D()
> > 
> > 	--I have no idea what to do with this line!!!
> > 	--glGetIntegerv(GL_VIEWPORT, vPort)
> > 	
> > 	glMatrixMode(GL_PROJECTION)
> > 	glPushMatrix()
> > 	glLoadIdentity()
> > 	
> > 	glOrtho(0, vPort[2], 0, vPort[3], -1, 1)
> > 	glMatrixMode(GL_MODELVIEW)
> > 	glPushMatrix()
> > 	glLoadIdentity()
> > end procedure
> > 
> 
> <font color="#330033"></font>
> <font color="#FF00FF">atom </font><font color="#330033">vPort</font>
> <font color="#330033">vPort = allocate(16) </font><font color="#FF0055">--
> space for 4 integer values</font>
> <font color="#330033"></font>
> <font color="#330033">glOrtho(0, vPort</font><font
> color="#993333">[</font><font color="#330033">3</font><font
> color="#993333">]</font><font color="#330033">, 0, vPort</font><font
> color="#993333">[</font><font color="#330033">4</font><font
> color="#993333">]</font><font color="#330033">, -1, 1)  </font><font
> color="#FF0055">--Euphoria is 1 based</font>
> <font color="#330033"></font>


That should be:
glOrtho(0,peek4u(vPort+8),0,peek4u(vPort+12),-1,1)

new topic     » goto parent     » topic index » view message » categorize

4. Re: C(++?) to EUPHORIA Code

Thanks Evan... so glGetIntegerv() isn't needed? What does it do?

new topic     » goto parent     » topic index » view message » categorize

5. Re: C(++?) to EUPHORIA Code

cklester wrote:
> 
> Thanks Evan... so glGetIntegerv() isn't needed? What does it do?


No, you still need to call it.

I assume that the routine is just a wrapper around the API call...

   x_glGetIntegerv = define_c_proc(lib, "glGetIntegerv", {C_INT, C_POINTER))
   procedure glGetIntegerv(atom x, atom ints)
       c_proc(x_glGetIntegerv, {x,ints})
   end procedure

   glGetIntegerv(GL_VIEWPORT, vPort)

It seems to initialize the four integer values in RAM.

-- 
Derek Parnell
Melbourne, Australia

new topic     » goto parent     » topic index » view message » categorize

6. Re: C(++?) to EUPHORIA Code

Hi there,

If all you need to do is miniwrap "glGetIntegerv(GL_VIEWPORT, vPort)"
this should make short work of it...


function glGetInt()
  atom pvPort
  sequence vPort

  pvPort=allocate(16)
  glGetIntegerv(GL_VIEWPORT,pvPort)
  vPort=peek4s({pvPort,4})
  free(pvPort)
  return vPort
end function


You can then call vPort=glGetInt() anytime you need to get
the coordinates:

sequence vPort
vPort=glGetInt()


You can then call glOrtho() as you have it already.

It looks like that function gets four screen coordinates.

Take care,
Al


And, good luck with your programming!

My bumper sticker: "I brake for LED's"

new topic     » goto parent     » topic index » view message » categorize

7. Re: C(++?) to EUPHORIA Code

Derek Parnell wrote:
> 
> cklester wrote:
> > 
> > Thanks Evan... so glGetIntegerv() isn't needed? What does it do?
> 
> 
> No, you still need to call it.
> 
> I assume that the routine is just a wrapper around the API call...
> 
>    x_glGetIntegerv = define_c_proc(lib, "glGetIntegerv", {C_INT, C_POINTER))
>    procedure glGetIntegerv(atom x, atom ints)
>        c_proc(x_glGetIntegerv, {x,ints})
>    end procedure
> 
>    glGetIntegerv(GL_VIEWPORT, vPort)
> 
> It seems to initialize the four integer values in RAM.
> 
> -- 
> Derek Parnell
> Melbourne, Australia

Excellent reply; however, the question I'd like to ask is: does 4 months 
between beta releases of a very popular library seem like a long time to 
anyone else?

Does more than a year seem like a long time between minor (even major)
releases of a very popular library?

Years ago I would have just started a web-poll.  Maybe I just might...

Is it just me?
-- Brian

PS:  True C++ does not easily translate to Euphoria code.  Eu is not OOP.
     It can be done but it's really not meant to be (IMHO).

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu