forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

pspgl - problem with GL_QUADS

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Jim



Joined: 02 Jul 2005
Posts: 487
Location: Sydney

PostPosted: Fri Jan 13, 2006 8:16 pm    Post subject: pspgl - problem with GL_QUADS Reply with quote

I've knocked up the following test to show a problem with the GL_QUADS primitive
Code:


#include <pspkernel.h>
#include <pspthreadman.h>
#include <pspiofilemgr.h>
#include <pspiofilemgr_dirent.h>
#include <pspctrl.h>
#include <pspdisplay.h>
#include <pspdebug.h>
#include <psprtc.h>

#include <GLES/egl.h>
#include <GL/gl.h>

#include <stdlib.h>
#include <string.h>

/* Define the module info section */
PSP_MODULE_INFO("test", 0, 1, 1);

/* Define the main thread's attribute value (optional) */
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER);

static int done = 0;

/* Exit callback */
int exit_callback(void)
{
   done = 1;
   return 0;
}

/* Callback thread */
void CallbackThread(void *arg)
{
   int cbid;

   cbid = sceKernelCreateCallback("Exit Callback", (void *)exit_callback, NULL);
   sceKernelRegisterExitCallback(cbid);

   sceKernelSleepThreadCB();
}

/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void)
{
   int thid = 0;

   thid = sceKernelCreateThread("update_thread", (void *)CallbackThread, 0x11, 0xFA0, 0, 0);
   if(thid >= 0)
   {
      sceKernelStartThread(thid, 0, 0);
   }

   return thid;
}

static const EGLint attrib_list[]=
{
   EGL_RED_SIZE, 1,
   EGL_GREEN_SIZE, 1,
   EGL_BLUE_SIZE, 1,
   EGL_ALPHA_SIZE, 0,
   EGL_DEPTH_SIZE, 0,
   EGL_NONE
};

EGLDisplay dpy;
EGLSurface surface;

static void init_egl(void)
{
   EGLConfig config;
   EGLint num_configs;
   EGLContext ctx;

   dpy = eglGetDisplay(0);
   eglInitialize(dpy, NULL, NULL);

   eglChooseConfig(dpy, attrib_list, &config, 1, &num_configs);

   if (num_configs == 0)
      return;

   ctx = eglCreateContext(dpy, config, NULL, NULL);
   surface = eglCreateWindowSurface(dpy, config, 0, NULL);
   eglMakeCurrent(dpy, surface, surface, ctx);
}

int main(int argc, char **argv)
{
   SceCtrlData pad;

   sceCtrlSetSamplingCycle(0);
   sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);

   init_egl();
   
   glShadeModel(GL_SMOOTH);                     // Enable Smooth Shading
   glClearColor(0.0f, 0.0f, 0.0f, 1.0f);            // Black Background
   glDepthFunc(GL_ALWAYS);
   glDisable(GL_DEPTH_TEST);

   glClear(GL_COLOR_BUFFER_BIT);

   //viewport in top left hand corner of window
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
   glOrthof(0,640,480,0,-1,1);
   glMatrixMode(GL_MODELVIEW);
   glLoadIdentity();
   glDrawBuffer(GL_BACK);

   glViewport(0,0,(GLsizei)480,(GLsizei)272);

   SetupCallbacks();

   glColor3ub(255,255,255);

   do
   {
      glBegin(GL_QUADS);

      glVertex2i(0,0);
      glVertex2i(100,0);
      glVertex2i(100,100);
      glVertex2i(0,100);

      glVertex2i(150+0,0);
      glVertex2i(150+100,0);
      glVertex2i(150+100,100);
      glVertex2i(150+0,100);

      glEnd();

      glBegin(GL_QUADS);

      glVertex2i(0,150+0);
      glVertex2i(100,150+0);
      glVertex2i(100,150+100);
      glVertex2i(0,150+100);

      glEnd();

      glBegin(GL_QUADS);

      glVertex2i(150+0,150+0);
      glVertex2i(150+100,150+0);
      glVertex2i(150+100,150+100);
      glVertex2i(150+0,150+100);

      glEnd();

      eglSwapBuffers(dpy, surface);

      sceCtrlReadBufferPositive(&pad, 1);

   } while (!pad.Buttons && !done);

   sceKernelExitGame();
   return 0;
}


The problem is, unless I do a glBegin/End for each quad, they get linked together by an extra triangle. The sample code shows the problem. GL_TRIANGLES works fine however.
I'm using today's SVN pspgl.

Thanks in advance for any insight.

Jim
_________________
http://www.dbfinteractive.com
Back to top
View user's profile Send private message Visit poster's website
PeterM



Joined: 31 Dec 2005
Posts: 125
Location: Edinburgh, UK

PostPosted: Sat Jan 14, 2006 12:16 am    Post subject: Reply with quote

I don't think quads are supported yet ( http://www.goop.org/psp/gl/#immediate ).
Back to top
View user's profile Send private message Visit poster's website
Jim



Joined: 02 Jul 2005
Posts: 487
Location: Sydney

PostPosted: Sat Jan 14, 2006 8:07 am    Post subject: Reply with quote

Oh, rats! I should have spotted that. Thanks Peter.

Jim
_________________
http://www.dbfinteractive.com
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group