Codesnippets > 3D-snippets

Link to gl.gbas

<< < (3/5) > >>

Wampus:
Everytime I try to run an app on Nexus 7 (Android) that includes the OpenGLES file I get an error message before anything starts up, "Unfortunately, [app] has stopped."

I also get the same message when I use Kanonet's X_SPRITE replacement code.

Anyone come across a similar issue and solved it? If not, any idea how or if this can be dealt with?

I'm using IDE 11.261

[ Edit: Ok, so OpenGL ES (used in Android and iPhone, probably other mobile devices too) doesn't have glBegin, glVertex or glEnd. Would need to re-code for Android. Will start here if I get the time: http://pandorawiki.org/OpenGL_ES_1.1_Tutorial ]

UBERmonkeybot:
Would anyone be able to supply a bit of example code how to get started with gl.gbas as i don't have a scooby!

Thanks

Schranz0r:
It's a 1:1 wrapper.

Search for some GL-Tutorials :)

Kitty Hello:
glBegin should be wrapped internally. Try it.

UBERmonkeybot:
Wrapped internally?

I have got some quads working but am having difficulty with textures,

I am using spritetomem -> tex%[] but glTexImage2D wont accept the array.


glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, tex%[])

Please could someone put me out of my misery.

Thanks

gl.gbas needs to be included to run this...


--- Code: (glbasic) ---

LOCAL x=100,y=100,z,r

CONSTANT sc=100
GLOBAL texture%=GENSPRITE()
LOCAL  sc=GENSCREEN()
CREATESCREEN sc,texture,32,32
USESCREEN sc


FOR f=0 TO 10
DRAWRECT RND(20),RND(20),5,5,RND(0xffffff)
NEXT
USESCREEN -1

GLOBAL tex%[]
DIM tex%[32*32]
LOCAL  aaaa

aaaa=SPRITE2MEM(tex%[],texture%)
//IF aaaa=0 THEN END
//FOR s=0 TO 32*32-1
//DEBUG "\n"+tex%[s]
//NEXT
//DRAWSPRITE texture,0,0
//SHOWSCREEN
//MOUSEWAIT

REPEAT
//glMatrixMode(GL_PROJECTION)//
   
    glClear(GL_COLOR_BUFFER_BIT AND GL_DEPTH_BUFFER_BIT AND GL_POLYGON_SMOOTH); // Clear The Screen And The Depth Buffer
 
    glShadeModel(GL_SMOOTH) 
    glLoadIdentity();                   // Reset The Current Modelview Matrix
  glTranslatef(x,y,z); 
 


    glBegin(GL_TRIANGLES); 
//glScaled(5,5,5)
glColor3f(255,0,0)
glVertex3f(-sc,-sc,0)

glColor3f(0,255,0)
glVertex3f(0 ,-sc,0)

glColor3f(0,0,0x66)
glVertex3f(00,sc,0)
//glTranslatef(3,0,0)
glEnd()


glLoadIdentity();
glTranslatef(500,100,0)
glRotated(r,0,0,1)
INC r,.5



glGenTextures(1,tex%[])
glEnable(GL_TEXTURE_2D)
 
glBindTexture(GL_TEXTURE_2D, texture)//tex%[]);

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, tex%[]);

    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

glBegin(GL_QUADS); 
  glColor3f(0,0,33); 

glTexCoord2f(0,-1)
glVertex3f(-sc, -sc,0)         //tl
 
    glTexCoord2f( 1,1) 
    glVertex3f(sc,-sc,0)        //tr
   
glTexCoord2f( 1,0)  //br
    glVertex3f( sc,sc,0) 
   
    glColor3f(0,33,33)
   
    glTexCoord2f( 0,0)          //
glVertex3f( -sc, sc,0)          // bl
glEnd();                        // Done Drawing A Quad
   





IF KEY(203) THEN DEC x,1

IF KEY(205) THEN INC x,1
IF KEY(200) THEN DEC y,1
IF KEY(208) THEN INC y,1
IF KEY(12) THEN DEC z,.1
IF KEY(13) THEN INC z,.1

SHOWSCREEN
UNTIL FALSE










--- End code ---


Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version