Random Homebrew: Kobo Deluxe
Kobo Deluxe is a 3rd person scrolling 2D shooter with a simple and responsive control system - which [...]
Friends: Coding 'n Cracking - Nymphaea - PS3 Forum - darkforestgroup - daxhordes.org - Tgames - coldbird - gopsp.it - pspstation.org - prometheus - hgoel.info - MakeSmartTV - ps vita

Cant draw image to Screen

Forum rules
Any post not directly related to programming will be moderated.
Do not request people to code something for you.
Avoid posting messages that do not bring anything to the conversation. We want the threads in this subforum to stay focused.

Cant draw image to Screen

Postby remus » Sun Jan 22, 2012 4:21 pm

Hi Folks, this is my first post on this forum.

First, here is my setup
- PSP 2000 on CFW '6.60 ME-1.6'
- Linux Mint 12 (based on the latest Ubuntu with an usable Gnome Interface)
- PSP Toolchain 'minpspw_0.10.0-1ubuntu0_amd64'

I have installed the Plugins on the PSP and i can compile and run the samples from the PSPSDK with psplink just fine.

I have started with the SimpleTutorials and if i try to draw an image, it won´t show up.

Here is my main.c
Code: Select all
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* main.c - A basic example of getting code onto the ME. This was based on
* the sample code written by crazyc on the pspdev forums.
*
* Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
*
* $Id: main.c 1095 2005-09-27 21:02:16Z jim $
*/
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspctrl.h>
#include <pspdisplay.h>
#include <stdlib.h>
#include <string.h>
#include <pspgu.h>
#include "./common/graphics.h"
#include "./common/framebuffer.h"
#include "./common/callbacks.h"
#include "./common/vram.h"

/* Define the module info section */
# ifdef PSPFW3X
PSP_MODULE_INFO("test prx", 0x0, 1, 1);
PSP_HEAP_SIZE_KB(6*1024);
# else
PSP_MODULE_INFO("test", 0x1000, 1, 1);
# endif

#define BUF_WIDTH (512)
#define SCR_WIDTH (480)
#define SCR_HEIGHT (272)

#define GRID_WIDTH 18
#define GRID_HEIGHT 18

static unsigned int __attribute__((aligned(16))) list[262144];

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

/* Define printf, just to make typing easier */
#define printf   pspDebugScreenPrintf

#define Max(X,Y)((X) > (Y) ? (X) : (Y))

#define RGB(r, g, b) ((r)|((g)<<8)|((b)<<16))
Color White = RGB(255, 255, 255);
Color Black = RGB(0, 0, 0);

void dump_threadstatus(void);

int done = 0;

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

/* Callback thread */
int CallbackThread(SceSize args, void *argp)
{
   int cbid;

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

   return 0;
}

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

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

   return thid;
}

void initMyGraphics(void) {
   sceGuInit();
   // setup GU

   void* fbp0 = getStaticVramBuffer(BUF_WIDTH,SCR_HEIGHT,GU_PSM_8888);
   void* fbp1 = getStaticVramBuffer(BUF_WIDTH,SCR_HEIGHT,GU_PSM_8888);
   void* zbp = getStaticVramBuffer(BUF_WIDTH,SCR_HEIGHT,GU_PSM_4444);

   sceGuStart(GU_DIRECT,list);
   sceGuDrawBuffer(GU_PSM_8888,fbp0,BUF_WIDTH);
   sceGuDispBuffer(SCR_WIDTH,SCR_HEIGHT,fbp1,BUF_WIDTH);
   sceGuDepthBuffer(zbp,BUF_WIDTH);
   sceGuOffset(2048 - (SCR_WIDTH/2),2048 - (SCR_HEIGHT/2));
   sceGuViewport(2048,2048,SCR_WIDTH,SCR_HEIGHT);
   sceGuDepthRange(0xc350,0x2710);
   sceGuScissor(0,0,SCR_WIDTH,SCR_HEIGHT);
   sceGuEnable(GU_SCISSOR_TEST);
   sceGuDepthFunc(GU_GEQUAL);
   sceGuEnable(GU_DEPTH_TEST);
   sceGuFrontFace(GU_CW);
   sceGuShadeModel(GU_SMOOTH);
//   sceGuEnable(GU_CULL_FACE);
   sceGuEnable(GU_CLIP_PLANES);
   sceGuFinish();
   sceGuSync(0,0);

   sceDisplayWaitVblankStart();
   sceGuDisplay(GU_TRUE);
}

