Author Topic: XOR graphics  (Read 7932 times)

Offline Minion

  • Mr. Polyvector
  • ***
  • Posts: 229
    • View Profile
XOR graphics
« on: 2012-Mar-11 »
Not even sure if this is possible in GLB but I`ll ask anways.

Is it possible to XOR a graphic (be it DRARECT or POLYVECTOR or DRAWSPRITE) to the screen (without the use of shaders) ?
« Last Edit: 2012-Apr-17 by Moru »

Offline Ian Price

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4159
  • On the shoulders of giants.
    • View Profile
    • My Apps
Re: XOR grpahics
« Reply #1 on: 2012-Mar-11 »
I suppose you could do a SPRITE2MEM() then make a function to XOR the data in the array, then use MEM2SPRITE().

Dunno. Why would you need this?
I came. I saw. I played.

Offline Minion

  • Mr. Polyvector
  • ***
  • Posts: 229
    • View Profile
Re: XOR grpahics
« Reply #2 on: 2012-Apr-15 »
Well I got my XOR graphics workin  =D But I feel that for such a simple effect it may slow the whole project down  :(

Offline Ian Price

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4159
  • On the shoulders of giants.
    • View Profile
    • My Apps
Re: XOR grpahics
« Reply #3 on: 2012-Apr-15 »
Manic Miner attribute clash, perchance?
I came. I saw. I played.

Offline Minion

  • Mr. Polyvector
  • ***
  • Posts: 229
    • View Profile
Re: XOR grpahics
« Reply #4 on: 2012-Apr-15 »
Aye. But, I may just have come up with another idea. One so brilliant only I could have come up with it. So fantastic that it wouldn`t just work on a character, but the whole screen. So mind boggeling that Im having to break my cardinal rull with this project and slip into inline ;( (I wanted to do this as purely GLB, but this one thing is iluding me) But by golly, if this works I will be chuffed to bits !

Offline bigsofty

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 2747
    • View Profile
Re: XOR grpahics
« Reply #5 on: 2012-Apr-15 »
Use a little bit of OpenGL, that is, logic-ops.

Turn on XOR mode...

Code: (glbasic) [Select]
glEnable(GL_COLOR_LOGIC_OP);
glLogicOp(GL_XOR);


Turn off...

Code: (glbasic) [Select]
glDisable(GL_COLOR_LOGIC_OP);
I am not at my PC at the moment, so I can't test. I can't see why this would not work TBH and it should not affect speed at all. I would use Gernots OpenGL lib or import the commands + #defines, then inline them above and below your rendering code.
Cheers,

Ian.

“It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration.”
(E. W. Dijkstra)

Offline Minion

  • Mr. Polyvector
  • ***
  • Posts: 229
    • View Profile
Re: XOR grpahics
« Reply #6 on: 2012-Apr-15 »
That is axactly what I had in mind. My only problem is how to implement it. Not too clever when it comes to inline and ogl stuff. But yeah, shouldn`t affect the speed at all.

Offline bigsofty

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 2747
    • View Profile
Re: XOR grpahics
« Reply #7 on: 2012-Apr-15 »
Including Gernots GL.gbas, from the samples...

Code: (glbasic) [Select]
// Xor mode, on/off sample

LOCAL i%

WHILE 1=1

GLXOR(TRUE) // On

FOR i%=0 TO 999
DRAWLINE RND(640),RND(480),RND(640),RND(480),RGB(255,255,255)
NEXT

GLXOR(FALSE) // Off

SHOWSCREEN

MOUSEWAIT

WEND


FUNCTION GLXOR: xorFlg%
IF xorFlg%
glEnable(GL_COLOR_LOGIC_OP)
glLogicOp(GL_XOR)
ELSE
glDisable(GL_COLOR_LOGIC_OP)
ENDIF
ENDFUNCTION

Cheers,

Ian.

“It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration.”
(E. W. Dijkstra)

Offline Minion

  • Mr. Polyvector
  • ***
  • Posts: 229
    • View Profile
Re: XOR grpahics
« Reply #8 on: 2012-Apr-15 »
Thanks for the help Biggy. Tried all day with inline stuff and whatnot but until you posted the snippet I didnt know about GL.GBAS which already had everything defined (I was seaching all over the net for those defines).

Anyway, only taken me all day, but finally got there ;)

http://twitpic.com/9a9tty

Now with authentic BBC MICRO style colour clash ;)

Offline bigsofty

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 2747
    • View Profile
Re: XOR grpahics
« Reply #9 on: 2012-Apr-15 »
Glad to help. It's looks very good too!  :good:
Cheers,

Ian.

“It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration.”
(E. W. Dijkstra)

Offline Ian Price

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4159
  • On the shoulders of giants.
    • View Profile
    • My Apps
Re: XOR grpahics
« Reply #10 on: 2012-Apr-16 »
That's pretty cool to see nowadays without the use of an emulator!
I came. I saw. I played.

Offline Minion

  • Mr. Polyvector
  • ***
  • Posts: 229
    • View Profile
Re: XOR grpahics
« Reply #11 on: 2012-Apr-16 »
Ooops :(

Just tried compiling to Android and it came back with this ...

Code: (glbasic) [Select]

_______________________________________
*** Configuration: ANDROID ***
precompiling:
GPC - GLBasic Precompiler V.10.104 SN:17d88e8b - 3D, NET
Wordcount:3832 commands
compile+link:
C:\Users\WINDOW~1\AppData\Local\Temp\glbasic\gpc_temp2.cpp: In function 'DGInt __GLBASIC__::glGetClipPlane(DGInt, __GLBASIC__::DGIntArray&)':
C:\Users\WINDOW~1\AppData\Local\Temp\glbasic\gpc_temp2.cpp:733: error: no matching function for call to 'DIMDATA(__GLBASIC__::DGIntArray&, int, __GLBASIC__::GLdouble [4])'
Q:\Compiler/platform/Include/glb.h:882: note: candidates are: void __GLBASIC__::DIMDATA(__GLBASIC__::DGIntArray&, int, DGInt*)
Q:\Compiler/platform/Include/glb.h:884: note:                 void __GLBASIC__::DIMDATA(__GLBASIC__::DGNatArray&, int, DGNat*)
C:\Users\WINDOW~1\AppData\Local\Temp\glbasic\gpc_temp2.cpp: In function 'DGInt __GLBASIC__::glLoadMatrixd(__GLBASIC__::DGIntArray&)':
C:\Users\WINDOW~1\AppData\Local\Temp\glbasic\gpc_temp2.cpp:1741: error: cannot convert 'DGInt*' to 'const __GLBASIC__::GLdouble*' for argument '1' to 'void glLoadMatrixd(const __GLBASIC__::GLdouble*)'
C:\Users\WINDOW~1\AppData\Local\Temp\glbasic\gpc_temp2.cpp: In function 'DGInt __GLBASIC__::glMultMatrixd(__GLBASIC__::DGIntArray&)':
C:\Users\WINDOW~1\AppData\Local\Temp\glbasic\gpc_temp2.cpp:1796: error: cannot convert 'DGInt*' to 'const __GLBASIC__::GLdouble*' for argument '1' to 'void glMultMatrixd(const __GLBASIC__::GLdouble*)'
C:\Users\WINDOW~1\AppData\Local\Temp\glbasic\gpc_temp2.cpp: In function 'DGInt __GLBASIC__::glVertex2dv(__GLBASIC__::DGIntArray&)':
C:\Users\WINDOW~1\AppData\Local\Temp\glbasic\gpc_temp2.cpp:2691: error: cannot convert 'DGInt*' to 'const __GLBASIC__::GLdouble*' for argument '1' to 'void glVertex2dv(const __GLBASIC__::GLdouble*)'
C:\Users\WINDOW~1\AppData\Local\Temp\glbasic\gpc_temp2.cpp: In function 'DGInt __GLBASIC__::glVertex3dv(__GLBASIC__::DGIntArray&)':
C:\Users\WINDOW~1\AppData\Local\Temp\glbasic\gpc_temp2.cpp:2771: error: cannot convert 'DGInt*' to 'const __GLBASIC__::GLdouble*' for argument '1' to 'void glVertex2dv(const __GLBASIC__::GLdouble*)'
C:\Users\WINDOW~1\AppData\Local\Temp\glbasic\gpc_temp2.cpp: In function 'DGInt __GLBASIC__::glVertex4dv(__GLBASIC__::DGIntArray&)':
C:\Users\WINDOW~1\AppData\Local\Temp\glbasic\gpc_temp2.cpp:2851: error: cannot convert 'DGInt*' to 'const __GLBASIC__::GLdouble*' for argument '1' to 'void glVertex2dv(const __GLBASIC__::GLdouble*)'
C:\Users\WINDOW~1\AppData\Local\Temp\glbasic\gpc_temp2.cpp: In function 'DGInt __GLBASIC__::glNormal3dv(__GLBASIC__::DGIntArray&)':
C:\Users\WINDOW~1\AppData\Local\Temp\glbasic\gpc_temp2.cpp:3091: error: cannot convert 'DGInt*' to 'const __GLBASIC__::GLdouble*' for argument '1' to 'void glNormal3dv(const __GLBASIC__::GLdouble*)'
C:\Users\WINDOW~1\AppData\Local\Temp\glbasic\gpc_temp2.cpp: In function 'DGInt __GLBASIC__::glIndexdv(__GLBASIC__::DGIntArray&)':
C:\Users\WINDOW~1\AppData\Local\Temp\glbasic\gpc_temp2.cpp:3347: error: cannot convert 'DGInt*' to 'const __GLBASIC__::GLdouble*' for argument '1' to 'void glIndexdv(const __GLBASIC__::GLdouble*)'
C:\Users\WINDOW~1\AppData\Local\Temp\glbasic\gpc_temp2.cpp: In function 'DGInt __GLBASIC__::glColor3dv(__GLBASIC__::DGIntArray&)':
C:\Users\WINDOW~1\AppData\Local\Temp\glbasic\gpc_temp2.cpp:3955: error: cannot convert 'DGInt*' to 'const __GLBASIC__::GLdouble*' for argument '1' to 'void glColor3dv(const __GLBASIC__::GLdouble*)'
C:\Users\WINDOW~1\AppData\Local\Temp\glbasic\gpc_temp2.cpp: In function 'DGInt __GLBASIC__::glTexCoord1dv(__GLBASIC__::DGIntArray&)':
C:\Users\WINDOW~1\AppData\Local\Temp\glbasic\gpc_temp2.cpp:4723: error: cannot convert 'DGInt*' to 'const __GLBASIC__::GLdouble*' for argument '1' to 'void glTexCoord1dv(const __GLBASIC__::GLdouble*)'
C:\Users\WINDOW~1\AppData\Local\Temp\glbasic\gpc_temp2.cpp: In function 'DGInt __GLBASIC__::glTexCoord2dv(__GLBASIC__::DGIntArray&)':
C:\Users\WINDOW~1\AppData\Local\Temp\glbasic\gpc_temp2.cpp:4803: error: cannot convert 'DGInt*' to 'const __GLBASIC__::GLdouble*' for argument '1' to 'void glTexCoord2dv(const __GLBASIC__::GLdouble*)'
C:\Users\WINDOW~1\AppData\Local\Temp\glbasic\gpc_temp2.cpp: In function 'DGInt __GLBASIC__::glTexCoord3dv(__GLBASIC__::DGIntArray&)':
C:\Users\WINDOW~1\AppData\Local\Temp\glbasic\gpc_temp2.cpp:4883: error: cannot convert 'DGInt*' to 'const __GLBASIC__::GLdouble*' for argument '1' to 'void glTexCoord3dv(const __GLBASIC__::GLdouble*)'
C:\Users\WINDOW~1\AppData\Local\Temp\glbasic\gpc_temp2.cpp: In function 'DGInt __GLBASIC__::glTexCoord4dv(__GLBASIC__::DGIntArray&)':
C:\Users\WINDOW~1\AppData\Local\Temp\glbasic\gpc_temp2.cpp:4963: error: cannot convert 'DGInt*' to 'const __GLBASIC__::GLdouble*' for argument '1' to 'void glTexCoord4dv(const __GLBASIC__::GLdouble*)'
C:\Users\WINDOW~1\AppData\Local\Temp\glbasic\gpc_temp2.cpp: In function 'DGInt __GLBASIC__::glRasterPos2dv(__GLBASIC__::DGIntArray&)':
C:\Users\WINDOW~1\AppData\Local\Temp\glbasic\gpc_temp2.cpp:5427: error: cannot convert 'DGInt*' to 'const __GLBASIC__::GLdouble*' for argument '1' to 'void glRasterPos2dv(const __GLBASIC__::GLdouble*)'
C:\Users\WINDOW~1\AppData\Local\Temp\glbasic\gpc_temp2.cpp: In function 'DGInt __GLBASIC__::glRasterPos3dv(__GLBASIC__::DGIntArray&)':
C:\Users\WINDOW~1\AppData\Local\Temp\glbasic\gpc_temp2.cpp:5507: error: cannot convert 'DGInt*' to 'const __GLBASIC__::GLdouble*' for argument '1' to 'void glRasterPos3dv(const __GLBASIC__::GLdouble*)'
C:\Users\WINDOW~1\AppData\Local\Temp\glbasic\gpc_temp2.cpp: In function 'DGInt __GLBASIC__::glRasterPos4dv(__GLBASIC__::DGIntArray&)':
C:\Users\WINDOW~1\AppData\Local\Temp\glbasic\gpc_temp2.cpp:5587: error: cannot convert 'DGInt*' to 'const __GLBASIC__::GLdouble*' for argument '1' to 'void glRasterPos4dv(const __GLBASIC__::GLdouble*)'
C:\Users\WINDOW~1\AppData\Local\Temp\glbasic\gpc_temp2.cpp: In function 'DGInt __GLBASIC__::glRectdv(__GLBASIC__::DGIntArray&, __GLBASIC__::DGIntArray&)':
C:\Users\WINDOW~1\AppData\Local\Temp\glbasic\gpc_temp2.cpp:5795: error: cannot convert 'DGInt*' to 'const __GLBASIC__::GLdouble*' for argument '1' to 'void glRectdv(const __GLBASIC__::GLdouble*, const __GLBASIC__::GLdouble*)'
C:\Users\WINDOW~1\AppData\Local\Temp\glbasic\gpc_temp2.cpp: In function 'DGInt __GLBASIC__::glTexGendv(DGInt, DGInt, __GLBASIC__::DGIntArray&)':
C:\Users\WINDOW~1\AppData\Local\Temp\glbasic\gpc_temp2.cpp:6889: error: cannot convert 'DGInt*' to 'const __GLBASIC__::GLdouble*' for argument '3' to 'void glTexGendv(__GLBASIC__::GLenum, __GLBASIC__::GLenum, const __GLBASIC__::GLdouble*)'
C:\Users\WINDOW~1\AppData\Local\Temp\glbasic\gpc_temp2.cpp: In function 'DGInt __GLBASIC__::glGetTexGendv(DGInt, DGInt, __GLBASIC__::DGIntArray&)':
C:\Users\WINDOW~1\AppData\Local\Temp\glbasic\gpc_temp2.cpp:6955: error: cannot convert 'DGInt*' to '__GLBASIC__::GLdouble*' for argument '3' to 'void glGetTexGendv(__GLBASIC__::GLenum, __GLBASIC__::GLenum, __GLBASIC__::GLdouble*)'
C:\Users\WINDOW~1\AppData\Local\Temp\glbasic\gpc_temp2.cpp: In function 'DGInt __GLBASIC__::glEvalCoord1dv(__GLBASIC__::DGIntArray&)':
C:\Users\WINDOW~1\AppData\Local\Temp\glbasic\gpc_temp2.cpp:7369: error: cannot convert 'DGInt*' to 'const __GLBASIC__::GLdouble*' for argument '1' to 'void glEvalCoord1dv(const __GLBASIC__::GLdouble*)'
C:\Users\WINDOW~1\AppData\Local\Temp\glbasic\gpc_temp2.cpp: In function 'DGInt __GLBASIC__::glEvalCoord2dv(__GLBASIC__::DGIntArray&)':
C:\Users\WINDOW~1\AppData\Local\Temp\glbasic\gpc_temp2.cpp:7481: error: cannot convert 'DGInt*' to 'const __GLBASIC__::GLdouble*' for argument '1' to 'void glEvalCoord2dv(const __GLBASIC__::GLdouble*)'
*** FATAL ERROR - Please post this output in the forum
_______________________________________
*** Finished ***
Elapsed: 9.4 sec. Time: 14:59
Build: 0 succeeded.
*** 1 FAILED ***



Offline bigsofty

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 2747
    • View Profile
Re: XOR grpahics
« Reply #12 on: 2012-Apr-16 »
I don't have an Android device but I suspect the problem may lay with gl.gbas. The gl.gbas is an OpenGL wrapper, Android needs OpenGLES, the errors you see are the differences from opengl.h and opengles.h.

Try just cutting gl.gbas down to the commands that you require.
Cheers,

Ian.

“It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration.”
(E. W. Dijkstra)

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10814
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: XOR grpahics
« Reply #13 on: 2012-Apr-16 »
This works for me on android.


[attachment deleted by admin]

Offline bigsofty

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 2747
    • View Profile
Re: XOR grpahics
« Reply #14 on: 2012-Apr-17 »
Handy, thanks Gernot, I assume this will work on IOS as well?
Cheers,

Ian.

“It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration.”
(E. W. Dijkstra)