int main(void) {
   SetupCallbacks();
   initMyGraphics();
   pspDebugScreenInit();

   SceCtrlData pad;
   sceCtrlSetSamplingCycle(0);
   sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);

   Image* image = loadImage("DemoTexture.png");


    while (1) {
       sceGuStart(GU_DIRECT,list);

      // clear screen

      sceGuClearColor(0x000000);
      sceGuClearDepth(0);
      sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT);

      fillScreenRect(White, 0, 0, 480, 272);
      flipScreen();

      pspDebugScreenSetXY(0, 2);
      sceDisplayWaitVblankStart();
      if (!image) {
         printf("image was not found");
      } else {
         printf("drawing image (%i,%i)", image->imageWidth, image->imageHeight);
         blitAlphaImageToScreen(0, 0, image->imageWidth, image->imageHeight, image, 20, 40);
      }

       sceCtrlReadBufferPositive(&pad, 1);
      pspDebugScreenSetXY(0, 3);

      printf("Analog X = %d ", pad.Lx);
      printf("Analog Y = %d \n", pad.Ly);

      if (pad.Buttons != 0){
         if (pad.Buttons & PSP_CTRL_SQUARE){
            printf("Square pressed \n");
         }
         if (pad.Buttons & PSP_CTRL_TRIANGLE){
            printf("Triangle pressed \n");
         }
         if (pad.Buttons & PSP_CTRL_CIRCLE){
            printf("Cicle pressed \n");
         }
         if (pad.Buttons & PSP_CTRL_CROSS){
            printf("Cross pressed \n");
         }

         if (pad.Buttons & PSP_CTRL_UP){
            printf("Up pressed \n");
         }
         if (pad.Buttons & PSP_CTRL_DOWN){
            printf("Down pressed \n");
         }
         if (pad.Buttons & PSP_CTRL_LEFT){
            printf("Left pressed \n");
         }
         if (pad.Buttons & PSP_CTRL_RIGHT){
            printf("Right pressed \n");
         }

         if (pad.Buttons & PSP_CTRL_START){
            printf("Start pressed \n");
         }
         if (pad.Buttons & PSP_CTRL_SELECT){
            printf("Select pressed \n");
         }
         if (pad.Buttons & PSP_CTRL_LTRIGGER){
            printf("L-trigger pressed \n");
         }
         if (pad.Buttons & PSP_CTRL_RTRIGGER){
            printf("R-trigger pressed \n");
         }
      }
      //sceDisplayWaitVblankStart();
      //blitImageToScreen(0, 0, 128, 128, image, 0, 0);

      flipScreen();
   }

   sceKernelSleepThread();
   sceKernelExitGame();
   return 0;
}


If i run this code, the debug output appears just fine and it changes correctly, if i press a button. But the image does not appear. I have tried many other pngs but with no success.

I hope someone can help me. :-)

With best regards
remus
remus
 
Posts: 2
Joined: Sun Jan 22, 2012 4:12 pm

Re: Cant draw image to Screen

Postby m0skit0 » Tue Jan 24, 2012 9:02 am

Probably because you've commented out:

Code: Select all
//blitImageToScreen(0, 0, 128, 128, image, 0, 0);

?
I wanna lots of mov al,0xb
Image
"just not into this RA stuffz"
User avatar
m0skit0
Guru
 
Posts: 4783
Joined: Mon Sep 27, 2010 6:01 pm

Re: Cant draw image to Screen

Postby remus » Sat Jan 28, 2012 12:45 am

Sorry for the late reply, but the forum was down for me for about 3 days.

No, the main problem were both libpng and libz. I recompiled both and now i can draw images.

But if i try to draw an image with an alpha Channel and Call "blitAlphaImageToScreen" the image i try to draw is totally scrambled. I tried many different pictures, but the problem still persists.

Does anybody have an good idea or have done this himself?

best regards
remus
remus
 
Posts: 2
Joined: Sun Jan 22, 2012 4:12 pm

Re: Cant draw image to Screen

Postby Geecko » Mon Feb 20, 2012 7:39 pm

Use a real graphics library, like this one : https://github.com/GeeckoDev/gLib2D

I created it to replace the obsolete "graphics.h" library.
Contributing to the most awesome project yet: uOFW. Join us!
gLib2D - A simple, fast, light-weight 2D graphics library for PSP.
intraFont-G - A mod of intraFont by BenHur which adds rotation support.
Check out my GitHub repo!
Geecko
 
Posts: 43
Joined: Sun Nov 07, 2010 7:09 pm

Re: Cant draw image to Screen

Postby noname120 » Tue Feb 21, 2012 6:12 pm

@Gecko: I like your hidden ad ;) I actually use the one from dridri (the libge) but I'll switch to another one if needed. What advantage does your lib have ?
noname120
 
Posts: 658
Joined: Thu Oct 07, 2010 4:29 pm

Re: Cant draw image to Screen

Postby V@ughn » Thu Mar 01, 2012 3:32 pm

Geecko wrote:Use a real graphics library, like this one : https://github.com/GeeckoDev/gLib2D

I created it to replace the obsolete "graphics.h" library.

I have used that one and I must say it is a great library :D

you can also use oslib (although I do not know if it is being updated anymore)
http://www.forums.qj.net/psp-development-forum/158606-release-oslib-mod-version-1-1-0-a.html
Want to see my latest games in action? Check out my epic youtube channel! http://www.youtube.com/user/TVKProgrammer
V@ughn
 
Posts: 65
Joined: Wed Dec 21, 2011 10:51 pm
Location: stuck inside the matrix...darn you C++


Return to Programming

Who is online

Users browsing this forum: No registered users and 5 guests